MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / find_dynamically_linked_funcs

Function find_dynamically_linked_funcs

python/examples/triage/imports.py:124–159  ·  view source on GitHub ↗
(bv)

Source from the content-addressed store, hash-verified

122 return
123
124def find_dynamically_linked_funcs(bv):
125 platform_info = get_platform_info(bv)
126
127 funcs_to_check = set()
128 for lookup in platform_info["sym_lookups"]:
129 for ref in bv.get_code_refs(lookup):
130 ref.function.analysis_skip_override = FunctionAnalysisSkipOverride.NeverSkipFunctionAnalysis
131 funcs_to_check.add(ref.function)
132
133 bv.update_analysis()
134 time.sleep(1)
135
136 for f in funcs_to_check:
137 mlil_ssa = f.medium_level_il.ssa_form
138
139 for call in find_mlil_calls_to_targets(mlil_ssa, platform_info["sym_lookups"]):
140 if len(call.params) < 2 or len(call.output) < 1:
141 continue
142
143 symbol_name_addr = call.params[1].value
144 if symbol_name_addr.type not in [RegisterValueType.ConstantPointerValue, RegisterValueType.ConstantValue]:
145 continue
146
147 output_var = call.output[0]
148 symbol_name = bv.get_ascii_string_at(symbol_name_addr.value).value
149 # Add confidence to both the args and the return of zero
150 symbol_type = Type.pointer(bv.arch, bv.parse_type_string("void foo()")[0])
151
152 if len(symbol_name) == 0:
153 continue
154
155 bv.define_user_data_var(symbol_name_addr.value, Type.array(Type.int(1), len(symbol_name)))
156
157 output_name = symbol_name + "@DYN"
158 f.create_user_var(output_var.var, symbol_type, output_name)
159 propagate_var_name(f, mlil_ssa, output_var, output_name, symbol_type)
160
161
162class GenericImportsModel(QAbstractItemModel):

Callers 1

scanDynamicMethod · 0.85

Calls 13

get_platform_infoFunction · 0.85
propagate_var_nameFunction · 0.85
get_code_refsMethod · 0.80
get_ascii_string_atMethod · 0.80
addMethod · 0.45
update_analysisMethod · 0.45
pointerMethod · 0.45
parse_type_stringMethod · 0.45
define_user_data_varMethod · 0.45
arrayMethod · 0.45
intMethod · 0.45

Tested by

no test coverage detected