Crack the Code

We have crackthecode.py script and goal is get the code that is the key to decrypt message.

Easy solution is brute force the key :))

Code:

import hashlib
import sys

def validatecode(code):	
	sha1 = hashlib.sha1()
	sha1.update(code)
	
	sha224 = hashlib.sha224()
	sha224.update(code)
	
	sha256 = hashlib.sha256()
	sha256.update(code)
	
	sha384 = hashlib.sha384()
	sha384.update(code)
	
	if sha1.hexdigest()[0:2] == 'a6' and sha224.hexdigest()[0:2] == '7b' and sha256.hexdigest()[0:2] == '57' and sha384.hexdigest()[0:2] == 'db':
		return True
	else:
		return False
		
arr  = '0123456789'
code = ''
for i1 in arr:
	for i2 in arr:
		for i3 in arr:
			for i4 in arr:
				for i5 in arr:
					for i6 in arr:
						for i7 in arr:
							code = i1 + i2 + i3 + i4 + i5 + i6 + i7
							if validatecode(code) == True:
								print 'code: ' + code
								sys.exit()

After about 5s, script return the code is: 3495745

Then, run crackthecode.py with this code:

# python crackthecode.py -p 3495745

result:

Capture

Key: 44859c3554ee157264297d62d8aeef64685c57549051836001e14b8821ab6a0f

Advertisements