-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhashpasscrack.py
More file actions
49 lines (40 loc) · 1.28 KB
/
hashpasscrack.py
File metadata and controls
49 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#Small tool for dictionary based attack
#coded by -> payload
#code require two file
#1)Hash file with password as plaintext and in hash format --- filename = demo_hash_pass.txt
#2)/etc/shadow --- filename = demoshadow.txt
#note:- this the file which i have used uses crypt() from python with max salt value of 2
# /etc/shadow may use diff hashing algo which may differ from the one i have used.
def readshadow():
shadow=open('demoshadow.txt','r')
line=shadow.readline()
while line:
data=line.strip()
if ":" in data:
user=line.split(':')[0]
hashpass=line.split(':')[1]
#print "******"
#print user
#print "in readshadow->"+str(hashpass)
gethashfile(hashpass)
line=shadow.readline()
shadow.close()
def gethashfile(cmphash):
#print "in gethashfile->"+str(cmphash)
hashfile=open('demo_hash_pass.txt','r')
line=hashfile.readline()
while line:
data=line.strip()
if ":" in data:
user=line.split(':')[0]
password=line.split(':')[1]
hashpass=line.split(':')[2].strip(' ')
if(hashpass==cmphash):
print "[+]FOUND[+]"
print "[+]USERNAME="+str(user)+" PASSWORD="+str(password)+" CRYPTPASS="+str(hashpass)
line=hashfile.readline()
hashfile.close()
def main():
readshadow()
if __name__=='__main__':
main()