forked from SyxP/IL2CPPDumperBinja
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
87 lines (73 loc) · 2.97 KB
/
__init__.py
File metadata and controls
87 lines (73 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from binaryninja import *
from os.path import exists
def get_addr(bv: BinaryView, relative_addr: int):
base_addr = bv.start
return base_addr + relative_addr
class IL2CPPProcessTask(BackgroundTaskThread):
def __init__(self, bv: BinaryView, script_path: str):
BackgroundTaskThread.__init__(self, "IL2CPP Initialise", True)
self.bv = bv
self.script_path = script_path
def process_methods(self, data: dict):
self.progress = "Adding IL2CPP Methods"
methodList = data["ScriptMethod"]
N = len(methodList)
i = 0
for method in methodList:
if self.cancelled:
self.progress = f"IL2CPP cancelled. Aborting..."
return
i += 1
if i % 100 == 0:
percentage = 100*i / N
self.progress = f"IL2CPP Methods: {percentage:.2f}% ({i}/{N})"
addr = get_addr(self.bv, method["Address"])
name = method["Name"].replace("$", "_").replace(".", "_")
sig = method["Signature"]
f = self.bv.get_function_at(addr)
try:
if f != None:
if f.name == name:
continue
else:
f.name = name
# Setting the type directly via
# f.type = sig
# is too slow for analysis.
f.add_tag("Signature", sig)
except Exception:
log_info(f"Unable to add method {name}")
def process_strings(self, data: dict):
self.progress = "Adding IL2CPP Strings"
stringList = data["ScriptString"]
i = 0
for string in stringList:
if self.cancelled:
self.progress = "IL2CPP cancelled. Aborting..."
return
addr = get_addr(self.bv, string["Address"])
value = string["Value"]
var = self.bv.get_data_var_at(addr)
try:
if var != None:
var.name = f"StringLiteral_{i}"
i += 1
self.bv.set_comment_at(addr, value)
except Exception:
log_info(f"Unable to add string at {addr}")
def run(self):
data = json.loads(open(self.script_path, 'rb').read().decode('utf-8'))
self.bv.create_tag_type("Signature", "📜")
if "ScriptMethod" in data:
self.process_methods(data)
if "ScriptString" in data:
self.process_strings(data)
def process(bv: BinaryView):
scriptDialog = OpenFileNameField("Select script.json", "script.json", "script.json")
if not get_form_input([scriptDialog], "script.json"):
return log_error("File not selected.")
if not exists(scriptDialog.result):
return log_error("File not found.")
task = IL2CPPProcessTask(bv, scriptDialog.result)
task.start()
PluginCommand.register("IL2CPPDumper", "Process File", process)