mirror of https://github.com/AxioDL/metaforce.git
33 lines
844 B
Python
33 lines
844 B
Python
|
'''
|
||
|
De-obfuscation tool for substituting "// Coded by Kawasedo"
|
||
|
lookups with the actual values.
|
||
|
'''
|
||
|
|
||
|
import re
|
||
|
|
||
|
KawasedoLUT = [
|
||
|
0x18, 0xFC, 0xC0, 0x80, 0x7F, 0x40, 0x3F, 0x01, 0x00, 0x2F,
|
||
|
0x2F, 0x20, 0x43, 0x6F, 0x64, 0x65, 0x64, 0x20, 0x62, 0x79,
|
||
|
0x20, 0x4B, 0x61, 0x77, 0x61, 0x73, 0x65, 0x64, 0x6F, 0x00,
|
||
|
0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xAC, 0xC4,
|
||
|
0xF8, 0x08, 0x10, 0xBF, 0x18, 0x00, 0x00, 0x00
|
||
|
]
|
||
|
|
||
|
kawa_reg = re.compile(r'''KawasedoLUT\[(0x[0-9a-fA-F]+)\]''')
|
||
|
string = str()
|
||
|
|
||
|
file = open('main.cpp')
|
||
|
fstring = str(file.read())
|
||
|
file.close()
|
||
|
|
||
|
list = kawa_reg.findall(fstring)
|
||
|
|
||
|
for elem in list:
|
||
|
val = int(elem, 0)
|
||
|
fstring = fstring.replace('KawasedoLUT[0x%x]' % (val), '0x%x' % (KawasedoLUT[val]))
|
||
|
#print(val, KawasedoLUT[val])
|
||
|
|
||
|
file = open('main-deobfuscated.cpp', 'w')
|
||
|
file.write(fstring)
|
||
|
file.close()
|