mirror of
https://github.com/MapMakersAndProgrammers/TankiOnline2.0DemoClient.git
synced 2025-10-26 01:49:11 -07:00
Use the horrendous tools used to deobfuscate
This commit is contained in:
8
utils/asm.py
Normal file
8
utils/asm.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import subprocess
|
||||||
|
from glob import glob
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
path = argv[1]
|
||||||
|
paths = glob(f"{path}/*/*.main.asasm")
|
||||||
|
for path in paths:
|
||||||
|
subprocess.run(["rabcasm", path])
|
||||||
8
utils/dasm.py
Normal file
8
utils/dasm.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import subprocess
|
||||||
|
from glob import glob
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
path = argv[1]
|
||||||
|
paths = glob(f"{path}/*.abc")
|
||||||
|
for path in paths:
|
||||||
|
subprocess.run(["rabcdasm", path])
|
||||||
94
utils/deob.py
Normal file
94
utils/deob.py
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
from json import load
|
||||||
|
from sys import argv
|
||||||
|
from glob import glob
|
||||||
|
import re
|
||||||
|
from multiprocessing import Pool
|
||||||
|
|
||||||
|
mappingPath = argv[1]
|
||||||
|
detailMappingPath = argv[2]
|
||||||
|
abcPath = argv[3]
|
||||||
|
|
||||||
|
mapping = {}
|
||||||
|
with open(mappingPath, "r") as file:
|
||||||
|
mapping = load(file)
|
||||||
|
|
||||||
|
detailMapping = {}
|
||||||
|
with open(detailMappingPath, "r") as file:
|
||||||
|
detailMapping = load(file)
|
||||||
|
|
||||||
|
paths = glob(f"{abcPath}/**/**/*.asasm")
|
||||||
|
|
||||||
|
def deobfuscateFile(path):
|
||||||
|
print(path)
|
||||||
|
with open(path, "r+") as reader:
|
||||||
|
className = path.split("/")[-1]
|
||||||
|
className = className.split(".")[0]
|
||||||
|
packageName = path.split("/")[-2]
|
||||||
|
|
||||||
|
content_lines = reader.readlines()
|
||||||
|
|
||||||
|
new_lines = []
|
||||||
|
|
||||||
|
for index, line in enumerate(content_lines):
|
||||||
|
if (
|
||||||
|
not line.strip().startswith("#include")
|
||||||
|
and not line.strip().startswith("pushstring")
|
||||||
|
and index != 0
|
||||||
|
):
|
||||||
|
for entry in mapping:
|
||||||
|
fakePackageName = entry.split(":")[0]
|
||||||
|
fakeClassName = entry.split(":")[1]
|
||||||
|
if fakePackageName in line:
|
||||||
|
realName = mapping[f"{fakePackageName}:{fakeClassName}"].split(":")[0]
|
||||||
|
line = re.sub(
|
||||||
|
rf"(^|[\"\/:]){fakePackageName}([\"\/:]|$)", rf"\1{realName}\2", line
|
||||||
|
)
|
||||||
|
if fakeClassName in line:
|
||||||
|
realName = mapping[f"{fakePackageName}:{fakeClassName}"].split(":")[1]
|
||||||
|
line = re.sub(
|
||||||
|
rf"(^|[\"\/:]){fakeClassName}([\"\/:]|$)", rf"\1{realName}\2", line
|
||||||
|
)
|
||||||
|
#classs = detailMapping[packageName][className]
|
||||||
|
for package in detailMapping:
|
||||||
|
for classs in detailMapping[package]:
|
||||||
|
classs = detailMapping[package][classs]
|
||||||
|
for member in classs:
|
||||||
|
realMember = classs[member]
|
||||||
|
if realMember == None: continue
|
||||||
|
|
||||||
|
memberChain = member.split("/")
|
||||||
|
memberName = memberChain[-1]
|
||||||
|
if memberName == "setter" or memberName == "getter":
|
||||||
|
memberName = memberChain[-2]
|
||||||
|
elif memberName == "init" or memberName == "final" or memberName.rstrip() == "each" or memberName == "package":
|
||||||
|
continue
|
||||||
|
if ":" in memberName:
|
||||||
|
memberName = memberName.split(":")[-1]
|
||||||
|
|
||||||
|
realMemberChain = realMember.split("/")
|
||||||
|
realMemberName = realMemberChain[-1]
|
||||||
|
if realMemberName == "set" or realMemberName == "get":
|
||||||
|
realMemberName = realMemberChain[-2]
|
||||||
|
if ":" in realMemberName:
|
||||||
|
realMemberName = realMemberName.split(":")[-1]
|
||||||
|
if realMemberName == memberName:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if memberName in line:
|
||||||
|
line = re.sub(
|
||||||
|
rf"(^|[\"\/:]){memberName}([\"\/:]|$)", rf"\1{realMemberName}\2", line
|
||||||
|
)
|
||||||
|
|
||||||
|
new_lines.append(line)
|
||||||
|
|
||||||
|
# Reset the file to the beginning and truncate the content
|
||||||
|
reader.seek(0)
|
||||||
|
reader.truncate()
|
||||||
|
|
||||||
|
# Then write the new contents to the file
|
||||||
|
reader.writelines(new_lines)
|
||||||
|
|
||||||
|
# for path in paths:
|
||||||
|
# deobfuscateFile(path)
|
||||||
|
pool = Pool(12)
|
||||||
|
pool.map(deobfuscateFile, paths)
|
||||||
36
utils/generatemapping.py
Normal file
36
utils/generatemapping.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from sys import argv
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
from json import dump
|
||||||
|
|
||||||
|
path = argv[1]
|
||||||
|
paths = glob(f"{path}/**/**/*.class.asasm")
|
||||||
|
paths += glob(f"{path}/**/*.class.asasm")
|
||||||
|
|
||||||
|
names = {}
|
||||||
|
for path in paths:
|
||||||
|
name = None
|
||||||
|
with open(path, "r") as file:
|
||||||
|
className = path.split("/")[-1]
|
||||||
|
className = className.split(".class.asasm")[0]
|
||||||
|
packageName = path.split("/")[-2]
|
||||||
|
|
||||||
|
if not packageName in names:
|
||||||
|
names[packageName] = {}
|
||||||
|
if not className in names[packageName]:
|
||||||
|
names[packageName][className] = {}
|
||||||
|
|
||||||
|
for line in file:
|
||||||
|
line = line.strip()
|
||||||
|
if line.startswith("name"):
|
||||||
|
line = line.split("name \"")
|
||||||
|
line = line[1][:-1]
|
||||||
|
name = line
|
||||||
|
elif line.startswith("refid"):
|
||||||
|
line = line.split("refid \"")
|
||||||
|
line = line[1][:-1]
|
||||||
|
|
||||||
|
names[packageName][className][line] = name
|
||||||
|
|
||||||
|
with open("mapping.json", "w") as file:
|
||||||
|
dump(names, file)
|
||||||
22
utils/generatepmapping.py
Normal file
22
utils/generatepmapping.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from json import load, dump
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
mappingPath = argv[1]
|
||||||
|
mapping = {}
|
||||||
|
with open(mappingPath, "r") as file:
|
||||||
|
mapping = load(file)
|
||||||
|
|
||||||
|
classMap = {}
|
||||||
|
for packageName in mapping:
|
||||||
|
package = mapping[packageName]
|
||||||
|
for className in package:
|
||||||
|
clas = package[className]
|
||||||
|
func = list(clas.values())
|
||||||
|
if len(func) != 0:
|
||||||
|
func = func[1]
|
||||||
|
realName = func.split("/")[0]
|
||||||
|
fakeName = f"{packageName}:{className}"
|
||||||
|
classMap[fakeName] = realName
|
||||||
|
|
||||||
|
with open("packagemap.json", "w") as file:
|
||||||
|
dump(classMap, file)
|
||||||
16
utils/replace.py
Normal file
16
utils/replace.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from sys import argv
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isdir
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
abcPath = argv[1]
|
||||||
|
swfPath = argv[2]
|
||||||
|
|
||||||
|
for path in listdir(abcPath):
|
||||||
|
folder = path.split("/")[-1]
|
||||||
|
path = f"{abcPath}/{path}"
|
||||||
|
if not isdir(path): continue
|
||||||
|
abcIndex = folder.split("-")[-1]
|
||||||
|
abcFile = f"{path}/{folder}.main.abc"
|
||||||
|
print(f"{path} {abcIndex} {abcFile}")
|
||||||
|
subprocess.run(["abcreplace", swfPath, abcIndex, abcFile])
|
||||||
Reference in New Issue
Block a user