Simple python code for crack md5 double salt

I want to share my simple python code for crack md5 double salt, not perfect but it can be used
This encryption format looks like

md5($salt + $password + $salt)

because I was curious about the password, finally I tried to make a simple code with python for crack the hash

Example:
2016-08-09_18-26-37

File hash:
04767e78e3d4c8afaa85e7be1d022d7c:barbar
e6ab72d7ee2206d232074bfa439d1958:foofoo
a3601c16af573f890dd355bd7f8dfcfb:foobla

This encryption that I get with the hash format $md5 + $salt, and i found the static salt at the source code example like “Idontwanttosharethissalt”

2016-08-09_18-27-27

Cracking start:
2016-08-09_18-30-54

Thank you,
indahnya berbagi 😀

Code:

#!/usr/bin/python

#title : crack md5 double salt
#author: f3ci
#date  : 2016-08-09

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"

The post Simple python code for crack md5 double salt appeared first on 09 Aug 2016.