angr 9.2.130__py3-none-manylinux2014_aarch64.whl → 9.2.132__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 +1 -1
- angr/analyses/analysis.py +6 -2
- angr/analyses/cfg/cfg_emulated.py +5 -5
- angr/analyses/cfg/cfg_fast.py +2 -2
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +139 -94
- angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
- angr/analyses/ddg.py +14 -11
- angr/analyses/decompiler/ail_simplifier.py +3 -2
- angr/analyses/decompiler/block_simplifier.py +10 -21
- angr/analyses/decompiler/clinic.py +361 -8
- angr/analyses/decompiler/condition_processor.py +12 -10
- angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
- angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
- angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
- angr/analyses/decompiler/optimization_passes/__init__.py +0 -3
- angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
- angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
- angr/analyses/decompiler/optimization_passes/engine_base.py +261 -83
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +173 -35
- angr/analyses/decompiler/optimization_passes/mod_simplifier.py +5 -2
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +39 -19
- angr/analyses/decompiler/peephole_optimizations/__init__.py +5 -1
- angr/analyses/decompiler/peephole_optimizations/a_mul_const_sub_a.py +34 -0
- angr/analyses/decompiler/peephole_optimizations/a_shl_const_sub_a.py +3 -1
- angr/analyses/decompiler/peephole_optimizations/bswap.py +10 -6
- angr/analyses/decompiler/peephole_optimizations/eager_eval.py +100 -19
- angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +17 -0
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_conversions.py +42 -3
- angr/analyses/decompiler/peephole_optimizations/remove_redundant_shifts.py +4 -2
- angr/analyses/decompiler/peephole_optimizations/rol_ror.py +37 -10
- angr/analyses/decompiler/peephole_optimizations/shl_to_mul.py +25 -0
- angr/analyses/decompiler/peephole_optimizations/utils.py +18 -0
- angr/analyses/decompiler/presets/fast.py +0 -2
- angr/analyses/decompiler/presets/full.py +0 -2
- angr/analyses/decompiler/ssailification/rewriting.py +1 -2
- angr/analyses/decompiler/ssailification/rewriting_engine.py +140 -57
- 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/c.py +79 -16
- angr/analyses/decompiler/structuring/phoenix.py +40 -14
- angr/analyses/decompiler/structuring/structurer_nodes.py +9 -0
- angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
- angr/analyses/deobfuscator/string_obf_finder.py +2 -2
- angr/analyses/init_finder.py +47 -22
- angr/analyses/propagator/engine_base.py +21 -14
- angr/analyses/propagator/engine_vex.py +149 -179
- angr/analyses/propagator/propagator.py +10 -28
- angr/analyses/propagator/top_checker_mixin.py +211 -5
- angr/analyses/propagator/vex_vars.py +1 -1
- 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/rd_state.py +37 -32
- angr/analyses/s_propagator.py +38 -5
- angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
- angr/analyses/typehoon/simple_solver.py +16 -7
- angr/analyses/typehoon/translator.py +8 -0
- angr/analyses/typehoon/typeconsts.py +10 -2
- angr/analyses/typehoon/typehoon.py +4 -1
- angr/analyses/typehoon/typevars.py +9 -7
- angr/analyses/variable_recovery/engine_ail.py +296 -256
- angr/analyses/variable_recovery/engine_base.py +137 -116
- 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 +32 -33
- angr/analyses/variable_recovery/variable_recovery_fast.py +2 -2
- angr/analyses/xrefs.py +46 -19
- angr/annocfg.py +19 -14
- angr/block.py +4 -9
- angr/calling_conventions.py +1 -1
- angr/engines/engine.py +30 -14
- angr/engines/light/__init__.py +11 -3
- angr/engines/light/engine.py +1003 -1185
- angr/engines/pcode/cc.py +2 -0
- angr/engines/successors.py +13 -9
- angr/engines/vex/claripy/datalayer.py +1 -1
- angr/engines/vex/claripy/irop.py +14 -3
- angr/engines/vex/light/slicing.py +2 -2
- angr/exploration_techniques/__init__.py +1 -124
- 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 +4 -7
- 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/knowledge_plugins/key_definitions/atoms.py +2 -2
- angr/knowledge_plugins/key_definitions/live_definitions.py +16 -13
- angr/knowledge_plugins/propagations/states.py +13 -8
- angr/knowledge_plugins/variables/variable_manager.py +23 -9
- angr/sim_manager.py +1 -3
- angr/sim_state.py +39 -41
- angr/sim_type.py +5 -0
- angr/sim_variable.py +29 -28
- angr/utils/bits.py +17 -0
- angr/utils/formatting.py +4 -1
- angr/utils/orderedset.py +4 -1
- angr/utils/ssa/__init__.py +21 -3
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/METADATA +6 -6
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/RECORD +124 -123
- angr/analyses/decompiler/optimization_passes/multi_simplifier.py +0 -223
- angr/analyses/propagator/engine_ail.py +0 -1562
- angr/storage/memory_mixins/__init__.pyi +0 -48
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/LICENSE +0 -0
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/WHEEL +0 -0
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/entry_points.txt +0 -0
- {angr-9.2.130.dist-info → angr-9.2.132.dist-info}/top_level.txt +0 -0
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
import logging
|
|
3
|
-
|
|
4
|
-
from ailment import Expr
|
|
5
|
-
from unique_log_filter import UniqueLogFilter
|
|
6
|
-
|
|
7
|
-
from .engine_base import SimplifierAILEngine, SimplifierAILState
|
|
8
|
-
from .optimization_pass import OptimizationPass, OptimizationPassStage
|
|
9
|
-
|
|
10
|
-
_l = logging.getLogger(name=__name__)
|
|
11
|
-
_l.addFilter(UniqueLogFilter())
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class MultiSimplifierAILEngine(SimplifierAILEngine):
|
|
15
|
-
"""
|
|
16
|
-
An AIL pass for the multi simplifier
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def _ail_handle_Add(self, expr):
|
|
20
|
-
operand_0 = self._expr(expr.operands[0])
|
|
21
|
-
operand_1 = self._expr(expr.operands[1])
|
|
22
|
-
|
|
23
|
-
# x + x = 2*x
|
|
24
|
-
if (
|
|
25
|
-
type(operand_0) in [Expr.Convert, Expr.VirtualVariable]
|
|
26
|
-
and isinstance(operand_1, (Expr.Convert, Expr.VirtualVariable))
|
|
27
|
-
and operand_0 == operand_1
|
|
28
|
-
):
|
|
29
|
-
count = Expr.Const(expr.idx, None, 2, operand_1.bits)
|
|
30
|
-
return Expr.BinaryOp(expr.idx, "Mul", [operand_1, count], expr.signed, **expr.tags)
|
|
31
|
-
# 2*x + x = 3*x
|
|
32
|
-
if Expr.BinaryOp in [type(operand_0), type(operand_1)]:
|
|
33
|
-
if (
|
|
34
|
-
isinstance(operand_1, Expr.BinaryOp)
|
|
35
|
-
and operand_1.op == "Mul"
|
|
36
|
-
and (
|
|
37
|
-
not isinstance(operand_0, Expr.BinaryOp)
|
|
38
|
-
or (isinstance(operand_0, Expr.BinaryOp) and operand_0.op != "Mul")
|
|
39
|
-
)
|
|
40
|
-
):
|
|
41
|
-
x0 = operand_0
|
|
42
|
-
x1_index = 0 if isinstance(operand_1.operands[1], Expr.Const) else 1
|
|
43
|
-
x1 = operand_1.operands[x1_index]
|
|
44
|
-
const_x1 = operand_1.operands[1 - x1_index]
|
|
45
|
-
if x0 == x1:
|
|
46
|
-
new_const = Expr.Const(const_x1.idx, None, const_x1.value + 1, const_x1.bits)
|
|
47
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x0, new_const], expr.signed, **expr.tags)
|
|
48
|
-
elif (
|
|
49
|
-
isinstance(operand_0, Expr.BinaryOp)
|
|
50
|
-
and operand_0.op == "Mul"
|
|
51
|
-
and (
|
|
52
|
-
not isinstance(operand_1, Expr.BinaryOp)
|
|
53
|
-
or (isinstance(operand_1, Expr.BinaryOp) and operand_1.op != "Mul")
|
|
54
|
-
)
|
|
55
|
-
):
|
|
56
|
-
x1 = operand_1
|
|
57
|
-
x0_index = 0 if isinstance(operand_0.operands[1], Expr.Const) else 1
|
|
58
|
-
x0 = operand_0.operands[x0_index]
|
|
59
|
-
const_x0 = operand_0.operands[1 - x0_index]
|
|
60
|
-
if x0 == x1:
|
|
61
|
-
new_const = Expr.Const(const_x0.idx, None, const_x0.value + 1, const_x0.bits)
|
|
62
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x1, new_const], expr.signed, **expr.tags)
|
|
63
|
-
# 2*x + 3*x = 5*x
|
|
64
|
-
elif (
|
|
65
|
-
isinstance(operand_0, Expr.BinaryOp)
|
|
66
|
-
and isinstance(operand_1, Expr.BinaryOp)
|
|
67
|
-
and operand_0.op == "Mul"
|
|
68
|
-
and operand_1.op == "Mul"
|
|
69
|
-
):
|
|
70
|
-
if Expr.Const in [type(operand_0.operands[0]), type(operand_0.operands[1])] and Expr.Const in [
|
|
71
|
-
type(operand_1.operands[0]),
|
|
72
|
-
type(operand_1.operands[1]),
|
|
73
|
-
]:
|
|
74
|
-
x0_index = 0 if isinstance(operand_0.operands[1], Expr.Const) else 1
|
|
75
|
-
x0 = operand_0.operands[x0_index]
|
|
76
|
-
const_x0 = operand_0.operands[1 - x0_index]
|
|
77
|
-
|
|
78
|
-
x1_index = 0 if isinstance(operand_1.operands[1], Expr.Const) else 1
|
|
79
|
-
x1 = operand_1.operands[x1_index]
|
|
80
|
-
const_x1 = operand_1.operands[1 - x1_index]
|
|
81
|
-
if x0 == x1:
|
|
82
|
-
new_const = Expr.Const(const_x1.idx, None, const_x1.value + const_x0.value, const_x1.bits)
|
|
83
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x0, new_const], expr.signed, **expr.tags)
|
|
84
|
-
|
|
85
|
-
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
|
|
86
|
-
return Expr.BinaryOp(expr.idx, "Add", [operand_0, operand_1], expr.signed, **expr.tags)
|
|
87
|
-
return expr
|
|
88
|
-
|
|
89
|
-
def _ail_handle_Sub(self, expr):
|
|
90
|
-
operand_0 = self._expr(expr.operands[0])
|
|
91
|
-
operand_1 = self._expr(expr.operands[1])
|
|
92
|
-
|
|
93
|
-
# x + x = 2*x
|
|
94
|
-
if (
|
|
95
|
-
type(operand_0) in [Expr.Convert, Expr.VirtualVariable]
|
|
96
|
-
and isinstance(operand_1, (Expr.Convert, Expr.VirtualVariable))
|
|
97
|
-
and operand_0 == operand_1
|
|
98
|
-
):
|
|
99
|
-
count = Expr.Const(expr.idx, None, 0, 8)
|
|
100
|
-
return Expr.BinaryOp(expr.idx, "Mul", [operand_1, count], expr.signed, **expr.tags)
|
|
101
|
-
|
|
102
|
-
# 2*x - x = x
|
|
103
|
-
if Expr.BinaryOp in [type(operand_0), type(operand_1)]:
|
|
104
|
-
if (
|
|
105
|
-
isinstance(operand_1, Expr.BinaryOp)
|
|
106
|
-
and operand_1.op == "Mul"
|
|
107
|
-
and (
|
|
108
|
-
not isinstance(operand_0, Expr.BinaryOp)
|
|
109
|
-
or (isinstance(operand_0, Expr.BinaryOp) and operand_0.op != "Mul")
|
|
110
|
-
)
|
|
111
|
-
):
|
|
112
|
-
x0 = operand_0
|
|
113
|
-
x1_index = 0 if isinstance(operand_1.operands[1], Expr.Const) else 1
|
|
114
|
-
x1 = operand_1.operands[x1_index]
|
|
115
|
-
const_x1 = operand_1.operands[1 - x1_index]
|
|
116
|
-
if x0 == x1:
|
|
117
|
-
new_const = Expr.Const(const_x1.idx, None, const_x1.value - 1, const_x1.bits)
|
|
118
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x0, new_const], expr.signed, **expr.tags)
|
|
119
|
-
elif (
|
|
120
|
-
isinstance(operand_0, Expr.BinaryOp)
|
|
121
|
-
and operand_0.op == "Mul"
|
|
122
|
-
and (
|
|
123
|
-
not isinstance(operand_1, Expr.BinaryOp)
|
|
124
|
-
or (isinstance(operand_1, Expr.BinaryOp) and operand_1.op != "Mul")
|
|
125
|
-
)
|
|
126
|
-
):
|
|
127
|
-
x1 = operand_1
|
|
128
|
-
x0_index = 0 if isinstance(operand_0.operands[1], Expr.Const) else 1
|
|
129
|
-
x0 = operand_0.operands[x0_index]
|
|
130
|
-
const_x0 = operand_0.operands[1 - x0_index]
|
|
131
|
-
if x0 == x1:
|
|
132
|
-
new_const = Expr.Const(const_x0.idx, None, const_x0.value - 1, const_x0.bits)
|
|
133
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x1, new_const], expr.signed, **expr.tags)
|
|
134
|
-
# 3*x - 2*x = x
|
|
135
|
-
elif (
|
|
136
|
-
isinstance(operand_0, Expr.BinaryOp)
|
|
137
|
-
and isinstance(operand_1, Expr.BinaryOp)
|
|
138
|
-
and operand_0.op == "Mul"
|
|
139
|
-
and operand_1.op == "Mul"
|
|
140
|
-
):
|
|
141
|
-
if Expr.Const in [type(operand_0.operands[0]), type(operand_0.operands[1])] and Expr.Const in [
|
|
142
|
-
type(operand_1.operands[0]),
|
|
143
|
-
type(operand_1.operands[1]),
|
|
144
|
-
]:
|
|
145
|
-
x0_index = 0 if isinstance(operand_0.operands[1], Expr.Const) else 1
|
|
146
|
-
x0 = operand_0.operands[x0_index]
|
|
147
|
-
const_x0 = operand_0.operands[1 - x0_index]
|
|
148
|
-
|
|
149
|
-
x1_index = 0 if isinstance(operand_1.operands[1], Expr.Const) else 1
|
|
150
|
-
x1 = operand_1.operands[x1_index]
|
|
151
|
-
const_x1 = operand_1.operands[1 - x1_index]
|
|
152
|
-
if x0 == x1:
|
|
153
|
-
new_const = Expr.Const(const_x1.idx, None, const_x0.value - const_x1.value, const_x1.bits)
|
|
154
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x0, new_const], expr.signed, **expr.tags)
|
|
155
|
-
|
|
156
|
-
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
|
|
157
|
-
return Expr.BinaryOp(expr.idx, "Sub", [operand_0, operand_1], expr.signed, **expr.tags)
|
|
158
|
-
return expr
|
|
159
|
-
|
|
160
|
-
def _ail_handle_Shl(self, expr):
|
|
161
|
-
operand_0 = self._expr(expr.operands[0])
|
|
162
|
-
operand_1 = self._expr(expr.operands[1])
|
|
163
|
-
|
|
164
|
-
if isinstance(operand_1, Expr.Const):
|
|
165
|
-
new_operand = Expr.Const(operand_1.idx, None, 2**operand_1.value, operand_0.bits)
|
|
166
|
-
return Expr.BinaryOp(expr.idx, "Mul", [operand_0, new_operand], expr.signed, **expr.tags)
|
|
167
|
-
|
|
168
|
-
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
|
|
169
|
-
return Expr.BinaryOp(expr.idx, "Shl", [operand_0, operand_1], expr.signed, **expr.tags)
|
|
170
|
-
return expr
|
|
171
|
-
|
|
172
|
-
def _ail_handle_Mul(self, expr):
|
|
173
|
-
operand_0 = self._expr(expr.operands[0])
|
|
174
|
-
operand_1 = self._expr(expr.operands[1])
|
|
175
|
-
|
|
176
|
-
if Expr.Const in [type(operand_0), type(operand_1)] and Expr.BinaryOp in [type(operand_0), type(operand_1)]:
|
|
177
|
-
const_, x0 = (operand_0, operand_1) if isinstance(operand_0, Expr.Const) else (operand_1, operand_0)
|
|
178
|
-
if x0.op == "Mul" and Expr.Const in [type(x0.operands[0]), type(x0.operands[1])]:
|
|
179
|
-
if isinstance(x0.operands[0], Expr.Const):
|
|
180
|
-
const_x0, x = x0.operands[0], x0.operands[1]
|
|
181
|
-
else:
|
|
182
|
-
const_x0, x = x0.operands[1], x0.operands[0]
|
|
183
|
-
new_const = Expr.Const(const_.idx, None, const_.value * const_x0.value, const_.bits)
|
|
184
|
-
return Expr.BinaryOp(expr.idx, "Mul", [x, new_const], expr.signed, **expr.tags)
|
|
185
|
-
|
|
186
|
-
if (operand_0, operand_1) != (expr.operands[0], expr.operands[1]):
|
|
187
|
-
return Expr.BinaryOp(expr.idx, "Mul", [operand_0, operand_1], expr.signed, **expr.tags)
|
|
188
|
-
return expr
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
class MultiSimplifier(OptimizationPass):
|
|
192
|
-
"""
|
|
193
|
-
Implements several different arithmetic optimizations.
|
|
194
|
-
"""
|
|
195
|
-
|
|
196
|
-
ARCHES = ["X86", "AMD64"]
|
|
197
|
-
PLATFORMS = ["linux", "windows"]
|
|
198
|
-
STAGE = OptimizationPassStage.AFTER_GLOBAL_SIMPLIFICATION
|
|
199
|
-
NAME = "Simplify various arithmetic expressions"
|
|
200
|
-
DESCRIPTION = __doc__.strip()
|
|
201
|
-
|
|
202
|
-
def __init__(self, func, **kwargs):
|
|
203
|
-
super().__init__(func, **kwargs)
|
|
204
|
-
|
|
205
|
-
self.state = SimplifierAILState(self.project.arch)
|
|
206
|
-
self.engine = MultiSimplifierAILEngine()
|
|
207
|
-
|
|
208
|
-
self.analyze()
|
|
209
|
-
|
|
210
|
-
def _check(self):
|
|
211
|
-
return True, None
|
|
212
|
-
|
|
213
|
-
def _analyze(self, cache=None):
|
|
214
|
-
for block in list(self._graph.nodes()):
|
|
215
|
-
new_block = block
|
|
216
|
-
old_block = None
|
|
217
|
-
|
|
218
|
-
while new_block != old_block:
|
|
219
|
-
old_block = new_block
|
|
220
|
-
new_block = self.engine.process(state=self.state.copy(), block=old_block.copy())
|
|
221
|
-
_l.debug("new block: %s", new_block.statements)
|
|
222
|
-
|
|
223
|
-
self._update_block(block, new_block)
|