#--coding:utf-8---
# Author: subk
# Time : 2018/12/12 22:06
# Desc :
"""
1. 都用的小写字母
2. & 0xffffffff是为了得到正数
如 binascii.crc32(‘haha’)
"""
import itertools
import binascii
alph = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/='
def crc32_dec_2(crc32):
x = itertools.product(alph, repeat=2) #repeat 确定生成的组合里有几个字符
for i in x:
zuhe=''.join(i)
if str(hex(binascii.crc32(zuhe) & 0xffffffff)[2:10]) == crc32.lower():
return zuhe
def crc32_dec_3(crc32):
x = itertools.product(alph, repeat=3) #repeat 确定生成的组合里有几个字符
for i in x:
zuhe=''.join(i)
if str(hex(binascii.crc32(zuhe) & 0xffffffff)[2:10]) == crc32.lower():
return zuhe
def crc32_dec_5(crc32): #需要的时间可能比较长
x = itertools.product(alph, repeat=5) #repeat 确定生成的组合里有几个字符
for i in x:
zuhe=''.join(i)
if str(hex(binascii.crc32(zuhe) & 0xffffffff)[2:10]) == crc32.lower():
return zuhe
print crc32_dec_5('c46bbddc') #需要爆破的crc32值