-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_gen_case.py
41 lines (31 loc) · 1.14 KB
/
test_gen_case.py
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
# Author: hluwa <[email protected]>
# HomePage: https://github.com/hluwa
# CreateTime: 2022/3/26
import json
from idaapi import *
from obpo.analysis.dispatcher import DispatchAnalyzer
from obpo.analysis.pathfinder import FlowFinder
from obpoplugin.manager import mark_manager_instance
from obpoplugin.process import generate_microcode, prepare_request, _backup_calls
def inst_info_str(i):
return "{}. {}".format(i.blk.serial, i.topins.dstr())
ea = get_screen_ea()
file_name = get_root_filename()
func_name = get_func_name(ea)
func = get_func(ea)
mba = generate_microcode(func)
_backup_calls(mba)
data = prepare_request(mba, mark_manager_instance().func_marked(ea))
data = json.loads(data)
out_name = "mba-{}-{}{}-{}.json".format(file_name, data["arch"], data["bit"], func_name)
analyzer = DispatchAnalyzer(mba=mba)
for m in mark_manager_instance().func_marked(ea):
analyzer.mark_dispatcher(m)
analyzer.run()
data.update(analyzer.data())
finder = FlowFinder(analyzer)
finder.run()
data.update(finder.data())
out_path = os.path.join(os.path.dirname(__file__), "tests", "testres", out_name)
with open(out_path, 'w') as out:
out.write(json.dumps(data))