You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
211 lines
3.3 KiB
211 lines
3.3 KiB
#!/usr/bin/python3
|
|
|
|
charmap = {
|
|
' ': 0x00,
|
|
'0': 0xA1,
|
|
'1': 0xA2,
|
|
'2': 0xA3,
|
|
'3': 0xA4,
|
|
'4': 0xA5,
|
|
'5': 0xA6,
|
|
'6': 0xA7,
|
|
'7': 0xA8,
|
|
'8': 0xA9,
|
|
'9': 0xAA,
|
|
'!': 0xAB,
|
|
'?': 0xAC,
|
|
'.': 0xAD,
|
|
'-': 0xAE,
|
|
'…': 0xB0,
|
|
'“': 0xB1,
|
|
'”': 0xB2,
|
|
'‘': 0xB3,
|
|
'’': 0xB4,
|
|
'♂': 0xB5,
|
|
'♀': 0xB6,
|
|
',': 0xB8,
|
|
'/': 0xBA,
|
|
'A': 0xBB,
|
|
'B': 0xBC,
|
|
'C': 0xBD,
|
|
'D': 0xBE,
|
|
'E': 0xBF,
|
|
'F': 0xC0,
|
|
'G': 0xC1,
|
|
'H': 0xC2,
|
|
'I': 0xC3,
|
|
'J': 0xC4,
|
|
'K': 0xC5,
|
|
'L': 0xC6,
|
|
'M': 0xC7,
|
|
'N': 0xC8,
|
|
'O': 0xC9,
|
|
'P': 0xCA,
|
|
'Q': 0xCB,
|
|
'R': 0xCC,
|
|
'S': 0xCD,
|
|
'T': 0xCE,
|
|
'U': 0xCF,
|
|
'V': 0xD0,
|
|
'W': 0xD1,
|
|
'X': 0xD2,
|
|
'Y': 0xD3,
|
|
'Z': 0xD4,
|
|
'a': 0xD5,
|
|
'b': 0xD6,
|
|
'c': 0xD7,
|
|
'd': 0xD8,
|
|
'e': 0xD9,
|
|
'f': 0xDA,
|
|
'g': 0xDB,
|
|
'h': 0xDC,
|
|
'i': 0xDD,
|
|
'j': 0xDE,
|
|
'k': 0xDF,
|
|
'l': 0xE0,
|
|
'm': 0xE1,
|
|
'n': 0xE2,
|
|
'o': 0xE3,
|
|
'p': 0xE4,
|
|
'q': 0xE5,
|
|
'r': 0xE6,
|
|
's': 0xE7,
|
|
't': 0xE8,
|
|
'u': 0xE9,
|
|
'v': 0xEA,
|
|
'w': 0xEB,
|
|
'x': 0xEC,
|
|
'y': 0xED,
|
|
'z': 0xEE,
|
|
'$': 0xFF,
|
|
}
|
|
chars = [
|
|
' ',
|
|
'0',
|
|
'1',
|
|
'2',
|
|
'3',
|
|
'4',
|
|
'5',
|
|
'6',
|
|
'7',
|
|
'8',
|
|
'9',
|
|
'!',
|
|
'?',
|
|
'.',
|
|
'-',
|
|
'…',
|
|
'“',
|
|
'”',
|
|
'‘',
|
|
'’',
|
|
'♂',
|
|
'♀',
|
|
',',
|
|
'/',
|
|
'A',
|
|
'B',
|
|
'C',
|
|
'D',
|
|
'E',
|
|
'F',
|
|
'G',
|
|
'H',
|
|
'I',
|
|
'J',
|
|
'K',
|
|
'L',
|
|
'M',
|
|
'N',
|
|
'O',
|
|
'P',
|
|
'Q',
|
|
'R',
|
|
'S',
|
|
'T',
|
|
'U',
|
|
'V',
|
|
'W',
|
|
'X',
|
|
'Y',
|
|
'Z',
|
|
'a',
|
|
'b',
|
|
'c',
|
|
'd',
|
|
'e',
|
|
'f',
|
|
'g',
|
|
'h',
|
|
'i',
|
|
'j',
|
|
'k',
|
|
'l',
|
|
'm',
|
|
'n',
|
|
'o',
|
|
'p',
|
|
'q',
|
|
'r',
|
|
's',
|
|
't',
|
|
'u',
|
|
'v',
|
|
'w',
|
|
'x',
|
|
'y',
|
|
'z',
|
|
'$',
|
|
]
|
|
|
|
round1 = ([73, 97, 13, 41, 67, 101, 89, 139, 71, 83], [6969, 6367, 5099, 4591, 4421, 4831, 3581, 5039, 5279, 4079, 4021])
|
|
round2 = ([59, 181, 127, 163, 103, 163, 149, 193, 211, 151], [1337, 3701, 4603, 4663, 4703, 4219, 6481, 6983, 5407, 5297, 5099])
|
|
def one_round(string, coeffs, addends):
|
|
assert(len(coeffs) == 10)
|
|
assert(len(string) == 10)
|
|
|
|
var32769 = addends[0]
|
|
for c,n,x in zip(string,coeffs,addends[1:]):
|
|
var32769 = (var32769 + charmap[c]) % 65536
|
|
var32769 = (var32769 * n) % 65536
|
|
var32769 = (var32769 + x) % 65536
|
|
return var32769
|
|
|
|
def get_hash_for(string):
|
|
var32771 = one_round(string, *round1)
|
|
var32769 = one_round(string, *round2)
|
|
return hex(var32771),hex(var32769)
|
|
|
|
all = len(chars) ** 10
|
|
for x in range(all):
|
|
s = ""
|
|
while x:
|
|
s += chars[x % len(chars)]
|
|
x //= len(chars)
|
|
while len(s) < 10:
|
|
s += "$"
|
|
|
|
hash = get_hash_for(s)
|
|
if hash == (0xB0EF, 0xD4B9):
|
|
print(s)
|
|
|
|
final = 0x828E - round1[1][-1]
|
|
for x in range(10):
|
|
for i, c in reversed(charmap.items()):
|
|
if c == 0:
|
|
continue
|
|
if c % round1[0][-x] == 0:
|
|
c //= round1[0][-x]
|
|
print(c)
|
|
break
|
|
else:
|
|
print("nope")
|
|
exit()
|
|
c -= round1[1][-1 - x]
|
|
|
|
# 0123456789 =
|
|
print(get_hash_for("0123456789"))
|
|
print(get_hash_for("$$$$$$$$$$"))
|
|
print(get_hash_for("ABABABABAB"))
|
|
print(get_hash_for("6969696969"))
|
|
|