angr 9.2.102__py3-none-manylinux2014_x86_64.whl → 9.2.103__py3-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of angr might be problematic. Click here for more details.
- angr/__init__.py +1 -1
- angr/analyses/analysis.py +7 -6
- angr/analyses/calling_convention.py +33 -35
- angr/analyses/cdg.py +2 -4
- angr/analyses/cfg/cfb.py +4 -3
- angr/analyses/cfg/cfg_base.py +14 -14
- angr/analyses/cfg/cfg_emulated.py +3 -4
- angr/analyses/cfg/cfg_fast.py +46 -46
- angr/analyses/cfg/cfg_fast_soot.py +1 -2
- angr/analyses/cfg/cfg_job_base.py +2 -2
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +14 -13
- angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +5 -5
- angr/analyses/cfg_slice_to_sink/cfg_slice_to_sink.py +3 -3
- angr/analyses/complete_calling_conventions.py +13 -12
- angr/analyses/data_dep/data_dependency_analysis.py +24 -24
- angr/analyses/data_dep/dep_nodes.py +3 -3
- angr/analyses/ddg.py +1 -2
- angr/analyses/decompiler/ail_simplifier.py +35 -34
- angr/analyses/decompiler/block_io_finder.py +20 -20
- angr/analyses/decompiler/block_similarity.py +4 -6
- angr/analyses/decompiler/block_simplifier.py +17 -16
- angr/analyses/decompiler/callsite_maker.py +25 -10
- angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +1 -3
- angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +2 -4
- angr/analyses/decompiler/clinic.py +250 -45
- angr/analyses/decompiler/condition_processor.py +15 -8
- angr/analyses/decompiler/decompilation_cache.py +7 -7
- angr/analyses/decompiler/decompilation_options.py +4 -4
- angr/analyses/decompiler/decompiler.py +19 -15
- angr/analyses/decompiler/expression_counters.py +10 -9
- angr/analyses/decompiler/goto_manager.py +2 -4
- angr/analyses/decompiler/graph_region.py +9 -9
- angr/analyses/decompiler/jump_target_collector.py +1 -2
- angr/analyses/decompiler/optimization_passes/__init__.py +4 -3
- angr/analyses/decompiler/optimization_passes/code_motion.py +5 -6
- angr/analyses/decompiler/optimization_passes/const_derefs.py +4 -4
- angr/analyses/decompiler/optimization_passes/deadblock_remover.py +73 -0
- angr/analyses/decompiler/optimization_passes/engine_base.py +25 -3
- angr/analyses/decompiler/optimization_passes/expr_op_swapper.py +6 -5
- angr/analyses/decompiler/optimization_passes/flip_boolean_cmp.py +2 -2
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +3 -0
- angr/analyses/decompiler/optimization_passes/ite_expr_converter.py +2 -2
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +17 -17
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +12 -13
- angr/analyses/decompiler/optimization_passes/register_save_area_simplifier.py +25 -21
- angr/analyses/decompiler/optimization_passes/ret_addr_save_simplifier.py +3 -3
- angr/analyses/decompiler/optimization_passes/ret_deduplicator.py +1 -2
- angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +7 -7
- angr/analyses/decompiler/optimization_passes/spilled_register_finder.py +18 -0
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +2 -3
- angr/analyses/decompiler/optimization_passes/win_stack_canary_simplifier.py +1 -2
- angr/analyses/decompiler/optimization_passes/x86_gcc_getpc_simplifier.py +2 -2
- angr/analyses/decompiler/peephole_optimizations/__init__.py +4 -3
- angr/analyses/decompiler/peephole_optimizations/base.py +13 -15
- angr/analyses/decompiler/peephole_optimizations/bswap.py +1 -3
- angr/analyses/decompiler/peephole_optimizations/cmpord_rewriter.py +72 -0
- angr/analyses/decompiler/peephole_optimizations/const_mull_a_shift.py +1 -2
- angr/analyses/decompiler/peephole_optimizations/eager_eval.py +1 -1
- angr/analyses/decompiler/peephole_optimizations/inlined_strcpy.py +5 -10
- angr/analyses/decompiler/peephole_optimizations/inlined_strcpy_consolidation.py +3 -4
- angr/analyses/decompiler/peephole_optimizations/inlined_wstrcpy.py +7 -10
- angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +2 -3
- angr/analyses/decompiler/peephole_optimizations/sar_to_signed_div.py +1 -2
- angr/analyses/decompiler/peephole_optimizations/tidy_stack_addr.py +4 -4
- angr/analyses/decompiler/redundant_label_remover.py +4 -5
- angr/analyses/decompiler/region_identifier.py +4 -5
- angr/analyses/decompiler/region_simplifiers/cascading_cond_transformer.py +1 -2
- angr/analyses/decompiler/region_simplifiers/expr_folding.py +19 -20
- angr/analyses/decompiler/region_simplifiers/goto.py +2 -3
- angr/analyses/decompiler/region_simplifiers/loop.py +1 -2
- angr/analyses/decompiler/region_simplifiers/node_address_finder.py +1 -2
- angr/analyses/decompiler/region_simplifiers/region_simplifier.py +1 -3
- angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +19 -19
- angr/analyses/decompiler/return_maker.py +1 -2
- angr/analyses/decompiler/structured_codegen/base.py +5 -6
- angr/analyses/decompiler/structured_codegen/c.py +39 -38
- angr/analyses/decompiler/structuring/__init__.py +1 -1
- angr/analyses/decompiler/structuring/dream.py +17 -16
- angr/analyses/decompiler/structuring/phoenix.py +45 -46
- angr/analyses/decompiler/structuring/recursive_structurer.py +4 -4
- angr/analyses/decompiler/structuring/structurer_base.py +16 -15
- angr/analyses/decompiler/structuring/structurer_nodes.py +10 -9
- angr/analyses/decompiler/utils.py +17 -16
- angr/analyses/disassembly.py +7 -6
- angr/analyses/flirt.py +9 -9
- angr/analyses/forward_analysis/forward_analysis.py +15 -14
- angr/analyses/forward_analysis/visitors/function_graph.py +1 -2
- angr/analyses/forward_analysis/visitors/graph.py +16 -15
- angr/analyses/propagator/engine_ail.py +30 -26
- angr/analyses/propagator/outdated_definition_walker.py +8 -7
- angr/analyses/propagator/propagator.py +11 -13
- angr/analyses/proximity_graph.py +21 -21
- angr/analyses/reaching_definitions/__init__.py +3 -3
- angr/analyses/reaching_definitions/call_trace.py +3 -6
- angr/analyses/reaching_definitions/dep_graph.py +41 -48
- angr/analyses/reaching_definitions/engine_ail.py +11 -5
- angr/analyses/reaching_definitions/engine_vex.py +9 -8
- angr/analyses/reaching_definitions/function_handler.py +51 -34
- angr/analyses/reaching_definitions/heap_allocator.py +3 -4
- angr/analyses/reaching_definitions/rd_initializer.py +8 -8
- angr/analyses/reaching_definitions/rd_state.py +57 -58
- angr/analyses/reaching_definitions/reaching_definitions.py +18 -17
- angr/analyses/reaching_definitions/subject.py +2 -3
- angr/analyses/stack_pointer_tracker.py +15 -6
- angr/analyses/typehoon/dfa.py +4 -4
- angr/analyses/typehoon/simple_solver.py +48 -52
- angr/analyses/typehoon/translator.py +3 -6
- angr/analyses/typehoon/typeconsts.py +13 -14
- angr/analyses/typehoon/typehoon.py +9 -9
- angr/analyses/typehoon/typevars.py +18 -17
- angr/analyses/variable_recovery/engine_ail.py +5 -5
- angr/analyses/variable_recovery/engine_base.py +25 -21
- angr/analyses/variable_recovery/irsb_scanner.py +8 -9
- angr/analyses/variable_recovery/variable_recovery.py +1 -2
- angr/analyses/variable_recovery/variable_recovery_base.py +14 -13
- angr/analyses/variable_recovery/variable_recovery_fast.py +8 -8
- angr/analyses/veritesting.py +1 -2
- angr/analyses/vfg.py +57 -56
- angr/analyses/xrefs.py +1 -2
- angr/angrdb/db.py +7 -7
- angr/angrdb/serializers/kb.py +16 -13
- angr/angrdb/serializers/loader.py +1 -2
- angr/angrdb/serializers/structured_code.py +2 -2
- angr/annocfg.py +1 -2
- angr/block.py +16 -6
- angr/calling_conventions.py +27 -27
- angr/code_location.py +8 -8
- angr/codenode.py +1 -2
- angr/concretization_strategies/max.py +1 -3
- angr/distributed/server.py +1 -3
- angr/distributed/worker.py +1 -2
- angr/engines/engine.py +2 -3
- angr/engines/light/engine.py +4 -4
- angr/engines/pcode/behavior.py +20 -2
- angr/engines/pcode/emulate.py +1 -1
- angr/engines/pcode/engine.py +7 -7
- angr/engines/pcode/lifter.py +78 -77
- angr/engines/vex/claripy/ccall.py +1 -2
- angr/engines/vex/claripy/datalayer.py +1 -2
- angr/engines/vex/light/light.py +1 -2
- angr/exploration_techniques/tracer.py +4 -4
- angr/factory.py +12 -15
- angr/flirt/__init__.py +8 -8
- angr/flirt/build_sig.py +2 -3
- angr/keyed_region.py +2 -2
- angr/knowledge_base/knowledge_base.py +3 -3
- angr/knowledge_plugins/callsite_prototypes.py +4 -6
- angr/knowledge_plugins/cfg/cfg_manager.py +19 -6
- angr/knowledge_plugins/cfg/cfg_model.py +26 -27
- angr/knowledge_plugins/cfg/cfg_node.py +2 -2
- angr/knowledge_plugins/cfg/indirect_jump.py +6 -8
- angr/knowledge_plugins/cfg/memory_data.py +8 -9
- angr/knowledge_plugins/custom_strings.py +1 -3
- angr/knowledge_plugins/debug_variables.py +2 -2
- angr/knowledge_plugins/functions/function.py +21 -22
- angr/knowledge_plugins/functions/function_manager.py +5 -5
- angr/knowledge_plugins/indirect_jumps.py +1 -3
- angr/knowledge_plugins/key_definitions/atoms.py +7 -7
- angr/knowledge_plugins/key_definitions/definition.py +14 -14
- angr/knowledge_plugins/key_definitions/environment.py +5 -7
- angr/knowledge_plugins/key_definitions/heap_address.py +1 -3
- angr/knowledge_plugins/key_definitions/key_definition_manager.py +3 -2
- angr/knowledge_plugins/key_definitions/live_definitions.py +60 -59
- angr/knowledge_plugins/key_definitions/liveness.py +16 -16
- angr/knowledge_plugins/key_definitions/rd_model.py +15 -15
- angr/knowledge_plugins/key_definitions/uses.py +11 -11
- angr/knowledge_plugins/patches.py +4 -8
- angr/knowledge_plugins/propagations/prop_value.py +10 -9
- angr/knowledge_plugins/propagations/propagation_manager.py +3 -5
- angr/knowledge_plugins/propagations/propagation_model.py +9 -9
- angr/knowledge_plugins/propagations/states.py +52 -22
- angr/knowledge_plugins/structured_code/manager.py +2 -2
- angr/knowledge_plugins/sync/sync_controller.py +3 -3
- angr/knowledge_plugins/variables/variable_access.py +4 -4
- angr/knowledge_plugins/variables/variable_manager.py +39 -39
- angr/knowledge_plugins/xrefs/xref.py +9 -11
- angr/knowledge_plugins/xrefs/xref_manager.py +3 -4
- angr/misc/ansi.py +1 -2
- angr/misc/autoimport.py +3 -3
- angr/misc/plugins.py +9 -9
- angr/procedures/definitions/__init__.py +16 -16
- angr/procedures/definitions/linux_kernel.py +1 -1
- angr/procedures/definitions/parse_win32json.py +1 -1
- angr/procedures/java_jni/__init__.py +1 -1
- angr/procedures/java_jni/array_operations.py +1 -2
- angr/procedures/java_jni/method_calls.py +1 -2
- angr/procedures/posix/inet_ntoa.py +1 -2
- angr/procedures/stubs/format_parser.py +3 -3
- angr/project.py +13 -11
- angr/sim_manager.py +12 -12
- angr/sim_procedure.py +7 -3
- angr/sim_state.py +2 -2
- angr/sim_type.py +60 -45
- angr/sim_variable.py +5 -5
- angr/simos/simos.py +1 -2
- angr/simos/userland.py +1 -2
- angr/state_plugins/callstack.py +3 -2
- angr/state_plugins/history.py +1 -2
- angr/state_plugins/solver.py +34 -34
- angr/storage/memory_mixins/__init__.py +4 -3
- angr/storage/memory_mixins/actions_mixin.py +1 -3
- angr/storage/memory_mixins/address_concretization_mixin.py +1 -3
- angr/storage/memory_mixins/convenient_mappings_mixin.py +3 -4
- angr/storage/memory_mixins/default_filler_mixin.py +1 -1
- angr/storage/memory_mixins/label_merger_mixin.py +2 -2
- angr/storage/memory_mixins/multi_value_merger_mixin.py +4 -3
- angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +9 -8
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +12 -11
- angr/storage/memory_mixins/paged_memory/pages/cooperation.py +8 -8
- angr/storage/memory_mixins/paged_memory/pages/history_tracking_mixin.py +2 -3
- angr/storage/memory_mixins/paged_memory/pages/list_page.py +10 -11
- angr/storage/memory_mixins/paged_memory/pages/multi_values.py +11 -10
- angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +18 -17
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +12 -11
- angr/storage/memory_mixins/regioned_memory/abstract_address_descriptor.py +3 -3
- angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +3 -2
- angr/storage/memory_mixins/regioned_memory/region_data.py +1 -2
- angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +2 -2
- angr/storage/memory_mixins/regioned_memory/regioned_address_concretization_mixin.py +3 -3
- angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +18 -21
- angr/storage/memory_mixins/size_resolution_mixin.py +1 -2
- angr/storage/memory_mixins/symbolic_merger_mixin.py +3 -2
- angr/storage/memory_mixins/top_merger_mixin.py +3 -2
- angr/storage/memory_object.py +2 -4
- angr/utils/algo.py +3 -2
- angr/utils/dynamic_dictlist.py +5 -5
- angr/utils/formatting.py +4 -4
- angr/utils/funcid.py +1 -2
- angr/utils/graph.py +5 -6
- angr/utils/library.py +5 -5
- angr/utils/mp.py +5 -4
- angr/utils/segment_list.py +3 -4
- angr/utils/typing.py +3 -2
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/METADATA +9 -11
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/RECORD +239 -236
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/LICENSE +0 -0
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/WHEEL +0 -0
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/entry_points.txt +0 -0
- {angr-9.2.102.dist-info → angr-9.2.103.dist-info}/top_level.txt +0 -0
angr/engines/pcode/lifter.py
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
# - Fix/remove NotImplementedError's
|
|
7
7
|
|
|
8
8
|
import logging
|
|
9
|
-
from typing import
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from collections.abc import Iterable, Sequence
|
|
10
11
|
|
|
11
12
|
import archinfo
|
|
12
13
|
from archinfo import ArchARM, ArchPcode
|
|
@@ -49,10 +50,10 @@ class ExitStatement:
|
|
|
49
50
|
|
|
50
51
|
__slots__ = ("dst", "jumpkind")
|
|
51
52
|
|
|
52
|
-
dst:
|
|
53
|
+
dst: int | None
|
|
53
54
|
jumpkind: str
|
|
54
55
|
|
|
55
|
-
def __init__(self, dst:
|
|
56
|
+
def __init__(self, dst: int | None, jumpkind: str):
|
|
56
57
|
self.dst = dst
|
|
57
58
|
self.jumpkind = jumpkind
|
|
58
59
|
|
|
@@ -125,20 +126,20 @@ class IRSB:
|
|
|
125
126
|
"next",
|
|
126
127
|
)
|
|
127
128
|
|
|
128
|
-
_direct_next:
|
|
129
|
-
_exit_statements: Sequence[
|
|
130
|
-
_instruction_addresses:
|
|
129
|
+
_direct_next: bool | None
|
|
130
|
+
_exit_statements: Sequence[tuple[int, int, ExitStatement]]
|
|
131
|
+
_instruction_addresses: Sequence[int] | None
|
|
131
132
|
_ops: Sequence["pypcode.PcodeOp"] # FIXME: Merge into _statements
|
|
132
|
-
_size:
|
|
133
|
+
_size: int | None
|
|
133
134
|
_statements: Iterable # Note: currently unused
|
|
134
|
-
_disassembly:
|
|
135
|
+
_disassembly: PcodeDisassemblerBlock | None
|
|
135
136
|
addr: int
|
|
136
137
|
arch: archinfo.Arch
|
|
137
|
-
behaviors:
|
|
138
|
+
behaviors: BehaviorFactory | None
|
|
138
139
|
data_refs: Sequence # Note: currently unused
|
|
139
140
|
default_exit_target: Optional # Note: currently used
|
|
140
|
-
jumpkind:
|
|
141
|
-
next:
|
|
141
|
+
jumpkind: str | None
|
|
142
|
+
next: int | None
|
|
142
143
|
|
|
143
144
|
# The following constants shall match the defs in pyvex.h
|
|
144
145
|
MAX_EXITS = 400
|
|
@@ -146,16 +147,16 @@ class IRSB:
|
|
|
146
147
|
|
|
147
148
|
def __init__(
|
|
148
149
|
self,
|
|
149
|
-
data:
|
|
150
|
+
data: str | bytes | None,
|
|
150
151
|
mem_addr: int,
|
|
151
152
|
arch: archinfo.Arch,
|
|
152
|
-
max_inst:
|
|
153
|
-
max_bytes:
|
|
153
|
+
max_inst: int | None = None,
|
|
154
|
+
max_bytes: int | None = None,
|
|
154
155
|
bytes_offset: int = 0,
|
|
155
156
|
traceflags: int = 0,
|
|
156
157
|
opt_level: int = 1,
|
|
157
|
-
num_inst:
|
|
158
|
-
num_bytes:
|
|
158
|
+
num_inst: int | None = None,
|
|
159
|
+
num_bytes: int | None = None,
|
|
159
160
|
strict_block_end: bool = False,
|
|
160
161
|
skip_stmts: bool = False,
|
|
161
162
|
collect_data_refs: bool = False,
|
|
@@ -230,12 +231,12 @@ class IRSB:
|
|
|
230
231
|
def empty_block(
|
|
231
232
|
arch: archinfo.Arch,
|
|
232
233
|
addr: int,
|
|
233
|
-
statements:
|
|
234
|
-
nxt:
|
|
234
|
+
statements: Sequence | None = None,
|
|
235
|
+
nxt: int | None = None,
|
|
235
236
|
tyenv=None, # Unused, kept for compatibility
|
|
236
|
-
jumpkind:
|
|
237
|
-
direct_next:
|
|
238
|
-
size:
|
|
237
|
+
jumpkind: str | None = None,
|
|
238
|
+
direct_next: bool | None = None,
|
|
239
|
+
size: int | None = None,
|
|
239
240
|
) -> "IRSB":
|
|
240
241
|
block = IRSB(None, addr, arch)
|
|
241
242
|
block._set_attributes(statements, nxt, tyenv, jumpkind, direct_next, size=size)
|
|
@@ -246,7 +247,7 @@ class IRSB:
|
|
|
246
247
|
return self.statements is not None and self.statements
|
|
247
248
|
|
|
248
249
|
@property
|
|
249
|
-
def exit_statements(self) -> Sequence[
|
|
250
|
+
def exit_statements(self) -> Sequence[tuple[int, int, ExitStatement]]:
|
|
250
251
|
return self._exit_statements
|
|
251
252
|
|
|
252
253
|
def copy(self) -> "IRSB":
|
|
@@ -457,14 +458,14 @@ class IRSB:
|
|
|
457
458
|
def _set_attributes(
|
|
458
459
|
self: "IRSB",
|
|
459
460
|
statements: Iterable = None,
|
|
460
|
-
nxt:
|
|
461
|
+
nxt: int | None = None,
|
|
461
462
|
tyenv=None, # Unused, kept for compatibility
|
|
462
|
-
jumpkind:
|
|
463
|
-
direct_next:
|
|
464
|
-
size:
|
|
465
|
-
ops:
|
|
466
|
-
instruction_addresses:
|
|
467
|
-
exit_statements: Sequence[
|
|
463
|
+
jumpkind: str | None = None,
|
|
464
|
+
direct_next: bool | None = None,
|
|
465
|
+
size: int | None = None,
|
|
466
|
+
ops: Sequence["pypcode.PcodeOp"] | None = None,
|
|
467
|
+
instruction_addresses: Iterable[int] | None = None,
|
|
468
|
+
exit_statements: Sequence[tuple[int, int, ExitStatement]] = None,
|
|
468
469
|
default_exit_target: Optional = None,
|
|
469
470
|
) -> None:
|
|
470
471
|
# pylint: disable=unused-argument
|
|
@@ -539,15 +540,15 @@ class Lifter:
|
|
|
539
540
|
"addr",
|
|
540
541
|
)
|
|
541
542
|
|
|
542
|
-
data:
|
|
543
|
-
bytes_offset:
|
|
543
|
+
data: str | bytes | None
|
|
544
|
+
bytes_offset: int | None
|
|
544
545
|
opt_level: int
|
|
545
|
-
traceflags:
|
|
546
|
-
allow_arch_optimizations:
|
|
547
|
-
strict_block_end:
|
|
546
|
+
traceflags: int | None
|
|
547
|
+
allow_arch_optimizations: bool | None
|
|
548
|
+
strict_block_end: bool | None
|
|
548
549
|
collect_data_refs: bool
|
|
549
|
-
max_inst:
|
|
550
|
-
max_bytes:
|
|
550
|
+
max_inst: int | None
|
|
551
|
+
max_bytes: int | None
|
|
551
552
|
skip_stmts: bool
|
|
552
553
|
irsb: IRSB
|
|
553
554
|
arch: archinfo.Arch
|
|
@@ -570,14 +571,14 @@ class Lifter:
|
|
|
570
571
|
|
|
571
572
|
def _lift(
|
|
572
573
|
self,
|
|
573
|
-
data:
|
|
574
|
-
bytes_offset:
|
|
575
|
-
max_bytes:
|
|
576
|
-
max_inst:
|
|
574
|
+
data: str | bytes | None,
|
|
575
|
+
bytes_offset: int | None = None,
|
|
576
|
+
max_bytes: int | None = None,
|
|
577
|
+
max_inst: int | None = None,
|
|
577
578
|
opt_level: int = 1,
|
|
578
|
-
traceflags:
|
|
579
|
-
allow_arch_optimizations:
|
|
580
|
-
strict_block_end:
|
|
579
|
+
traceflags: int | None = None,
|
|
580
|
+
allow_arch_optimizations: bool | None = None,
|
|
581
|
+
strict_block_end: bool | None = None,
|
|
581
582
|
skip_stmts: bool = False,
|
|
582
583
|
collect_data_refs: bool = False,
|
|
583
584
|
) -> IRSB:
|
|
@@ -627,11 +628,11 @@ class Lifter:
|
|
|
627
628
|
|
|
628
629
|
# pylint:disable=unused-argument
|
|
629
630
|
def lift(
|
|
630
|
-
data:
|
|
631
|
+
data: str | bytes | None,
|
|
631
632
|
addr: int,
|
|
632
633
|
arch: archinfo.Arch,
|
|
633
|
-
max_bytes:
|
|
634
|
-
max_inst:
|
|
634
|
+
max_bytes: int | None = None,
|
|
635
|
+
max_inst: int | None = None,
|
|
635
636
|
bytes_offset: int = 0,
|
|
636
637
|
opt_level: int = 1,
|
|
637
638
|
traceflags: int = 0,
|
|
@@ -837,10 +838,10 @@ class PcodeBasicBlockLifter:
|
|
|
837
838
|
self,
|
|
838
839
|
irsb: IRSB,
|
|
839
840
|
baseaddr: int,
|
|
840
|
-
data:
|
|
841
|
+
data: bytes | bytearray,
|
|
841
842
|
bytes_offset: int = 0,
|
|
842
|
-
max_bytes:
|
|
843
|
-
max_inst:
|
|
843
|
+
max_bytes: int | None = None,
|
|
844
|
+
max_inst: int | None = None,
|
|
844
845
|
branch_delay_slot: bool = False,
|
|
845
846
|
is_sparc32: bool = False,
|
|
846
847
|
) -> None:
|
|
@@ -994,10 +995,10 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
994
995
|
def __init__(
|
|
995
996
|
self,
|
|
996
997
|
project=None,
|
|
997
|
-
use_cache:
|
|
998
|
+
use_cache: bool | None = None,
|
|
998
999
|
cache_size: int = 50000,
|
|
999
1000
|
default_opt_level: int = 1,
|
|
1000
|
-
selfmodifying_code:
|
|
1001
|
+
selfmodifying_code: bool | None = None,
|
|
1001
1002
|
single_step: bool = False,
|
|
1002
1003
|
default_strict_block_end: bool = False,
|
|
1003
1004
|
**kwargs,
|
|
@@ -1041,22 +1042,22 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
1041
1042
|
# FIXME: Consider moving to higher abstraction layer to reduce duplication with vex
|
|
1042
1043
|
def lift_vex(
|
|
1043
1044
|
self,
|
|
1044
|
-
addr:
|
|
1045
|
-
state:
|
|
1046
|
-
clemory:
|
|
1047
|
-
insn_bytes:
|
|
1048
|
-
arch:
|
|
1049
|
-
size:
|
|
1050
|
-
num_inst:
|
|
1045
|
+
addr: int | None = None,
|
|
1046
|
+
state: SimState | None = None,
|
|
1047
|
+
clemory: cle.Clemory | None = None,
|
|
1048
|
+
insn_bytes: bytes | None = None,
|
|
1049
|
+
arch: archinfo.Arch | None = None,
|
|
1050
|
+
size: int | None = None,
|
|
1051
|
+
num_inst: int | None = None,
|
|
1051
1052
|
traceflags: int = 0,
|
|
1052
1053
|
thumb: bool = False,
|
|
1053
|
-
extra_stop_points:
|
|
1054
|
-
opt_level:
|
|
1055
|
-
strict_block_end:
|
|
1054
|
+
extra_stop_points: Iterable[int] | None = None,
|
|
1055
|
+
opt_level: int | None = None,
|
|
1056
|
+
strict_block_end: bool | None = None,
|
|
1056
1057
|
skip_stmts: bool = False,
|
|
1057
1058
|
collect_data_refs: bool = False,
|
|
1058
1059
|
load_from_ro_regions: bool = False,
|
|
1059
|
-
cross_insn_opt:
|
|
1060
|
+
cross_insn_opt: bool | None = None,
|
|
1060
1061
|
):
|
|
1061
1062
|
"""
|
|
1062
1063
|
Temporary compatibility interface for integration with block code.
|
|
@@ -1082,22 +1083,22 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
1082
1083
|
|
|
1083
1084
|
def lift_pcode(
|
|
1084
1085
|
self,
|
|
1085
|
-
addr:
|
|
1086
|
-
state:
|
|
1087
|
-
clemory:
|
|
1088
|
-
insn_bytes:
|
|
1089
|
-
arch:
|
|
1090
|
-
size:
|
|
1091
|
-
num_inst:
|
|
1086
|
+
addr: int | None = None,
|
|
1087
|
+
state: SimState | None = None,
|
|
1088
|
+
clemory: cle.Clemory | None = None,
|
|
1089
|
+
insn_bytes: bytes | None = None,
|
|
1090
|
+
arch: archinfo.Arch | None = None,
|
|
1091
|
+
size: int | None = None,
|
|
1092
|
+
num_inst: int | None = None,
|
|
1092
1093
|
traceflags: int = 0,
|
|
1093
1094
|
thumb: bool = False,
|
|
1094
|
-
extra_stop_points:
|
|
1095
|
-
opt_level:
|
|
1096
|
-
strict_block_end:
|
|
1095
|
+
extra_stop_points: Iterable[int] | None = None,
|
|
1096
|
+
opt_level: int | None = None,
|
|
1097
|
+
strict_block_end: bool | None = None,
|
|
1097
1098
|
skip_stmts: bool = False,
|
|
1098
1099
|
collect_data_refs: bool = False,
|
|
1099
1100
|
load_from_ro_regions: bool = False,
|
|
1100
|
-
cross_insn_opt:
|
|
1101
|
+
cross_insn_opt: bool | None = None,
|
|
1101
1102
|
):
|
|
1102
1103
|
"""
|
|
1103
1104
|
Lift an IRSB.
|
|
@@ -1296,8 +1297,8 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
1296
1297
|
raise SimTranslationError("Unable to translate bytecode") from e
|
|
1297
1298
|
|
|
1298
1299
|
def _load_bytes(
|
|
1299
|
-
self, addr: int, max_size: int, state:
|
|
1300
|
-
) ->
|
|
1300
|
+
self, addr: int, max_size: int, state: SimState | None = None, clemory: cle.Clemory | None = None
|
|
1301
|
+
) -> tuple[bytes, int, int]:
|
|
1301
1302
|
if clemory is None and state is None:
|
|
1302
1303
|
raise SimEngineError("state and clemory cannot both be None in _load_bytes().")
|
|
1303
1304
|
|
|
@@ -1371,7 +1372,7 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
1371
1372
|
size = min(max_size, size)
|
|
1372
1373
|
return buff, size, offset
|
|
1373
1374
|
|
|
1374
|
-
def _first_stoppoint(self, irsb: IRSB, extra_stop_points:
|
|
1375
|
+
def _first_stoppoint(self, irsb: IRSB, extra_stop_points: Sequence[int] | None = None) -> int | None:
|
|
1375
1376
|
"""
|
|
1376
1377
|
Enumerate the imarks in the block. If any of them (after the first one) are at a stop point, returns the address
|
|
1377
1378
|
of the stop point. None is returned otherwise.
|
|
@@ -1388,7 +1389,7 @@ class PcodeLifterEngineMixin(SimEngineBase):
|
|
|
1388
1389
|
first_imark = False
|
|
1389
1390
|
return None
|
|
1390
1391
|
|
|
1391
|
-
def __is_stop_point(self, addr: int, extra_stop_points:
|
|
1392
|
+
def __is_stop_point(self, addr: int, extra_stop_points: Sequence[int] | None = None) -> bool:
|
|
1392
1393
|
if self.project is not None and addr in self.project._sim_procedures:
|
|
1393
1394
|
return True
|
|
1394
1395
|
elif extra_stop_points is not None and addr in extra_stop_points:
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from typing import Dict, Optional
|
|
2
1
|
import logging
|
|
3
2
|
|
|
4
3
|
import claripy
|
|
@@ -74,7 +73,7 @@ class CCallMultivaluedException(Exception):
|
|
|
74
73
|
### x86* data ###
|
|
75
74
|
##################
|
|
76
75
|
|
|
77
|
-
data:
|
|
76
|
+
data: dict[str, dict[str, dict[str, int | None]]] = {
|
|
78
77
|
"AMD64": {
|
|
79
78
|
"CondTypes": {},
|
|
80
79
|
"CondBitOffsets": {},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
1
|
import logging
|
|
3
2
|
|
|
4
3
|
import claripy
|
|
@@ -14,7 +13,7 @@ l = logging.getLogger(__name__)
|
|
|
14
13
|
zero = claripy.BVV(0, 32)
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
def value(ty, val, size:
|
|
16
|
+
def value(ty, val, size: int | None = None):
|
|
18
17
|
if ty == "Ity_F32":
|
|
19
18
|
return claripy.FPV(float(val), claripy.FSORT_FLOAT)
|
|
20
19
|
elif ty == "Ity_F64":
|
angr/engines/vex/light/light.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
import pyvex
|
|
5
4
|
|
|
@@ -549,7 +548,7 @@ class VEXMixin(SimEngineBase):
|
|
|
549
548
|
self.stmt_idx = DEFAULT_STATEMENT
|
|
550
549
|
self._handle_vex_defaultexit(irsb.next, irsb.jumpkind)
|
|
551
550
|
|
|
552
|
-
def _handle_vex_defaultexit(self, expr:
|
|
551
|
+
def _handle_vex_defaultexit(self, expr: pyvex.expr.IRExpr | None, jumpkind: str):
|
|
553
552
|
self._perform_vex_defaultexit(self._analyze_vex_defaultexit(expr) if expr is not None else None, jumpkind)
|
|
554
553
|
|
|
555
554
|
def _perform_vex_defaultexit(self, expr, jumpkind):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
2
|
import logging
|
|
3
3
|
import cle
|
|
4
4
|
|
|
@@ -179,13 +179,13 @@ class Tracer(ExplorationTechnique):
|
|
|
179
179
|
self._follow_unsat = follow_unsat
|
|
180
180
|
self._fast_forward_to_entry = fast_forward_to_entry
|
|
181
181
|
|
|
182
|
-
self._aslr_slides:
|
|
182
|
+
self._aslr_slides: dict[cle.Backend, int] = {}
|
|
183
183
|
self._current_slide = None
|
|
184
184
|
|
|
185
185
|
self._fd_bytes = None
|
|
186
186
|
|
|
187
187
|
# keep track of the last basic block we hit
|
|
188
|
-
self.predecessors:
|
|
188
|
+
self.predecessors: list["SimState"] = [None] * keep_predecessors
|
|
189
189
|
self.last_state = None
|
|
190
190
|
|
|
191
191
|
# whether we should follow the trace
|
|
@@ -284,7 +284,7 @@ class Tracer(ExplorationTechnique):
|
|
|
284
284
|
# this is an awful fucking heuristic but it's as good as we've got
|
|
285
285
|
return abs(self._trace[idx] - self._trace[idx + 1]) > 0x1000
|
|
286
286
|
|
|
287
|
-
def set_fd_data(self, fd_data:
|
|
287
|
+
def set_fd_data(self, fd_data: dict[int, bytes]):
|
|
288
288
|
"""
|
|
289
289
|
Set concrete bytes of various fds read by the program
|
|
290
290
|
"""
|
angr/factory.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import overload
|
|
2
2
|
import logging
|
|
3
3
|
import archinfo
|
|
4
4
|
from archinfo.arch_soot import ArchSoot, SootAddressDescriptor
|
|
@@ -6,9 +6,12 @@ from archinfo.arch_soot import ArchSoot, SootAddressDescriptor
|
|
|
6
6
|
from .sim_state import SimState
|
|
7
7
|
from .calling_conventions import default_cc, SimRegArg, SimStackArg, PointerWrapper, SimCCUnknown
|
|
8
8
|
from .callable import Callable
|
|
9
|
-
from .errors import AngrAssemblyError
|
|
9
|
+
from .errors import AngrAssemblyError, AngrError
|
|
10
10
|
from .engines import UberEngine, ProcedureEngine, SimEngineConcrete, SimEngine
|
|
11
11
|
from .sim_type import SimTypeFunction, SimTypeInt
|
|
12
|
+
from .codenode import HookNode, SyscallNode
|
|
13
|
+
from .block import Block, SootBlock
|
|
14
|
+
from .sim_manager import SimulationManager
|
|
12
15
|
|
|
13
16
|
try:
|
|
14
17
|
from .engines import UberEnginePcode
|
|
@@ -25,7 +28,7 @@ class AngrObjectFactory:
|
|
|
25
28
|
This factory provides access to important analysis elements.
|
|
26
29
|
"""
|
|
27
30
|
|
|
28
|
-
def __init__(self, project, default_engine:
|
|
31
|
+
def __init__(self, project, default_engine: type[SimEngine] | None = None):
|
|
29
32
|
if default_engine is None:
|
|
30
33
|
if isinstance(project.arch, archinfo.ArchPcode) and UberEnginePcode is not None:
|
|
31
34
|
l.warning("Creating project with the experimental 'UberEnginePcode' engine")
|
|
@@ -171,9 +174,7 @@ class AngrObjectFactory:
|
|
|
171
174
|
"""
|
|
172
175
|
return self.project.simos.state_call(addr, *args, **kwargs)
|
|
173
176
|
|
|
174
|
-
def simulation_manager(
|
|
175
|
-
self, thing: Optional[Union[List[SimState], SimState]] = None, **kwargs
|
|
176
|
-
) -> "SimulationManager":
|
|
177
|
+
def simulation_manager(self, thing: list[SimState] | SimState | None = None, **kwargs) -> "SimulationManager":
|
|
177
178
|
"""
|
|
178
179
|
Constructs a new simulation manager.
|
|
179
180
|
|
|
@@ -289,6 +290,7 @@ class AngrObjectFactory:
|
|
|
289
290
|
cross_insn_opt=True,
|
|
290
291
|
load_from_ro_regions=False,
|
|
291
292
|
initial_regs=None,
|
|
293
|
+
skip_stmts=False,
|
|
292
294
|
) -> "Block": ...
|
|
293
295
|
|
|
294
296
|
# pylint: disable=unused-argument, no-self-use, function-redefined
|
|
@@ -311,6 +313,7 @@ class AngrObjectFactory:
|
|
|
311
313
|
strict_block_end=None,
|
|
312
314
|
collect_data_refs=False,
|
|
313
315
|
cross_insn_opt=True,
|
|
316
|
+
skip_stmts=False,
|
|
314
317
|
) -> "SootBlock": ...
|
|
315
318
|
|
|
316
319
|
def block(
|
|
@@ -333,6 +336,7 @@ class AngrObjectFactory:
|
|
|
333
336
|
cross_insn_opt=True,
|
|
334
337
|
load_from_ro_regions=False,
|
|
335
338
|
initial_regs=None,
|
|
339
|
+
skip_stmts=False,
|
|
336
340
|
):
|
|
337
341
|
if isinstance(self.project.arch, ArchSoot) and isinstance(addr, SootAddressDescriptor):
|
|
338
342
|
return SootBlock(addr, arch=self.project.arch, project=self.project)
|
|
@@ -351,13 +355,11 @@ class AngrObjectFactory:
|
|
|
351
355
|
"Assembling failed. Please make sure keystone is installed, and the assembly string is correct."
|
|
352
356
|
)
|
|
353
357
|
|
|
354
|
-
if max_size is not None:
|
|
355
|
-
l.warning('Keyword argument "max_size" has been deprecated for block(). Please use "size" instead.')
|
|
356
|
-
size = max_size
|
|
357
358
|
return Block(
|
|
358
359
|
addr,
|
|
359
360
|
project=self.project,
|
|
360
361
|
size=size,
|
|
362
|
+
max_size=max_size,
|
|
361
363
|
byte_string=byte_string,
|
|
362
364
|
vex=vex,
|
|
363
365
|
extra_stop_points=extra_stop_points,
|
|
@@ -371,6 +373,7 @@ class AngrObjectFactory:
|
|
|
371
373
|
cross_insn_opt=cross_insn_opt,
|
|
372
374
|
load_from_ro_regions=load_from_ro_regions,
|
|
373
375
|
initial_regs=initial_regs,
|
|
376
|
+
skip_stmts=skip_stmts,
|
|
374
377
|
)
|
|
375
378
|
|
|
376
379
|
def fresh_block(self, addr, size, backup_state=None):
|
|
@@ -380,9 +383,3 @@ class AngrObjectFactory:
|
|
|
380
383
|
cc.SimStackArg = SimStackArg
|
|
381
384
|
callable.PointerWrapper = PointerWrapper
|
|
382
385
|
call_state.PointerWrapper = PointerWrapper
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
from .errors import AngrError
|
|
386
|
-
from .sim_manager import SimulationManager
|
|
387
|
-
from .codenode import HookNode, SyscallNode
|
|
388
|
-
from .block import Block, SootBlock
|
angr/flirt/__init__.py
CHANGED
|
@@ -22,11 +22,11 @@ class FlirtSignature:
|
|
|
22
22
|
platform: str,
|
|
23
23
|
sig_name: str,
|
|
24
24
|
sig_path: str,
|
|
25
|
-
unique_strings:
|
|
26
|
-
compiler:
|
|
27
|
-
compiler_version:
|
|
28
|
-
os_name:
|
|
29
|
-
os_version:
|
|
25
|
+
unique_strings: set[str] | None = None,
|
|
26
|
+
compiler: str | None = None,
|
|
27
|
+
compiler_version: str | None = None,
|
|
28
|
+
os_name: str | None = None,
|
|
29
|
+
os_version: str | None = None,
|
|
30
30
|
):
|
|
31
31
|
self.arch = arch
|
|
32
32
|
self.platform = platform
|
|
@@ -49,9 +49,9 @@ class FlirtSignature:
|
|
|
49
49
|
FS = FlirtSignature
|
|
50
50
|
|
|
51
51
|
# A dict from architecture names to FLIRT signatures under that architecture. Arch names are always in lower case.
|
|
52
|
-
FLIRT_SIGNATURES_BY_ARCH:
|
|
53
|
-
LIBRARY_TO_SIGNATURES:
|
|
54
|
-
STRING_TO_LIBRARIES:
|
|
52
|
+
FLIRT_SIGNATURES_BY_ARCH: dict[str, list[FlirtSignature]] = defaultdict(list)
|
|
53
|
+
LIBRARY_TO_SIGNATURES: dict[str, list[FlirtSignature]] = defaultdict(list)
|
|
54
|
+
STRING_TO_LIBRARIES: dict[str, set[str]] = defaultdict(set)
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
def load_signatures(path: str) -> None:
|
angr/flirt/build_sig.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# pylint:disable=consider-using-with
|
|
2
|
-
from typing import List, Dict
|
|
3
2
|
import json
|
|
4
3
|
import subprocess
|
|
5
4
|
import argparse
|
|
@@ -16,7 +15,7 @@ UNIQUE_STRING_COUNT = 20
|
|
|
16
15
|
MAX_UNIQUE_STRING_LEN = 70
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
def get_basic_info(ar_path: str) ->
|
|
18
|
+
def get_basic_info(ar_path: str) -> dict[str, str]:
|
|
20
19
|
"""
|
|
21
20
|
Get basic information of the archive file.
|
|
22
21
|
"""
|
|
@@ -41,7 +40,7 @@ def get_basic_info(ar_path: str) -> Dict[str, str]:
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
def get_unique_strings(ar_path: str) ->
|
|
43
|
+
def get_unique_strings(ar_path: str) -> list[str]:
|
|
45
44
|
"""
|
|
46
45
|
For Linux libraries, this method requires ar (from binutils), nm (from binutils), and strings.
|
|
47
46
|
"""
|
angr/keyed_region.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import weakref
|
|
3
|
-
from typing import Union,
|
|
3
|
+
from typing import Union, TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
from sortedcontainers import SortedDict
|
|
6
6
|
|
|
@@ -133,7 +133,7 @@ class KeyedRegion:
|
|
|
133
133
|
self._storage, om, self._phi_node_contains = s
|
|
134
134
|
self._object_mapping = weakref.WeakValueDictionary(om)
|
|
135
135
|
|
|
136
|
-
def _get_container(self, offset) ->
|
|
136
|
+
def _get_container(self, offset) -> tuple[int, RegionObject | None]:
|
|
137
137
|
try:
|
|
138
138
|
base_offset = next(self._storage.irange(maximum=offset, reverse=True))
|
|
139
139
|
except StopIteration:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from itertools import count
|
|
4
4
|
import logging
|
|
5
5
|
|
|
6
|
-
from typing import TYPE_CHECKING, TypeVar
|
|
6
|
+
from typing import TYPE_CHECKING, TypeVar
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from ..project import Project
|
|
@@ -116,7 +116,7 @@ class KnowledgeBase:
|
|
|
116
116
|
|
|
117
117
|
K = TypeVar("K", bound=KnowledgeBasePlugin)
|
|
118
118
|
|
|
119
|
-
def get_knowledge(self, requested_plugin_cls:
|
|
119
|
+
def get_knowledge(self, requested_plugin_cls: type[K]) -> K | None:
|
|
120
120
|
"""
|
|
121
121
|
Type inference safe method to request a knowledge base plugin
|
|
122
122
|
Explicitly passing the type of the requested plugin achieves two things:
|
|
@@ -135,7 +135,7 @@ class KnowledgeBase:
|
|
|
135
135
|
None,
|
|
136
136
|
)
|
|
137
137
|
|
|
138
|
-
def request_knowledge(self, requested_plugin_cls:
|
|
138
|
+
def request_knowledge(self, requested_plugin_cls: type[K]) -> K:
|
|
139
139
|
existing = self.get_knowledge(requested_plugin_cls)
|
|
140
140
|
if existing is not None:
|
|
141
141
|
return existing
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Dict, Tuple, Optional
|
|
2
|
-
|
|
3
1
|
from .plugin import KnowledgeBasePlugin
|
|
4
2
|
from ..sim_type import SimTypeFunction
|
|
5
3
|
from ..calling_conventions import SimCC
|
|
@@ -13,7 +11,7 @@ class CallsitePrototypes(KnowledgeBasePlugin):
|
|
|
13
11
|
def __init__(self, kb):
|
|
14
12
|
super().__init__(kb=kb)
|
|
15
13
|
|
|
16
|
-
self._prototypes:
|
|
14
|
+
self._prototypes: dict[int, tuple[SimCC, SimTypeFunction, bool]] = {}
|
|
17
15
|
|
|
18
16
|
def set_prototype(
|
|
19
17
|
self,
|
|
@@ -24,19 +22,19 @@ class CallsitePrototypes(KnowledgeBasePlugin):
|
|
|
24
22
|
) -> None:
|
|
25
23
|
self._prototypes[callsite_block_addr] = cc, prototype, manual
|
|
26
24
|
|
|
27
|
-
def get_cc(self, callsite_block_addr: int) ->
|
|
25
|
+
def get_cc(self, callsite_block_addr: int) -> SimCC | None:
|
|
28
26
|
try:
|
|
29
27
|
return self._prototypes[callsite_block_addr][0]
|
|
30
28
|
except KeyError:
|
|
31
29
|
return None
|
|
32
30
|
|
|
33
|
-
def get_prototype(self, callsite_block_addr: int) ->
|
|
31
|
+
def get_prototype(self, callsite_block_addr: int) -> SimTypeFunction | None:
|
|
34
32
|
try:
|
|
35
33
|
return self._prototypes[callsite_block_addr][1]
|
|
36
34
|
except KeyError:
|
|
37
35
|
return None
|
|
38
36
|
|
|
39
|
-
def get_prototype_type(self, callsite_block_addr: int) ->
|
|
37
|
+
def get_prototype_type(self, callsite_block_addr: int) -> bool | None:
|
|
40
38
|
try:
|
|
41
39
|
return self._prototypes[callsite_block_addr][2]
|
|
42
40
|
except KeyError:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
from
|
|
2
|
-
from functools import reduce
|
|
1
|
+
from collections import defaultdict
|
|
3
2
|
|
|
4
3
|
from archinfo.arch_arm import is_arm_arch
|
|
5
4
|
|
|
@@ -53,15 +52,29 @@ class CFGManager(KnowledgeBasePlugin):
|
|
|
53
52
|
cm.cfgs = dict(map(lambda x: (x[0], x[1].copy()), self.cfgs.items()))
|
|
54
53
|
return cm
|
|
55
54
|
|
|
56
|
-
def get_most_accurate(self) ->
|
|
55
|
+
def get_most_accurate(self) -> CFGModel | None:
|
|
57
56
|
"""
|
|
58
57
|
:return: The most accurate CFG present in the CFGManager, or None if it does not hold any.
|
|
59
58
|
"""
|
|
60
59
|
less_accurate_to_most_accurate = ["CFGFast", "CFGEmulated"]
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
sorted_cfgs_by_prefix = defaultdict(list)
|
|
62
|
+
for key, cfg_model in self.cfgs.items():
|
|
63
|
+
for prefix in less_accurate_to_most_accurate:
|
|
64
|
+
if key.startswith(prefix):
|
|
65
|
+
the_prefix = prefix
|
|
66
|
+
break
|
|
67
|
+
else:
|
|
68
|
+
# not found
|
|
69
|
+
continue
|
|
70
|
+
|
|
71
|
+
sorted_cfgs_by_prefix[the_prefix].append((key, cfg_model))
|
|
72
|
+
|
|
73
|
+
for key in reversed(less_accurate_to_most_accurate):
|
|
74
|
+
if key in sorted_cfgs_by_prefix:
|
|
75
|
+
lst = sorted(sorted_cfgs_by_prefix[key], key=lambda item: item[0])
|
|
76
|
+
return lst[-1][-1]
|
|
77
|
+
return None
|
|
65
78
|
|
|
66
79
|
#
|
|
67
80
|
# Pickling
|