|
1 | | -"""Generate a coverage file for WTF using Binary Ninja. |
2 | | -
|
3 | | -@australeo - 2023 |
4 | | -""" |
5 | | -from json import dump |
6 | | -from pathlib import Path |
7 | | -from binaryninja import PluginCommand, interaction |
8 | | - |
9 | | -def generate_coverage_file(bv): |
10 | | - # bv.file.filename: 'C:/path/to/binary.bndb' |
11 | | - name = Path(bv.file.filename).stem |
12 | | - |
13 | | - bb_list = [] |
14 | | - |
15 | | - for block in bv.basic_blocks: |
16 | | - bb_list.append(block.start - bv.start) |
17 | | - |
18 | | - json_object = { |
19 | | - "name": name, |
20 | | - "addresses": bb_list |
21 | | - } |
22 | | - |
23 | | - output_file = interaction.get_save_filename_input("Filename: ", ".cov", name + ".cov") |
24 | | - |
25 | | - with open(output_file, "w", encoding="utf-8") as file: |
26 | | - dump(json_object, file) |
27 | | - |
28 | | -def register_plugin(): |
29 | | - PluginCommand.register("Generate WTF coverage file", \ |
30 | | - "Generate WTF coverage file", generate_coverage_file) |
31 | | - |
32 | | -register_plugin() |
| 1 | +"""Generate a coverage file for WTF using Binary Ninja. |
| 2 | +
|
| 3 | +@australeo - 2023 |
| 4 | +""" |
| 5 | +from json import dump |
| 6 | +from pathlib import Path |
| 7 | +from binaryninja import PluginCommand, interaction |
| 8 | + |
| 9 | +def generate_coverage_file(bv): |
| 10 | + # bv.file.filename: 'C:/path/to/binary.bndb' |
| 11 | + name = Path(bv.file.filename).stem |
| 12 | + |
| 13 | + bb_list = [] |
| 14 | + |
| 15 | + for block in bv.basic_blocks: |
| 16 | + bb_list.append(block.start - bv.start) |
| 17 | + |
| 18 | + json_object = { |
| 19 | + "name": name, |
| 20 | + "addresses": bb_list |
| 21 | + } |
| 22 | + |
| 23 | + output_file = interaction.get_save_filename_input("Filename: ", ".cov", name + ".cov") |
| 24 | + |
| 25 | + with open(output_file, "w", encoding="utf-8") as file: |
| 26 | + dump(json_object, file) |
| 27 | + |
| 28 | +def register_plugin(): |
| 29 | + PluginCommand.register("Generate WTF coverage file", \ |
| 30 | + "Generate WTF coverage file", generate_coverage_file) |
| 31 | + |
| 32 | +register_plugin() |
0 commit comments