MD5爆破
截断爆破
from multiprocessing.dummy import Pool as tp
import hashlib
knownMd5 = 'c4d038' # 已知的md5明文
def md5(text):
return hashlib.md5(str(text).encode('utf-8')).hexdigest()
def findCode(code):
key = code.split(':')
end = int(key[1])
start = int(key[0])
for code in range(start, end):
if md5(code)[0:6] == knownMd5:
print(code)
list = []
for i in range(1): # 这里的range(number)指爆破出多少结果停止
list.append(str(10000000 * i) + ':' + str(10000000 * (i + 1)))
pool = tp() # 使用多线程加快爆破速度
pool.map(findCode, list)
pool.close()
pool.join()
残缺爆破
import hashlib
text = 'LitCTF{md5can3derypt213thoughcrsh}'
list1 = 'abcdefghijklmnopqrstuvyxyz0123456789'
for i in list1:
for j in list1:
for k in list1:
for l in list1:
text1 = list(text)
text1.insert(13, i)
text1.insert(14, j)
text1.insert(18, k)
text1.insert(34, l)
text3 = ''.join(text1)
text2 = hashlib.md5(text3.encode()).hexdigest()
if text2 == '496603d6953a15846cd7cc476f146771':
print(text3)
print(i, j, k, l)