angr 9.2.131__py3-none-manylinux2014_aarch64.whl → 9.2.133__py3-none-manylinux2014_aarch64.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 +128 -128
- angr/analyses/__init__.py +38 -38
- angr/analyses/analysis.py +6 -2
- angr/analyses/backward_slice.py +3 -4
- angr/analyses/binary_optimizer.py +5 -12
- angr/analyses/bindiff.py +3 -6
- angr/analyses/calling_convention.py +3 -4
- angr/analyses/cfg/__init__.py +3 -3
- angr/analyses/cfg/cfg_base.py +1 -1
- angr/analyses/cfg/cfg_emulated.py +5 -5
- angr/analyses/cfg/cfg_fast.py +19 -17
- angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
- angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +148 -101
- angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
- angr/analyses/data_dep/__init__.py +4 -4
- angr/analyses/datagraph_meta.py +1 -1
- angr/analyses/ddg.py +16 -17
- angr/analyses/decompiler/__init__.py +12 -12
- angr/analyses/decompiler/ail_simplifier.py +24 -12
- angr/analyses/decompiler/block_similarity.py +2 -4
- angr/analyses/decompiler/block_simplifier.py +10 -21
- angr/analyses/decompiler/callsite_maker.py +1 -1
- angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
- angr/analyses/decompiler/clinic.py +122 -41
- angr/analyses/decompiler/condition_processor.py +57 -39
- angr/analyses/decompiler/counters/__init__.py +3 -3
- angr/analyses/decompiler/decompilation_cache.py +7 -7
- angr/analyses/decompiler/dephication/__init__.py +1 -1
- angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
- angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
- angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
- angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
- angr/analyses/decompiler/expression_narrower.py +1 -1
- angr/analyses/decompiler/graph_region.py +8 -8
- angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
- angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
- angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
- angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
- angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
- angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
- angr/analyses/decompiler/optimization_passes/engine_base.py +262 -84
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +175 -39
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
- angr/analyses/decompiler/optimization_passes/mod_simplifier.py +12 -3
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +42 -19
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
- angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
- angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
- angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +2 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
- angr/analyses/decompiler/presets/__init__.py +1 -1
- angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
- angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
- angr/analyses/decompiler/ssailification/rewriting.py +1 -2
- angr/analyses/decompiler/ssailification/rewriting_engine.py +139 -56
- angr/analyses/decompiler/ssailification/ssailification.py +2 -1
- angr/analyses/decompiler/ssailification/traversal.py +4 -6
- angr/analyses/decompiler/ssailification/traversal_engine.py +125 -42
- angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
- angr/analyses/decompiler/structured_codegen/base.py +3 -3
- angr/analyses/decompiler/structured_codegen/c.py +39 -40
- angr/analyses/decompiler/structuring/__init__.py +3 -3
- angr/analyses/decompiler/structuring/phoenix.py +45 -29
- angr/analyses/decompiler/structuring/structurer_base.py +2 -2
- angr/analyses/decompiler/structuring/structurer_nodes.py +23 -14
- angr/analyses/deobfuscator/__init__.py +3 -3
- angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
- angr/analyses/deobfuscator/string_obf_finder.py +2 -2
- angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
- angr/analyses/disassembly.py +4 -4
- angr/analyses/forward_analysis/__init__.py +1 -1
- angr/analyses/forward_analysis/visitors/graph.py +6 -6
- angr/analyses/init_finder.py +47 -22
- angr/analyses/loop_analysis.py +1 -1
- angr/analyses/loopfinder.py +1 -1
- angr/analyses/propagator/engine_base.py +21 -14
- angr/analyses/propagator/engine_vex.py +149 -179
- angr/analyses/propagator/outdated_definition_walker.py +12 -6
- angr/analyses/propagator/propagator.py +10 -28
- angr/analyses/propagator/top_checker_mixin.py +211 -5
- angr/analyses/propagator/vex_vars.py +4 -4
- angr/analyses/reaching_definitions/__init__.py +9 -9
- angr/analyses/reaching_definitions/call_trace.py +2 -2
- angr/analyses/reaching_definitions/dep_graph.py +1 -1
- angr/analyses/reaching_definitions/engine_ail.py +304 -329
- angr/analyses/reaching_definitions/engine_vex.py +243 -229
- angr/analyses/reaching_definitions/function_handler.py +3 -3
- angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
- angr/analyses/reaching_definitions/rd_state.py +47 -42
- angr/analyses/reassembler.py +26 -31
- angr/analyses/s_liveness.py +8 -0
- angr/analyses/s_propagator.py +18 -3
- angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
- angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
- angr/analyses/stack_pointer_tracker.py +4 -4
- angr/analyses/typehoon/simple_solver.py +14 -14
- angr/analyses/typehoon/translator.py +10 -2
- angr/analyses/typehoon/typeconsts.py +11 -3
- angr/analyses/typehoon/typevars.py +26 -26
- angr/analyses/unpacker/__init__.py +1 -1
- angr/analyses/variable_recovery/engine_ail.py +299 -259
- angr/analyses/variable_recovery/engine_base.py +138 -121
- angr/analyses/variable_recovery/engine_vex.py +175 -185
- angr/analyses/variable_recovery/irsb_scanner.py +49 -38
- angr/analyses/variable_recovery/variable_recovery.py +28 -5
- angr/analyses/variable_recovery/variable_recovery_base.py +33 -34
- angr/analyses/variable_recovery/variable_recovery_fast.py +4 -8
- angr/analyses/veritesting.py +2 -2
- angr/analyses/vfg.py +5 -5
- angr/analyses/xrefs.py +46 -19
- angr/angrdb/serializers/__init__.py +1 -1
- angr/annocfg.py +20 -15
- angr/blade.py +2 -2
- angr/block.py +20 -25
- angr/calling_conventions.py +12 -14
- angr/code_location.py +6 -10
- angr/codenode.py +3 -3
- angr/engines/__init__.py +12 -14
- angr/engines/engine.py +24 -61
- angr/engines/light/__init__.py +13 -5
- angr/engines/light/data.py +1 -1
- angr/engines/light/engine.py +1003 -1185
- angr/engines/pcode/__init__.py +1 -1
- angr/engines/pcode/behavior.py +1 -1
- angr/engines/pcode/cc.py +2 -0
- angr/engines/pcode/lifter.py +13 -15
- angr/engines/soot/expressions/__init__.py +12 -12
- angr/engines/soot/statements/__init__.py +6 -6
- angr/engines/soot/values/__init__.py +6 -6
- angr/engines/soot/values/arrayref.py +2 -2
- angr/engines/soot/values/constants.py +1 -1
- angr/engines/soot/values/instancefieldref.py +1 -1
- angr/engines/soot/values/paramref.py +1 -1
- angr/engines/soot/values/staticfieldref.py +1 -1
- angr/engines/successors.py +15 -14
- angr/engines/vex/__init__.py +5 -5
- angr/engines/vex/claripy/ccall.py +2 -2
- angr/engines/vex/claripy/datalayer.py +1 -1
- angr/engines/vex/claripy/irop.py +19 -19
- angr/engines/vex/heavy/__init__.py +2 -2
- angr/engines/vex/heavy/actions.py +1 -3
- angr/engines/vex/heavy/heavy.py +4 -6
- angr/engines/vex/lifter.py +2 -4
- angr/engines/vex/light/light.py +0 -2
- angr/engines/vex/light/slicing.py +5 -5
- angr/exploration_techniques/__init__.py +19 -142
- angr/exploration_techniques/base.py +126 -0
- angr/exploration_techniques/bucketizer.py +1 -1
- angr/exploration_techniques/dfs.py +3 -1
- angr/exploration_techniques/director.py +2 -3
- angr/exploration_techniques/driller_core.py +1 -1
- angr/exploration_techniques/explorer.py +4 -2
- angr/exploration_techniques/lengthlimiter.py +2 -1
- angr/exploration_techniques/local_loop_seer.py +2 -1
- angr/exploration_techniques/loop_seer.py +5 -5
- angr/exploration_techniques/manual_mergepoint.py +2 -1
- angr/exploration_techniques/memory_watcher.py +3 -1
- angr/exploration_techniques/oppologist.py +4 -5
- angr/exploration_techniques/slicecutor.py +4 -2
- angr/exploration_techniques/spiller.py +1 -1
- angr/exploration_techniques/stochastic.py +2 -1
- angr/exploration_techniques/stub_stasher.py +2 -1
- angr/exploration_techniques/suggestions.py +3 -1
- angr/exploration_techniques/symbion.py +3 -1
- angr/exploration_techniques/tech_builder.py +2 -1
- angr/exploration_techniques/threading.py +2 -11
- angr/exploration_techniques/timeout.py +4 -2
- angr/exploration_techniques/tracer.py +4 -3
- angr/exploration_techniques/unique.py +3 -2
- angr/exploration_techniques/veritesting.py +1 -1
- angr/factory.py +36 -6
- angr/keyed_region.py +4 -4
- angr/knowledge_base.py +1 -1
- angr/knowledge_plugins/__init__.py +11 -11
- angr/knowledge_plugins/cfg/__init__.py +5 -5
- angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
- angr/knowledge_plugins/cfg/cfg_model.py +8 -8
- angr/knowledge_plugins/cfg/cfg_node.py +19 -19
- angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
- angr/knowledge_plugins/cfg/memory_data.py +5 -7
- angr/knowledge_plugins/functions/function.py +48 -52
- angr/knowledge_plugins/functions/function_parser.py +4 -4
- angr/knowledge_plugins/key_definitions/__init__.py +3 -3
- angr/knowledge_plugins/key_definitions/atoms.py +8 -8
- angr/knowledge_plugins/key_definitions/definition.py +1 -1
- angr/knowledge_plugins/key_definitions/live_definitions.py +30 -27
- angr/knowledge_plugins/labels.py +1 -1
- angr/knowledge_plugins/propagations/__init__.py +1 -1
- angr/knowledge_plugins/propagations/prop_value.py +2 -2
- angr/knowledge_plugins/propagations/propagation_model.py +7 -8
- angr/knowledge_plugins/propagations/states.py +44 -39
- angr/knowledge_plugins/variables/variable_access.py +2 -2
- angr/knowledge_plugins/variables/variable_manager.py +24 -10
- angr/knowledge_plugins/xrefs/xref.py +5 -8
- angr/misc/__init__.py +4 -4
- angr/misc/hookset.py +4 -5
- angr/misc/loggers.py +2 -2
- angr/misc/telemetry.py +1 -1
- angr/procedures/__init__.py +1 -1
- angr/procedures/cgc/fdwait.py +2 -2
- angr/procedures/definitions/__init__.py +2 -2
- angr/procedures/definitions/linux_kernel.py +0 -1
- angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
- angr/procedures/definitions/parse_win32json.py +0 -1
- angr/procedures/ntdll/exceptions.py +1 -1
- angr/procedures/stubs/format_parser.py +3 -3
- angr/procedures/win32/dynamic_loading.py +1 -1
- angr/protos/__init__.py +3 -3
- angr/sim_manager.py +3 -5
- angr/sim_state.py +40 -42
- angr/sim_state_options.py +3 -3
- angr/sim_type.py +15 -14
- angr/sim_variable.py +42 -45
- angr/simos/__init__.py +4 -4
- angr/simos/cgc.py +1 -1
- angr/simos/simos.py +1 -1
- angr/simos/userland.py +1 -1
- angr/slicer.py +4 -7
- angr/state_plugins/__init__.py +34 -34
- angr/state_plugins/callstack.py +5 -12
- angr/state_plugins/heap/__init__.py +2 -2
- angr/state_plugins/heap/heap_brk.py +2 -4
- angr/state_plugins/heap/heap_ptmalloc.py +1 -1
- angr/state_plugins/jni_references.py +3 -2
- angr/state_plugins/scratch.py +1 -1
- angr/state_plugins/sim_action.py +1 -4
- angr/state_plugins/sim_event.py +1 -1
- angr/state_plugins/solver.py +7 -9
- angr/state_plugins/uc_manager.py +1 -1
- angr/state_plugins/view.py +2 -2
- angr/storage/__init__.py +1 -1
- angr/storage/file.py +10 -10
- angr/storage/memory_mixins/__init__.py +46 -46
- angr/storage/memory_mixins/default_filler_mixin.py +1 -3
- angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
- angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
- angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
- angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
- angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
- angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
- angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
- angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
- angr/storage/memory_object.py +4 -4
- angr/utils/__init__.py +3 -3
- angr/utils/bits.py +12 -0
- angr/utils/dynamic_dictlist.py +1 -1
- angr/utils/graph.py +1 -1
- angr/utils/orderedset.py +4 -1
- angr/utils/segment_list.py +2 -2
- angr/utils/ssa/__init__.py +33 -8
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/RECORD +262 -263
- angr/analyses/propagator/engine_ail.py +0 -1562
- angr/storage/memory_mixins/__init__.pyi +0 -48
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
|
@@ -5,29 +5,25 @@ import logging
|
|
|
5
5
|
from ailment.block import Block
|
|
6
6
|
from ailment.statement import Statement, Assignment, Store, Call, Return, ConditionalJump, DirtyStatement
|
|
7
7
|
from ailment.expression import (
|
|
8
|
-
|
|
8
|
+
Expression,
|
|
9
9
|
VirtualVariable,
|
|
10
10
|
Load,
|
|
11
|
-
Const,
|
|
12
11
|
BinaryOp,
|
|
12
|
+
UnaryOp,
|
|
13
13
|
Phi,
|
|
14
14
|
Convert,
|
|
15
|
-
StackBaseOffset,
|
|
16
15
|
ITE,
|
|
17
16
|
VEXCCallExpression,
|
|
18
17
|
DirtyExpression,
|
|
19
18
|
)
|
|
20
19
|
|
|
21
|
-
from angr.engines.light import
|
|
20
|
+
from angr.engines.light import SimEngineNostmtAIL
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
_l = logging.getLogger(__name__)
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
class SimEngineDephiRewriting(
|
|
28
|
-
SimEngineLightAILMixin,
|
|
29
|
-
SimEngineLight,
|
|
30
|
-
):
|
|
26
|
+
class SimEngineDephiRewriting(SimEngineNostmtAIL[None, Expression | None, Statement | tuple[Statement, ...], None]):
|
|
31
27
|
"""
|
|
32
28
|
This engine rewrites every block to insert phi variables and replaces every used variable with their versioned
|
|
33
29
|
copies at each use location.
|
|
@@ -37,15 +33,22 @@ class SimEngineDephiRewriting(
|
|
|
37
33
|
|
|
38
34
|
def __init__(
|
|
39
35
|
self,
|
|
40
|
-
|
|
36
|
+
project,
|
|
41
37
|
vvar_to_vvar: dict[int, int],
|
|
42
38
|
):
|
|
43
|
-
super().__init__()
|
|
39
|
+
super().__init__(project)
|
|
44
40
|
|
|
45
|
-
self.arch = arch
|
|
46
41
|
self.vvar_to_vvar = vvar_to_vvar
|
|
47
42
|
self.out_block = None
|
|
48
43
|
|
|
44
|
+
self._stmt_handlers["IncompleteSwitchCaseHeadStatement"] = self._handle_stmt_IncompleteSwitchCaseHeadStatement
|
|
45
|
+
|
|
46
|
+
def _top(self, bits):
|
|
47
|
+
assert False, "Unreachable"
|
|
48
|
+
|
|
49
|
+
def _is_top(self, expr):
|
|
50
|
+
return False
|
|
51
|
+
|
|
49
52
|
def append_statement(self, stmt: Statement) -> None:
|
|
50
53
|
if self.out_block is None:
|
|
51
54
|
self.out_block = Block(self.block.addr, self.block.original_size, statements=[], idx=self.block.idx)
|
|
@@ -55,18 +58,19 @@ class SimEngineDephiRewriting(
|
|
|
55
58
|
# Handlers
|
|
56
59
|
#
|
|
57
60
|
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
def _process_block_end(self, block, stmt_data, whitelist):
|
|
62
|
+
assert whitelist is None
|
|
63
|
+
for stmt_idx, new_stmt in enumerate(stmt_data):
|
|
64
|
+
if new_stmt is not None:
|
|
65
|
+
if isinstance(new_stmt, tuple):
|
|
66
|
+
for stmt_ in new_stmt:
|
|
67
|
+
self.append_statement(stmt_)
|
|
68
|
+
else:
|
|
69
|
+
self.append_statement(new_stmt)
|
|
64
70
|
else:
|
|
65
|
-
self.append_statement(
|
|
66
|
-
else:
|
|
67
|
-
self.append_statement(stmt)
|
|
71
|
+
self.append_statement(block.statements[stmt_idx])
|
|
68
72
|
|
|
69
|
-
def
|
|
73
|
+
def _handle_stmt_Assignment(self, stmt):
|
|
70
74
|
new_src = self._expr(stmt.src)
|
|
71
75
|
new_dst = None
|
|
72
76
|
|
|
@@ -92,7 +96,7 @@ class SimEngineDephiRewriting(
|
|
|
92
96
|
)
|
|
93
97
|
return None
|
|
94
98
|
|
|
95
|
-
def
|
|
99
|
+
def _handle_stmt_Store(self, stmt):
|
|
96
100
|
new_addr = self._expr(stmt.addr)
|
|
97
101
|
new_data = self._expr(stmt.data)
|
|
98
102
|
|
|
@@ -110,7 +114,7 @@ class SimEngineDephiRewriting(
|
|
|
110
114
|
|
|
111
115
|
return None
|
|
112
116
|
|
|
113
|
-
def
|
|
117
|
+
def _handle_stmt_ConditionalJump(self, stmt):
|
|
114
118
|
new_cond = self._expr(stmt.condition)
|
|
115
119
|
new_true_target = self._expr(stmt.true_target) if stmt.true_target is not None else None
|
|
116
120
|
new_false_target = self._expr(stmt.false_target) if stmt.false_target is not None else None
|
|
@@ -127,7 +131,7 @@ class SimEngineDephiRewriting(
|
|
|
127
131
|
)
|
|
128
132
|
return None
|
|
129
133
|
|
|
130
|
-
def
|
|
134
|
+
def _handle_stmt_Call(self, stmt):
|
|
131
135
|
new_target = self._expr(stmt.target) if stmt.target is not None and not isinstance(stmt.target, str) else None
|
|
132
136
|
new_ret_expr = self._expr(stmt.ret_expr) if stmt.ret_expr is not None else None
|
|
133
137
|
new_fp_ret_expr = self._expr(stmt.fp_ret_expr) if stmt.fp_ret_expr is not None else None
|
|
@@ -146,24 +150,19 @@ class SimEngineDephiRewriting(
|
|
|
146
150
|
)
|
|
147
151
|
return None
|
|
148
152
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def _handle_DirtyStatement(self, stmt: DirtyStatement) -> DirtyStatement | None:
|
|
153
|
+
def _handle_stmt_DirtyStatement(self, stmt: DirtyStatement) -> DirtyStatement | None:
|
|
152
154
|
dirty = self._expr(stmt.dirty)
|
|
153
155
|
if dirty is None or dirty is stmt.dirty:
|
|
154
156
|
return None
|
|
155
157
|
return DirtyStatement(stmt.idx, dirty, **stmt.tags)
|
|
156
158
|
|
|
157
|
-
def
|
|
158
|
-
return None
|
|
159
|
-
|
|
160
|
-
def _handle_Load(self, expr: Load) -> Load | None:
|
|
159
|
+
def _handle_expr_Load(self, expr):
|
|
161
160
|
new_addr = self._expr(expr.addr)
|
|
162
161
|
if new_addr is not None:
|
|
163
162
|
return Load(expr.idx, new_addr, expr.size, expr.endness, guard=expr.guard, alt=expr.alt, **expr.tags)
|
|
164
163
|
return None
|
|
165
164
|
|
|
166
|
-
def
|
|
165
|
+
def _handle_expr_Convert(self, expr):
|
|
167
166
|
new_operand = self._expr(expr.operand)
|
|
168
167
|
if new_operand is not None:
|
|
169
168
|
return Convert(
|
|
@@ -179,13 +178,13 @@ class SimEngineDephiRewriting(
|
|
|
179
178
|
)
|
|
180
179
|
return None
|
|
181
180
|
|
|
182
|
-
def
|
|
181
|
+
def _handle_expr_Const(self, expr):
|
|
183
182
|
return None
|
|
184
183
|
|
|
185
|
-
def
|
|
184
|
+
def _handle_expr_Phi(self, expr: Phi) -> None:
|
|
186
185
|
return None
|
|
187
186
|
|
|
188
|
-
def
|
|
187
|
+
def _handle_expr_VirtualVariable(self, expr: VirtualVariable) -> VirtualVariable | None:
|
|
189
188
|
if expr.varid in self.vvar_to_vvar:
|
|
190
189
|
return VirtualVariable(
|
|
191
190
|
expr.idx,
|
|
@@ -199,13 +198,13 @@ class SimEngineDephiRewriting(
|
|
|
199
198
|
)
|
|
200
199
|
return None
|
|
201
200
|
|
|
202
|
-
def
|
|
203
|
-
if
|
|
201
|
+
def _handle_stmt_Return(self, stmt):
|
|
202
|
+
if stmt.ret_exprs is None:
|
|
204
203
|
new_ret_exprs = None
|
|
205
204
|
else:
|
|
206
205
|
updated = False
|
|
207
206
|
new_ret_exprs = []
|
|
208
|
-
for r in
|
|
207
|
+
for r in stmt.ret_exprs:
|
|
209
208
|
new_r = self._expr(r)
|
|
210
209
|
if new_r is not None:
|
|
211
210
|
updated = True
|
|
@@ -214,10 +213,13 @@ class SimEngineDephiRewriting(
|
|
|
214
213
|
new_ret_exprs = None
|
|
215
214
|
|
|
216
215
|
if new_ret_exprs:
|
|
217
|
-
return Return(
|
|
216
|
+
return Return(stmt.idx, new_ret_exprs, **stmt.tags)
|
|
217
|
+
return None
|
|
218
|
+
|
|
219
|
+
def _handle_stmt_IncompleteSwitchCaseHeadStatement(self, stmt):
|
|
218
220
|
return None
|
|
219
221
|
|
|
220
|
-
def
|
|
222
|
+
def _handle_expr_BinaryOp(self, expr):
|
|
221
223
|
new_op0 = self._expr(expr.operands[0])
|
|
222
224
|
new_op1 = self._expr(expr.operands[1])
|
|
223
225
|
|
|
@@ -233,13 +235,24 @@ class SimEngineDephiRewriting(
|
|
|
233
235
|
bits=expr.bits,
|
|
234
236
|
floating_point=expr.floating_point,
|
|
235
237
|
rounding_mode=expr.rounding_mode,
|
|
236
|
-
from_bits=expr.from_bits,
|
|
237
|
-
to_bits=expr.to_bits,
|
|
238
238
|
**expr.tags,
|
|
239
239
|
)
|
|
240
240
|
return None
|
|
241
241
|
|
|
242
|
-
def
|
|
242
|
+
def _handle_expr_UnaryOp(self, expr):
|
|
243
|
+
new_op0 = self._expr(expr.operands[0])
|
|
244
|
+
|
|
245
|
+
if new_op0 is not None:
|
|
246
|
+
return UnaryOp(
|
|
247
|
+
expr.idx,
|
|
248
|
+
expr.op,
|
|
249
|
+
expr.operands[0] if new_op0 is None else new_op0,
|
|
250
|
+
bits=expr.bits,
|
|
251
|
+
**expr.tags,
|
|
252
|
+
)
|
|
253
|
+
return None
|
|
254
|
+
|
|
255
|
+
def _handle_expr_ITE(self, expr):
|
|
243
256
|
new_cond = self._expr(expr.cond)
|
|
244
257
|
new_iftrue = self._expr(expr.iftrue)
|
|
245
258
|
new_iffalse = self._expr(expr.iffalse)
|
|
@@ -275,7 +288,7 @@ class SimEngineDephiRewriting(
|
|
|
275
288
|
)
|
|
276
289
|
return None
|
|
277
290
|
|
|
278
|
-
def
|
|
291
|
+
def _handle_expr_DirtyExpression(self, expr: DirtyExpression) -> DirtyExpression | None:
|
|
279
292
|
new_operands = []
|
|
280
293
|
updated = False
|
|
281
294
|
for o in expr.operands:
|
|
@@ -306,5 +319,116 @@ class SimEngineDephiRewriting(
|
|
|
306
319
|
)
|
|
307
320
|
return None
|
|
308
321
|
|
|
309
|
-
def
|
|
322
|
+
def _handle_expr_BasePointerOffset(self, expr):
|
|
323
|
+
return None
|
|
324
|
+
|
|
325
|
+
def _handle_expr_StackBaseOffset(self, expr):
|
|
326
|
+
return None
|
|
327
|
+
|
|
328
|
+
def _handle_expr_Call(self, expr: Call):
|
|
329
|
+
new_target = self._expr(expr.target) if expr.target is not None and not isinstance(expr.target, str) else None
|
|
330
|
+
new_ret_expr = self._expr(expr.ret_expr) if expr.ret_expr is not None else None
|
|
331
|
+
new_fp_ret_expr = self._expr(expr.fp_ret_expr) if expr.fp_ret_expr is not None else None
|
|
332
|
+
|
|
333
|
+
if new_target is not None or new_ret_expr is not None or new_fp_ret_expr is not None:
|
|
334
|
+
return Call(
|
|
335
|
+
expr.idx,
|
|
336
|
+
expr.target if new_target is None else new_target,
|
|
337
|
+
calling_convention=expr.calling_convention,
|
|
338
|
+
prototype=expr.prototype,
|
|
339
|
+
args=expr.args,
|
|
340
|
+
ret_expr=expr.ret_expr if new_ret_expr is None else new_ret_expr,
|
|
341
|
+
fp_ret_expr=expr.fp_ret_expr if new_fp_ret_expr is None else new_fp_ret_expr,
|
|
342
|
+
bits=expr.bits,
|
|
343
|
+
**expr.tags,
|
|
344
|
+
)
|
|
345
|
+
return None
|
|
346
|
+
|
|
347
|
+
def _handle_expr_DirtyExpression(self, expr):
|
|
310
348
|
return None
|
|
349
|
+
|
|
350
|
+
def _handle_expr_MultiStatementExpression(self, expr):
|
|
351
|
+
return None
|
|
352
|
+
|
|
353
|
+
def _handle_expr_Register(self, expr):
|
|
354
|
+
return None
|
|
355
|
+
|
|
356
|
+
def _handle_expr_Reinterpret(self, expr):
|
|
357
|
+
return None
|
|
358
|
+
|
|
359
|
+
def _handle_expr_Tmp(self, expr):
|
|
360
|
+
return None
|
|
361
|
+
|
|
362
|
+
def _handle_expr_VEXCCallExpression(self, expr):
|
|
363
|
+
return None
|
|
364
|
+
|
|
365
|
+
def _unreachable(self, *args, **kwargs):
|
|
366
|
+
assert False
|
|
367
|
+
|
|
368
|
+
_handle_binop_Add = _unreachable
|
|
369
|
+
_handle_binop_AddF = _unreachable
|
|
370
|
+
_handle_binop_AddV = _unreachable
|
|
371
|
+
_handle_binop_And = _unreachable
|
|
372
|
+
_handle_binop_Carry = _unreachable
|
|
373
|
+
_handle_binop_CmpEQ = _unreachable
|
|
374
|
+
_handle_binop_CmpF = _unreachable
|
|
375
|
+
_handle_binop_CmpGE = _unreachable
|
|
376
|
+
_handle_binop_CmpGT = _unreachable
|
|
377
|
+
_handle_binop_CmpLE = _unreachable
|
|
378
|
+
_handle_binop_CmpLT = _unreachable
|
|
379
|
+
_handle_binop_CmpNE = _unreachable
|
|
380
|
+
_handle_binop_Concat = _unreachable
|
|
381
|
+
_handle_binop_Div = _unreachable
|
|
382
|
+
_handle_binop_DivF = _unreachable
|
|
383
|
+
_handle_binop_DivV = _unreachable
|
|
384
|
+
_handle_binop_LogicalAnd = _unreachable
|
|
385
|
+
_handle_binop_LogicalOr = _unreachable
|
|
386
|
+
_handle_binop_Mod = _unreachable
|
|
387
|
+
_handle_binop_Mul = _unreachable
|
|
388
|
+
_handle_binop_Mull = _unreachable
|
|
389
|
+
_handle_binop_MulF = _unreachable
|
|
390
|
+
_handle_binop_MulV = _unreachable
|
|
391
|
+
_handle_binop_MulHiV = _unreachable
|
|
392
|
+
_handle_binop_Or = _unreachable
|
|
393
|
+
_handle_binop_Rol = _unreachable
|
|
394
|
+
_handle_binop_Ror = _unreachable
|
|
395
|
+
_handle_binop_SBorrow = _unreachable
|
|
396
|
+
_handle_binop_SCarry = _unreachable
|
|
397
|
+
_handle_binop_Sar = _unreachable
|
|
398
|
+
_handle_binop_Shl = _unreachable
|
|
399
|
+
_handle_binop_Shr = _unreachable
|
|
400
|
+
_handle_binop_Sub = _unreachable
|
|
401
|
+
_handle_binop_SubF = _unreachable
|
|
402
|
+
_handle_binop_SubV = _unreachable
|
|
403
|
+
_handle_binop_Xor = _unreachable
|
|
404
|
+
_handle_binop_InterleaveLOV = _unreachable
|
|
405
|
+
_handle_binop_InterleaveHIV = _unreachable
|
|
406
|
+
_handle_binop_CasCmpEQ = _unreachable
|
|
407
|
+
_handle_binop_CasCmpNE = _unreachable
|
|
408
|
+
_handle_binop_ExpCmpNE = _unreachable
|
|
409
|
+
_handle_binop_SarNV = _unreachable
|
|
410
|
+
_handle_binop_ShrNV = _unreachable
|
|
411
|
+
_handle_binop_ShlNV = _unreachable
|
|
412
|
+
_handle_binop_CmpEQV = _unreachable
|
|
413
|
+
_handle_binop_CmpNEV = _unreachable
|
|
414
|
+
_handle_binop_CmpGEV = _unreachable
|
|
415
|
+
_handle_binop_CmpGTV = _unreachable
|
|
416
|
+
_handle_binop_CmpLEV = _unreachable
|
|
417
|
+
_handle_binop_CmpLTV = _unreachable
|
|
418
|
+
_handle_binop_MinV = _unreachable
|
|
419
|
+
_handle_binop_MaxV = _unreachable
|
|
420
|
+
_handle_binop_QAddV = _unreachable
|
|
421
|
+
_handle_binop_QNarrowBinV = _unreachable
|
|
422
|
+
_handle_binop_PermV = _unreachable
|
|
423
|
+
_handle_binop_Set = _unreachable
|
|
424
|
+
_handle_unop_BitwiseNeg = _unreachable
|
|
425
|
+
_handle_unop_Dereference = _unreachable
|
|
426
|
+
_handle_unop_Neg = _unreachable
|
|
427
|
+
_handle_unop_Not = _unreachable
|
|
428
|
+
_handle_unop_Reference = _unreachable
|
|
429
|
+
_handle_unop_Clz = _unreachable
|
|
430
|
+
_handle_unop_Ctz = _unreachable
|
|
431
|
+
_handle_unop_GetMSBs = _unreachable
|
|
432
|
+
_handle_unop_unpack = _unreachable
|
|
433
|
+
_handle_unop_Sqrt = _unreachable
|
|
434
|
+
_handle_unop_RSqrtEst = _unreachable
|
|
@@ -7,6 +7,7 @@ from ailment.block import Block
|
|
|
7
7
|
from ailment.statement import Assignment
|
|
8
8
|
from ailment.expression import VirtualVariable, Phi
|
|
9
9
|
|
|
10
|
+
import angr
|
|
10
11
|
from angr.utils.ail import is_phi_assignment
|
|
11
12
|
from angr.knowledge_plugins.functions import Function
|
|
12
13
|
from angr.analyses import register_analysis
|
|
@@ -53,7 +54,7 @@ class SeqNodeRewriter(SequenceWalker):
|
|
|
53
54
|
variables.
|
|
54
55
|
"""
|
|
55
56
|
|
|
56
|
-
def __init__(self, seq_node: SequenceNode, vvar_to_vvar: dict[int, int],
|
|
57
|
+
def __init__(self, seq_node: SequenceNode, vvar_to_vvar: dict[int, int], project: angr.Project):
|
|
57
58
|
super().__init__(
|
|
58
59
|
handlers={
|
|
59
60
|
Block: self._handle_Block,
|
|
@@ -63,7 +64,7 @@ class SeqNodeRewriter(SequenceWalker):
|
|
|
63
64
|
)
|
|
64
65
|
|
|
65
66
|
self.vvar_to_vvar = vvar_to_vvar
|
|
66
|
-
self.engine = SimEngineDephiRewriting(
|
|
67
|
+
self.engine = SimEngineDephiRewriting(project, self.vvar_to_vvar)
|
|
67
68
|
|
|
68
69
|
self.output = self.walk(seq_node)
|
|
69
70
|
if self.output is None:
|
|
@@ -71,7 +72,7 @@ class SeqNodeRewriter(SequenceWalker):
|
|
|
71
72
|
self.output = seq_node
|
|
72
73
|
|
|
73
74
|
def _handle_Assignment(self, stmt: Assignment, **kwargs) -> Assignment: # pylint:disable=unused-argument
|
|
74
|
-
return self.engine.
|
|
75
|
+
return self.engine._handle_stmt_Assignment(stmt)
|
|
75
76
|
|
|
76
77
|
def _handle_Block(self, block: Block, **kwargs) -> Block | None: # pylint:disable=unused-argument
|
|
77
78
|
self.engine.out_block = None
|
|
@@ -117,7 +118,7 @@ class SeqNodeDephication(DephicationBase):
|
|
|
117
118
|
return collector.phi_to_src
|
|
118
119
|
|
|
119
120
|
def _rewrite_container(self) -> Any:
|
|
120
|
-
rewriter = SeqNodeRewriter(self._seq_node, self.vvar_to_vvar_mapping, self.project
|
|
121
|
+
rewriter = SeqNodeRewriter(self._seq_node, self.vvar_to_vvar_mapping, self.project)
|
|
121
122
|
return rewriter.output
|
|
122
123
|
|
|
123
124
|
|
|
@@ -23,15 +23,15 @@ class GraphRegion:
|
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
__slots__ = (
|
|
26
|
-
"head",
|
|
27
|
-
"graph",
|
|
28
|
-
"successors",
|
|
29
|
-
"graph_with_successors",
|
|
30
|
-
"cyclic",
|
|
31
|
-
"full_graph",
|
|
32
|
-
"cyclic_ancestor",
|
|
33
26
|
"_node_to_replaced_regions",
|
|
34
27
|
"_replaced_regions",
|
|
28
|
+
"cyclic",
|
|
29
|
+
"cyclic_ancestor",
|
|
30
|
+
"full_graph",
|
|
31
|
+
"graph",
|
|
32
|
+
"graph_with_successors",
|
|
33
|
+
"head",
|
|
34
|
+
"successors",
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def __init__(
|
|
@@ -74,7 +74,7 @@ class GraphRegion:
|
|
|
74
74
|
if addrs:
|
|
75
75
|
s = f": {min(addrs):#x}-{max(addrs):#x}"
|
|
76
76
|
|
|
77
|
-
return "<GraphRegion
|
|
77
|
+
return f"<GraphRegion {self.head!r} of {self.graph.number_of_nodes()} nodes{s}>"
|
|
78
78
|
|
|
79
79
|
def copy(self) -> GraphRegion:
|
|
80
80
|
return GraphRegion(
|
|
@@ -107,37 +107,37 @@ def register_optimization_pass(opt_pass, *, presets: list[str | DecompilationPre
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
__all__ = (
|
|
110
|
-
"
|
|
111
|
-
"
|
|
110
|
+
"ALL_OPTIMIZATION_PASSES",
|
|
111
|
+
"CONDENSING_OPTS",
|
|
112
|
+
"DUPLICATING_OPTS",
|
|
112
113
|
"BasePointerSaveSimplifier",
|
|
114
|
+
"CallStatementRewriter",
|
|
115
|
+
"CodeMotionOptimization",
|
|
116
|
+
"ConstPropOptReverter",
|
|
117
|
+
"ConstantDereferencesSimplifier",
|
|
118
|
+
"CrossJumpReverter",
|
|
119
|
+
"DeadblockRemover",
|
|
120
|
+
"DivSimplifier",
|
|
121
|
+
"DuplicationReverter",
|
|
113
122
|
"ExprOpSwapper",
|
|
114
|
-
"
|
|
123
|
+
"FlipBooleanCmp",
|
|
115
124
|
"ITEExprConverter",
|
|
125
|
+
"ITERegionConverter",
|
|
126
|
+
"InlinedStringTransformationSimplifier",
|
|
116
127
|
"LoweredSwitchSimplifier",
|
|
117
|
-
"DivSimplifier",
|
|
118
128
|
"ModSimplifier",
|
|
119
|
-
"
|
|
120
|
-
"ReturnDuplicatorHigh",
|
|
121
|
-
"ConstantDereferencesSimplifier",
|
|
129
|
+
"OptimizationPassStage",
|
|
122
130
|
"RegisterSaveAreaSimplifier",
|
|
123
131
|
"RetAddrSaveSimplifier",
|
|
124
|
-
"X86GccGetPcSimplifier",
|
|
125
|
-
"FlipBooleanCmp",
|
|
126
132
|
"ReturnDeduplicator",
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
133
|
+
"ReturnDuplicatorHigh",
|
|
134
|
+
"ReturnDuplicatorLow",
|
|
135
|
+
"StackCanarySimplifier",
|
|
130
136
|
"SwitchDefaultCaseDuplicator",
|
|
131
137
|
"SwitchReusedEntryRewriter",
|
|
132
|
-
"DeadblockRemover",
|
|
133
|
-
"InlinedStringTransformationSimplifier",
|
|
134
|
-
"ConstPropOptReverter",
|
|
135
|
-
"CallStatementRewriter",
|
|
136
|
-
"DuplicationReverter",
|
|
137
138
|
"TagSlicer",
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"CONDENSING_OPTS",
|
|
139
|
+
"WinStackCanarySimplifier",
|
|
140
|
+
"X86GccGetPcSimplifier",
|
|
141
141
|
"get_optimization_passes",
|
|
142
142
|
"register_optimization_pass",
|
|
143
143
|
)
|
|
@@ -50,8 +50,7 @@ class DeadblockRemover(OptimizationPass):
|
|
|
50
50
|
to_remove = {
|
|
51
51
|
blk
|
|
52
52
|
for blk in self._graph.nodes()
|
|
53
|
-
if blk.addr != self._func.addr
|
|
54
|
-
and self._graph.in_degree(blk) == 0
|
|
53
|
+
if (blk.addr != self._func.addr and self._graph.in_degree(blk) == 0)
|
|
55
54
|
or claripy.is_false(cond_proc.reaching_conditions[blk])
|
|
56
55
|
}
|
|
57
56
|
|