forked from witchfindertr/pentest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrack_md5.py
executable file
·71 lines (61 loc) · 2.04 KB
/
crack_md5.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python
# Simple python code for crack md5 double salt
# md5($salt + $password + $salt)
# This encryption that I get with the hash format $md5 + $salt, and i found the static salt example like "Idontwanttosharethissalt"
# ./crack_md5.py hash.txt /usr/share/wordlists/rockyou.txt
import hashlib, os, sys
import time
try:
dict = sys.argv[2]
file = sys.argv[1]
except:
print "[+] Usage: " + os.path.basename(__file__) + " hashfile wordlistfile"
print "[+] Example: " + os.path.basename(__file__) + " hash.txt rockyou.txt"
sys.exit(1)
staticsalt = "Idontwanttosharethissalt"
start = time.time()
end = time.time()
class nonlocal:
recover = 0
#parsing hash dan salt
def main():
with open(file) as hashfile:
print "[+] Cracking start"
global hashsum
hashsum = sum(1 for _ in hashfile)
print "[+] Total Hash : %s\n" % (hashsum)
hashfile.close()
with open(file) as hashfile:
salt = []
hash = []
for i in hashfile:
pars = i.strip()
hash = pars[0:32]
salt = pars[33:]
global salting
salting = salt
global crackdah
crackdah = hash
crack()
hashfile.close()
print "\n[+] Recovered : %s/%s" % (nonlocal.recover, hashsum)
print ("[+] Total Time : %s seconds " % format(time.time() - start))
#open wordlist
def crack():
with open(dict) as dictfile:
for n in dictfile:
pwd = n.strip()
global password
password = pwd
if hashlib.md5(staticsalt+password+salting).hexdigest() == crackdah:
print "%s : %s" % (crackdah, password)
nonlocal.recover += 1
return main
dictfile.close()
try:
main()
except (KeyboardInterrupt, SystemExit):
print "\n[+] Recovered : %s/%s" % (nonlocal.recover, hashsum)
print "[+] Not Recovered : %s" % (hashsum - nonlocal.recover)
print ("[+] Total Time : %s seconds " % format(time.time() - start))
print "\n[-] Exit"