Update for compatibility with Python 3.12 and Radare 6.0.2
Tested with the following workflows: vtable diff deep trace -> vtable alignment
This commit is contained in:
@@ -5,7 +5,7 @@ binary.
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
1. Ensure you have python >= 3.7 installed.
|
1. Ensure you have python == 3.12 installed.
|
||||||
|
|
||||||
1. Set up a python venv:
|
1. Set up a python venv:
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
+3
-1
@@ -326,7 +326,9 @@ def load_model(path, device="cpu"):
|
|||||||
|
|
||||||
|
|
||||||
def accuracy(y, probs):
|
def accuracy(y, probs):
|
||||||
return torch.mean(torch.tensor([torch.sum(probs[i][yi]) for i, yi in enumerate(y)]))
|
return torch.mean(
|
||||||
|
torch.tensor([torch.sum(probs[i][yi].detach()) for i, yi in enumerate(y)])
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def cosine_similarities(model):
|
def cosine_similarities(model):
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ class BlockDict(dict):
|
|||||||
).splitlines()
|
).splitlines()
|
||||||
missing_blocks = [json.loads(block_json) for block_json in block_json_list]
|
missing_blocks = [json.loads(block_json) for block_json in block_json_list]
|
||||||
additional_blocks = {
|
additional_blocks = {
|
||||||
missing_block[0]["offset"]: missing_block
|
missing_block[0]["addr"]: missing_block for missing_block in missing_blocks
|
||||||
for missing_block in missing_blocks
|
|
||||||
}
|
}
|
||||||
self.update(additional_blocks)
|
self.update(additional_blocks)
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ def full_similarity_matrix(
|
|||||||
# Now we copy this similarity value for all opcodes in the new
|
# Now we copy this similarity value for all opcodes in the new
|
||||||
# switch case
|
# switch case
|
||||||
for op in new_data["opcodes"]:
|
for op in new_data["opcodes"]:
|
||||||
similarities.append(score)
|
similarities.append(float(score))
|
||||||
# Now we copy this similarity mapping for all opcodes in the old
|
# Now we copy this similarity mapping for all opcodes in the old
|
||||||
# switch case
|
# switch case
|
||||||
for op in old_data["opcodes"]:
|
for op in old_data["opcodes"]:
|
||||||
|
|||||||
+3
-3
@@ -8,7 +8,7 @@ max_size_diff = 10
|
|||||||
|
|
||||||
|
|
||||||
def get_sem_ver(exe_file: str):
|
def get_sem_ver(exe_file: str):
|
||||||
res = re.match(".*ffxiv_dx11\.(\d).(\d)(\d)(\w?)(\d?)\.exe", exe_file)
|
res = re.match(r".*ffxiv_dx11\.(\d).(\d)(\d)(\w?)(\d?)\.exe", exe_file)
|
||||||
sem_ver = f"{res.group(1)}.{res.group(2)}.{res.group(3)}"
|
sem_ver = f"{res.group(1)}.{res.group(2)}.{res.group(3)}"
|
||||||
if res.group(4) != "":
|
if res.group(4) != "":
|
||||||
sem_ver = f"{sem_ver}+{res.group(4)}"
|
sem_ver = f"{sem_ver}+{res.group(4)}"
|
||||||
@@ -106,13 +106,13 @@ def get_opcode_offset(r2):
|
|||||||
def get_correct_switch(approx_ea, switch_cases):
|
def get_correct_switch(approx_ea, switch_cases):
|
||||||
switches = dict()
|
switches = dict()
|
||||||
|
|
||||||
pattern = re.compile("case\.(0x[0-9a-fA-F]+)\.(\d+)")
|
pattern = re.compile(r"case\.(0x[0-9a-fA-F]+)\.(\d+)")
|
||||||
|
|
||||||
for l in switch_cases:
|
for l in switch_cases:
|
||||||
match = pattern.match(l["name"])
|
match = pattern.match(l["name"])
|
||||||
if match is not None:
|
if match is not None:
|
||||||
switch_ea = match[1]
|
switch_ea = match[1]
|
||||||
case_ea = l["offset"]
|
case_ea = l["addr"]
|
||||||
|
|
||||||
if switch_ea not in switches:
|
if switch_ea not in switches:
|
||||||
switches[switch_ea] = dict()
|
switches[switch_ea] = dict()
|
||||||
|
|||||||
+13
-16
@@ -1,17 +1,14 @@
|
|||||||
black==22.12.0
|
black==25.1.0
|
||||||
click==8.1.3
|
click==8.2.1
|
||||||
colorama==0.4.6
|
colorama==0.4.6
|
||||||
Levenshtein==0.20.9
|
mypy-extensions==1.1.0
|
||||||
mypy-extensions==0.4.3
|
numpy==2.3.2
|
||||||
numpy==1.24.1
|
pathspec==0.12.1
|
||||||
pathspec==0.10.3
|
platformdirs==4.4.0
|
||||||
platformdirs==2.6.2
|
r2pipe==1.9.6
|
||||||
python-Levenshtein==0.20.9
|
rapidfuzz==3.14.0
|
||||||
r2pipe==1.7.4
|
semver==3.0.4
|
||||||
rapidfuzz==2.13.7
|
-f https://download.pytorch.org/whl/cu129
|
||||||
semver==3.0.1
|
torch==2.8.0
|
||||||
tomli==2.0.1
|
tqdm==4.67.1
|
||||||
-f https://download.pytorch.org/whl/torch_stable.html
|
typing_extensions==4.15.0
|
||||||
torch==1.13.1+cu117
|
|
||||||
tqdm==4.64.1
|
|
||||||
typing_extensions==4.4.0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user