-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path__init__.py
63 lines (46 loc) · 1.79 KB
/
__init__.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from .op_detective import (bb_llil_analysis, bb_mlil_analysis, bb_analysis,
get_authentic_bbs, get_non_generic_spec)
from .op_helpers import *
from binaryninja import *
from collections import namedtuple, defaultdict
AnalysisMetadata = namedtuple("AnalysisMetadata", "spec good_bbs")
LOGGING = True # set to False if don't want logging
def find_op_setup(bv, status=None):
"""
Perform necessary setup before core analysis
"""
# --- LOGGING ---
if LOGGING:
# debug is the lowest level == LOG EVERYTHING
log_to_stdout(LogLevel.DebugLog)
# --- LOGGING ---
# maybe binja will find more functions
# same as following in GUI:
# Tools -> Run Analysis Module -> Linear Sweep
bv.update_analysis_and_wait()
metadata = AnalysisMetadata(spec=get_non_generic_spec(),
good_bbs=get_authentic_bbs(bv))
analysis = [
bb_analysis,
bb_llil_analysis,
bb_mlil_analysis,
]
(total_patch_locations, total_conds) = find_op(bv, analyses=analysis,
metadata=metadata, status=status)
# determine OP authenticity
identify_authentic_op(total_patch_locations, total_conds,
metadata, bv, patch=True)
class FindOpaqueInBackground(BackgroundTaskThread):
def __init__(self, bv, msg):
BackgroundTaskThread.__init__(self, msg, True)
self.bv = bv
def run(self):
find_op_setup(self.bv, self)
def find_opaque_in_background(bv):
"""
Start `FindOpaqueInBackground`
"""
background_task = FindOpaqueInBackground(bv, "Finding opaque predicates")
background_task.start()
PluginCommand.register("Opaque Predicate Detective",
"find opaque predicate", find_opaque_in_background)