angr 9.2.121__py3-none-manylinux2014_aarch64.whl → 9.2.123__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/calling_convention.py +6 -1
- angr/analyses/decompiler/ail_simplifier.py +22 -323
- angr/analyses/decompiler/callsite_maker.py +11 -1
- angr/analyses/decompiler/clinic.py +3 -2
- angr/analyses/decompiler/dephication/rewriting_engine.py +1 -1
- angr/analyses/decompiler/expression_narrower.py +201 -5
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +11 -7
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +10 -1
- angr/analyses/decompiler/peephole_optimizations/const_mull_a_shift.py +73 -42
- angr/analyses/decompiler/region_simplifiers/expr_folding.py +4 -0
- angr/analyses/decompiler/sequence_walker.py +20 -4
- angr/analyses/s_propagator.py +10 -6
- angr/calling_conventions.py +2 -2
- angr/engines/light/engine.py +12 -2
- angr/engines/soot/expressions/instanceOf.py +4 -1
- angr/engines/successors.py +1 -1
- angr/engines/vex/heavy/concretizers.py +47 -47
- angr/engines/vex/heavy/dirty.py +4 -4
- angr/procedures/java_lang/getsimplename.py +4 -1
- angr/procedures/linux_kernel/iovec.py +5 -2
- angr/sim_type.py +56 -19
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/METADATA +7 -6
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/RECORD +28 -28
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/LICENSE +0 -0
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/WHEEL +0 -0
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/entry_points.txt +0 -0
- {angr-9.2.121.dist-info → angr-9.2.123.dist-info}/top_level.txt +0 -0
|
@@ -23,7 +23,7 @@ def concretize_2xm1(state, args):
|
|
|
23
23
|
# 2xm1(x) = 2 ** x - 1. Concretize 2**x part alone since only that cannot be modelled in Z3.
|
|
24
24
|
arg_x = state.solver.eval(args[1])
|
|
25
25
|
if -1 <= arg_x <= 1:
|
|
26
|
-
return
|
|
26
|
+
return claripy.FPV(math.pow(2, arg_x) - 1, claripy.FSORT_DOUBLE)
|
|
27
27
|
|
|
28
28
|
# If x is outside range [-1.0, 1.0], result is undefined. We return argument itself as observed on an Intel CPU.
|
|
29
29
|
return args[1]
|
|
@@ -31,26 +31,26 @@ def concretize_2xm1(state, args):
|
|
|
31
31
|
|
|
32
32
|
def concretize_abs_float64(state, args):
|
|
33
33
|
arg_val = state.solver.eval(args[0])
|
|
34
|
-
return
|
|
34
|
+
return claripy.FPV(abs(arg_val), args[0].sort)
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def concretize_add_float64(state, args):
|
|
38
38
|
arg0 = state.solver.eval(args[1])
|
|
39
39
|
arg1 = state.solver.eval(args[2])
|
|
40
|
-
return
|
|
40
|
+
return claripy.FPV(arg0 + arg1, claripy.FSORT_DOUBLE)
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def concretize_add32f04(state, args):
|
|
44
44
|
fp_arg0 = state.solver.eval(args[0][31:0].raw_to_fp())
|
|
45
45
|
fp_arg1 = state.solver.eval(args[1][31:0].raw_to_fp())
|
|
46
|
-
result =
|
|
46
|
+
result = claripy.FPV(fp_arg0 + fp_arg1, claripy.FSORT_FLOAT).raw_to_bv()
|
|
47
47
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def concretize_add64f02(state, args):
|
|
51
51
|
fp_arg0 = state.solver.eval(args[0][63:0].raw_to_fp())
|
|
52
52
|
fp_arg1 = state.solver.eval(args[1][63:0].raw_to_fp())
|
|
53
|
-
result =
|
|
53
|
+
result = claripy.FPV(fp_arg0 + fp_arg1, claripy.FSORT_DOUBLE).raw_to_bv()
|
|
54
54
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
55
55
|
|
|
56
56
|
|
|
@@ -71,18 +71,18 @@ def concretize_divf64(state, args):
|
|
|
71
71
|
arg1 = state.solver.eval(args[1])
|
|
72
72
|
arg2 = state.solver.eval(args[2])
|
|
73
73
|
if arg2 == 0:
|
|
74
|
-
return
|
|
74
|
+
return claripy.FPV(math.inf, args[1].sort)
|
|
75
75
|
|
|
76
|
-
return
|
|
76
|
+
return claripy.FPV(arg1 / arg2, args[1].sort)
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
def concretize_div32f04(state, args):
|
|
80
80
|
fp_arg0 = state.solver.eval(args[0][31:0].raw_to_fp())
|
|
81
81
|
fp_arg1 = state.solver.eval(args[1][31:0].raw_to_fp())
|
|
82
82
|
if fp_arg1 == 0:
|
|
83
|
-
result =
|
|
83
|
+
result = claripy.FPV(math.inf, claripy.FSORT_FLOAT).raw_to_bv()
|
|
84
84
|
else:
|
|
85
|
-
result =
|
|
85
|
+
result = claripy.FPV(fp_arg0 / fp_arg1, claripy.FSORT_FLOAT).raw_to_bv()
|
|
86
86
|
|
|
87
87
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
88
88
|
|
|
@@ -91,21 +91,21 @@ def concretize_div64f02(state, args):
|
|
|
91
91
|
fp_arg0 = state.solver.eval(args[0][63:0].raw_to_fp())
|
|
92
92
|
fp_arg1 = state.solver.eval(args[1][63:0].raw_to_fp())
|
|
93
93
|
if fp_arg1 == 0:
|
|
94
|
-
result =
|
|
94
|
+
result = claripy.FPV(math.inf, claripy.FSORT_DOUBLE).raw_to_bv()
|
|
95
95
|
else:
|
|
96
|
-
result =
|
|
96
|
+
result = claripy.FPV(fp_arg0 / fp_arg1, claripy.FSORT_DOUBLE).raw_to_bv()
|
|
97
97
|
|
|
98
98
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
def concretize_float32_to_float64(state, args):
|
|
102
102
|
arg0 = state.solver.eval(args[0])
|
|
103
|
-
return
|
|
103
|
+
return claripy.FPV(arg0, claripy.FSORT_DOUBLE)
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
def concretize_float64_to_float32(state, args):
|
|
107
107
|
arg = state.solver.eval(args[1])
|
|
108
|
-
return
|
|
108
|
+
return claripy.FPV(arg, claripy.FSORT_FLOAT)
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
def concretize_float64_to_int64s(state, args):
|
|
@@ -127,20 +127,20 @@ def concretize_int64s_to_float64(state, args):
|
|
|
127
127
|
def concretize_mulf64(state, args):
|
|
128
128
|
arg1 = state.solver.eval(args[1])
|
|
129
129
|
arg2 = state.solver.eval(args[2])
|
|
130
|
-
return
|
|
130
|
+
return claripy.FPV(arg1 / arg2, args[1].sort)
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
def concretize_mul32f04(state, args):
|
|
134
134
|
fp_arg0 = state.solver.eval(args[0][31:0].raw_to_fp())
|
|
135
135
|
fp_arg1 = state.solver.eval(args[1][31:0].raw_to_fp())
|
|
136
|
-
result =
|
|
136
|
+
result = claripy.FPV(fp_arg0 * fp_arg1, claripy.FSORT_FLOAT).raw_to_bv()
|
|
137
137
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
def concretize_mul64f02(state, args):
|
|
141
141
|
fp_arg0 = state.solver.eval(args[0][63:0].raw_to_fp())
|
|
142
142
|
fp_arg1 = state.solver.eval(args[1][63:0].raw_to_fp())
|
|
143
|
-
result =
|
|
143
|
+
result = claripy.FPV(fp_arg0 * fp_arg1, claripy.FSORT_DOUBLE).raw_to_bv()
|
|
144
144
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
145
145
|
|
|
146
146
|
|
|
@@ -149,24 +149,24 @@ def concretize_fscale(state, args):
|
|
|
149
149
|
arg_x = state.solver.eval(args[1])
|
|
150
150
|
arg_y = math.floor(state.solver.eval(args[2]))
|
|
151
151
|
if math.isnan(arg_x) or math.isnan(arg_y):
|
|
152
|
-
return
|
|
152
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
153
153
|
|
|
154
154
|
if abs(arg_x) == math.inf and arg_y == -1 * math.inf:
|
|
155
|
-
return
|
|
155
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
156
156
|
|
|
157
157
|
if arg_x == 0.0 and arg_y == math.inf:
|
|
158
|
-
return
|
|
158
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
159
159
|
|
|
160
|
-
return
|
|
160
|
+
return claripy.FPV(arg_x * math.pow(2, arg_y), claripy.FSORT_DOUBLE)
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
def concretize_fsqrt(state, args):
|
|
164
164
|
# Concretize floating point square root. Z3 does support square root but unsure if that includes floating point
|
|
165
165
|
arg_1 = state.solver.eval(args[1])
|
|
166
166
|
if arg_1 < 0 or math.isnan(arg_1):
|
|
167
|
-
return
|
|
167
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
168
168
|
|
|
169
|
-
return
|
|
169
|
+
return claripy.FPV(math.sqrt(arg_1), claripy.FSORT_DOUBLE)
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
def concretize_prem(state, args):
|
|
@@ -175,7 +175,7 @@ def concretize_prem(state, args):
|
|
|
175
175
|
dividend = state.solver.eval(args[1])
|
|
176
176
|
divisor = state.solver.eval(args[2])
|
|
177
177
|
if math.isnan(dividend) or math.isnan(divisor) or abs(dividend) == math.inf or divisor == 0.0:
|
|
178
|
-
return
|
|
178
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
179
179
|
|
|
180
180
|
if abs(divisor) == math.inf or dividend == 0.0:
|
|
181
181
|
return args[1]
|
|
@@ -194,9 +194,9 @@ def concretize_prem(state, args):
|
|
|
194
194
|
|
|
195
195
|
if result == 0.0 and math.copysign(1.0, dividend) < 0:
|
|
196
196
|
# According to Intel manual, if result is 0, its sign should be same as that of dividend.
|
|
197
|
-
return
|
|
197
|
+
return claripy.FPV(-0.0, claripy.FSORT_DOUBLE)
|
|
198
198
|
|
|
199
|
-
return
|
|
199
|
+
return claripy.FPV(result, claripy.FSORT_DOUBLE)
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
def concretize_prem_flags(state, args):
|
|
@@ -241,20 +241,20 @@ def concretize_prem_flags(state, args):
|
|
|
241
241
|
|
|
242
242
|
|
|
243
243
|
def concretize_reinterp_float64_as_int64(state, args):
|
|
244
|
-
return
|
|
244
|
+
return claripy.FPV(state.solver.eval(args[0]), args[0].sort).raw_to_bv()
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
def concretize_sub32f04(state, args):
|
|
248
248
|
fp_arg0 = state.solver.eval(args[0][31:0].raw_to_fp())
|
|
249
249
|
fp_arg1 = state.solver.eval(args[1][31:0].raw_to_fp())
|
|
250
|
-
result =
|
|
250
|
+
result = claripy.FPV(fp_arg0 - fp_arg1, claripy.FSORT_FLOAT).raw_to_bv()
|
|
251
251
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
252
252
|
|
|
253
253
|
|
|
254
254
|
def concretize_sub64f02(state, args):
|
|
255
255
|
fp_arg0 = state.solver.eval(args[0][63:0].raw_to_fp())
|
|
256
256
|
fp_arg1 = state.solver.eval(args[1][63:0].raw_to_fp())
|
|
257
|
-
result =
|
|
257
|
+
result = claripy.FPV(fp_arg0 - fp_arg1, claripy.FSORT_DOUBLE).raw_to_bv()
|
|
258
258
|
return claripy.Concat(args[0][(args[0].length - 1) : result.size()], result)
|
|
259
259
|
|
|
260
260
|
|
|
@@ -265,18 +265,18 @@ def concretize_trig_cos(state, args):
|
|
|
265
265
|
abs_arg_x = abs(arg_x)
|
|
266
266
|
|
|
267
267
|
if math.isnan(abs_arg_x):
|
|
268
|
-
return
|
|
268
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
269
269
|
|
|
270
270
|
if abs_arg_x == math.inf:
|
|
271
271
|
# Floating-point invalid-operation exception
|
|
272
|
-
return
|
|
272
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
273
273
|
|
|
274
274
|
if abs_arg_x > pow(2, 63):
|
|
275
275
|
# Intel manual says argument must be in range [-2^63, 2^63]. Otherwise, floating-point invalid-operation
|
|
276
276
|
# exception: leave value changed
|
|
277
277
|
return args[1]
|
|
278
278
|
|
|
279
|
-
return
|
|
279
|
+
return claripy.FPV(math.cos(arg_x), claripy.FSORT_DOUBLE)
|
|
280
280
|
|
|
281
281
|
|
|
282
282
|
def concretize_trig_sin(state, args):
|
|
@@ -286,18 +286,18 @@ def concretize_trig_sin(state, args):
|
|
|
286
286
|
abs_arg_x = abs(arg_x)
|
|
287
287
|
|
|
288
288
|
if math.isnan(abs_arg_x):
|
|
289
|
-
return
|
|
289
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
290
290
|
|
|
291
291
|
if abs_arg_x == math.inf:
|
|
292
292
|
# Floating-point invalid-operation exception
|
|
293
|
-
return
|
|
293
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
294
294
|
|
|
295
295
|
if abs_arg_x > pow(2, 63):
|
|
296
296
|
# Intel manual says argument must be in range [-2^63, 2^63]. Otherwise, floating-point invalid-operation
|
|
297
297
|
# exception: leave value changed
|
|
298
298
|
return args[1]
|
|
299
299
|
|
|
300
|
-
return
|
|
300
|
+
return claripy.FPV(math.sin(arg_x), claripy.FSORT_DOUBLE)
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
def concretize_trig_tan(state, args):
|
|
@@ -307,18 +307,18 @@ def concretize_trig_tan(state, args):
|
|
|
307
307
|
abs_arg_x = abs(arg_x)
|
|
308
308
|
|
|
309
309
|
if math.isnan(abs_arg_x):
|
|
310
|
-
return
|
|
310
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
311
311
|
|
|
312
312
|
if abs_arg_x == math.inf:
|
|
313
313
|
# Floating-point invalid-operation exception
|
|
314
|
-
return
|
|
314
|
+
return claripy.FPV(math.nan, claripy.FSORT_DOUBLE)
|
|
315
315
|
|
|
316
316
|
if abs_arg_x > pow(2, 63):
|
|
317
317
|
# Intel manual says argument must be in range [-2^63, 2^63]. Otherwise, floating-point invalid-operation
|
|
318
318
|
# exception: leave value changed
|
|
319
319
|
return args[1]
|
|
320
320
|
|
|
321
|
-
return
|
|
321
|
+
return claripy.FPV(math.tan(arg_x), claripy.FSORT_DOUBLE)
|
|
322
322
|
|
|
323
323
|
|
|
324
324
|
def concretize_yl2x(state, args):
|
|
@@ -330,35 +330,35 @@ def concretize_yl2x(state, args):
|
|
|
330
330
|
arg_y = state.solver.eval(args[1])
|
|
331
331
|
if arg_x < 0:
|
|
332
332
|
# TODO: Indicate floating-point invalid-operation exception
|
|
333
|
-
return
|
|
333
|
+
return claripy.FPV(arg_x, claripy.FSORT_DOUBLE)
|
|
334
334
|
|
|
335
335
|
if arg_x == 0:
|
|
336
336
|
if abs(arg_y) == math.inf:
|
|
337
|
-
return
|
|
337
|
+
return claripy.FPV(-1 * arg_y, claripy.FSORT_DOUBLE)
|
|
338
338
|
if arg_y == 0:
|
|
339
339
|
# TODO: Indicate floating-point invalid-operation exception
|
|
340
|
-
return
|
|
340
|
+
return claripy.FPV(arg_x, claripy.FSORT_DOUBLE)
|
|
341
341
|
# TODO: Indicate floating-point zero-division exception
|
|
342
|
-
return
|
|
342
|
+
return claripy.FPV(arg_x, claripy.FSORT_DOUBLE)
|
|
343
343
|
|
|
344
344
|
if arg_x == 1:
|
|
345
345
|
if abs(arg_y) == math.inf:
|
|
346
346
|
# TODO: Indicate floating-point invalid-operation exception
|
|
347
|
-
return
|
|
347
|
+
return claripy.FPV(arg_x, claripy.FSORT_DOUBLE)
|
|
348
348
|
|
|
349
349
|
# TODO: How to distinguish between +0 and -0?
|
|
350
|
-
return
|
|
350
|
+
return claripy.FPV(0, claripy.FSORT_DOUBLE)
|
|
351
351
|
|
|
352
352
|
if arg_x == math.inf:
|
|
353
353
|
if arg_y == 0:
|
|
354
354
|
# TODO: Indicate floating-point invalid-operation exception
|
|
355
|
-
return
|
|
355
|
+
return claripy.FPV(arg_x, claripy.FSORT_DOUBLE)
|
|
356
356
|
if arg_y < 0:
|
|
357
|
-
return
|
|
357
|
+
return claripy.FPV(-1 * math.inf, claripy.FSORT_DOUBLE)
|
|
358
358
|
|
|
359
|
-
return
|
|
359
|
+
return claripy.FPV(math.inf, claripy.FSORT_DOUBLE)
|
|
360
360
|
|
|
361
|
-
return
|
|
361
|
+
return claripy.FPV(arg_y * math.log2(arg_x), claripy.FSORT_DOUBLE)
|
|
362
362
|
|
|
363
363
|
|
|
364
364
|
concretizers = {
|
angr/engines/vex/heavy/dirty.py
CHANGED
|
@@ -19,12 +19,12 @@ l = logging.getLogger(name=__name__)
|
|
|
19
19
|
# http://www-inteng.fnal.gov/Integrated_Eng/GoodwinDocs/pdf/Sys%20docs/PowerPC/PowerPC%20Elapsed%20Time.pdf
|
|
20
20
|
# and
|
|
21
21
|
# http://www.cap-lore.com/code/TB/
|
|
22
|
-
def ppcg_dirtyhelper_MFTB(state):
|
|
22
|
+
def ppcg_dirtyhelper_MFTB(state): # pylint:disable=unused-argument
|
|
23
23
|
# TODO: This is an incorrect implementation. Fix it later!
|
|
24
24
|
return claripy.BVV(0x200, 64), []
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def ppc32g_dirtyhelper_MFSPR_287(state):
|
|
27
|
+
def ppc32g_dirtyhelper_MFSPR_287(state): # pylint:disable=unused-argument
|
|
28
28
|
return claripy.BVV(0x200, 32), []
|
|
29
29
|
|
|
30
30
|
|
|
@@ -119,8 +119,8 @@ EmWarn_S390X_fpext_rounding = 10
|
|
|
119
119
|
EmWarn_S390X_invalid_rounding = 11
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def amd64g_check_ldmxcsr(state, mxcsr):
|
|
123
|
-
rmode =
|
|
122
|
+
def amd64g_check_ldmxcsr(state, mxcsr): # pylint:disable=unused-argument
|
|
123
|
+
rmode = claripy.LShR(mxcsr, 13) & 3
|
|
124
124
|
|
|
125
125
|
ew = claripy.If(
|
|
126
126
|
(mxcsr & 0x1F80) != 0x1F80,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
import logging
|
|
3
4
|
|
|
5
|
+
import claripy
|
|
6
|
+
|
|
4
7
|
from angr.procedures.java import JavaSimProcedure
|
|
5
8
|
from angr.engines.soot.values.strref import SimSootValue_StringRef
|
|
6
9
|
|
|
@@ -12,4 +15,4 @@ class GetSimpleName(JavaSimProcedure):
|
|
|
12
15
|
|
|
13
16
|
def run(self, this): # pylint: disable=arguments-differ
|
|
14
17
|
class_simple_name = this.type.split(".")[-1]
|
|
15
|
-
return SimSootValue_StringRef.new_string(self.state,
|
|
18
|
+
return SimSootValue_StringRef.new_string(self.state, claripy.StringV(class_simple_name))
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
2
5
|
import angr
|
|
3
6
|
from angr.procedures.posix.read import read
|
|
4
7
|
from angr.procedures.posix.write import write
|
|
@@ -24,7 +27,7 @@ class readv(angr.SimProcedure):
|
|
|
24
27
|
res = 0
|
|
25
28
|
for element in self.state.mem[iovec].struct.iovec.array(iovcnt).resolved:
|
|
26
29
|
tmpres = self.inline_call(read, fd, element.iov_base, element.iov_len).ret_expr
|
|
27
|
-
if self.state.solver.is_true(
|
|
30
|
+
if self.state.solver.is_true(claripy.SLT(tmpres, 0)):
|
|
28
31
|
return tmpres
|
|
29
32
|
|
|
30
33
|
return res
|
|
@@ -38,7 +41,7 @@ class writev(angr.SimProcedure):
|
|
|
38
41
|
res = 0
|
|
39
42
|
for element in self.state.mem[iovec].struct.iovec.array(iovcnt).resolved:
|
|
40
43
|
tmpres = self.inline_call(write, fd, element.iov_base, element.iov_len).ret_expr
|
|
41
|
-
if self.state.solver.is_true(
|
|
44
|
+
if self.state.solver.is_true(claripy.SLT(tmpres, 0)):
|
|
42
45
|
return tmpres
|
|
43
46
|
|
|
44
47
|
return res
|
angr/sim_type.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# pylint:disable=abstract-method,line-too-long,missing-class-docstring,wrong-import-position
|
|
1
|
+
# pylint:disable=abstract-method,line-too-long,missing-class-docstring,wrong-import-position,too-many-positional-arguments
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import contextlib
|
|
@@ -19,7 +19,6 @@ from angr.sim_state import SimState
|
|
|
19
19
|
from .misc.ux import deprecated
|
|
20
20
|
|
|
21
21
|
if TYPE_CHECKING:
|
|
22
|
-
import pycparser
|
|
23
22
|
from angr.procedures.definitions import SimTypeCollection
|
|
24
23
|
from angr.storage.memory_mixins import _Coerce
|
|
25
24
|
|
|
@@ -120,7 +119,8 @@ class SimType:
|
|
|
120
119
|
if self._arch is None:
|
|
121
120
|
raise ValueError("Can't tell my alignment without an arch!")
|
|
122
121
|
if self.size is None:
|
|
123
|
-
|
|
122
|
+
l.debug("The size of the type %r is unknown; assuming word size of the arch.", self)
|
|
123
|
+
return self._arch.bytes
|
|
124
124
|
return self.size // self._arch.byte_width
|
|
125
125
|
|
|
126
126
|
def with_arch(self, arch: Arch | None):
|
|
@@ -214,7 +214,9 @@ class TypeRef(SimType):
|
|
|
214
214
|
self.type = self.type.with_arch(arch)
|
|
215
215
|
return self
|
|
216
216
|
|
|
217
|
-
def c_repr(
|
|
217
|
+
def c_repr(
|
|
218
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
219
|
+
): # pylint: disable=unused-argument
|
|
218
220
|
if not full:
|
|
219
221
|
if name is not None:
|
|
220
222
|
return f"{self.name} {name}"
|
|
@@ -265,7 +267,9 @@ class SimTypeBottom(SimType):
|
|
|
265
267
|
def __repr__(self):
|
|
266
268
|
return self.label or "BOT"
|
|
267
269
|
|
|
268
|
-
def c_repr(
|
|
270
|
+
def c_repr(
|
|
271
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
272
|
+
): # pylint: disable=unused-argument
|
|
269
273
|
if name is None:
|
|
270
274
|
return "int"
|
|
271
275
|
return f'{"int" if self.label is None else self.label} {name}'
|
|
@@ -408,7 +412,9 @@ class SimTypeInt(SimTypeReg):
|
|
|
408
412
|
super().__init__(None, label=label)
|
|
409
413
|
self.signed = signed
|
|
410
414
|
|
|
411
|
-
def c_repr(
|
|
415
|
+
def c_repr(
|
|
416
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
417
|
+
): # pylint: disable=unused-argument
|
|
412
418
|
out = self._base_name
|
|
413
419
|
if not self.signed:
|
|
414
420
|
out = "unsigned " + out
|
|
@@ -736,7 +742,9 @@ class SimTypePointer(SimTypeReg):
|
|
|
736
742
|
def __repr__(self):
|
|
737
743
|
return f"{self.pts_to}*"
|
|
738
744
|
|
|
739
|
-
def c_repr(
|
|
745
|
+
def c_repr(
|
|
746
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
747
|
+
): # pylint: disable=unused-argument
|
|
740
748
|
# if pts_to is SimTypeBottom, we return a void*
|
|
741
749
|
if isinstance(self.pts_to, SimTypeBottom):
|
|
742
750
|
out = "void*"
|
|
@@ -803,7 +811,9 @@ class SimTypeReference(SimTypeReg):
|
|
|
803
811
|
def __repr__(self):
|
|
804
812
|
return f"{self.refs}&"
|
|
805
813
|
|
|
806
|
-
def c_repr(
|
|
814
|
+
def c_repr(
|
|
815
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
816
|
+
): # pylint: disable=unused-argument
|
|
807
817
|
name = "&" if name is None else f"&{name}"
|
|
808
818
|
return self.refs.c_repr(name, full, memo, indent)
|
|
809
819
|
|
|
@@ -869,7 +879,9 @@ class SimTypeArray(SimType):
|
|
|
869
879
|
def __repr__(self):
|
|
870
880
|
return "{}[{}]".format(self.elem_type, "" if self.length is None else self.length)
|
|
871
881
|
|
|
872
|
-
def c_repr(
|
|
882
|
+
def c_repr(
|
|
883
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
884
|
+
): # pylint: disable=unused-argument
|
|
873
885
|
if name is None:
|
|
874
886
|
return repr(self)
|
|
875
887
|
|
|
@@ -958,7 +970,9 @@ class SimTypeString(NamedTypeMixin, SimType):
|
|
|
958
970
|
def __repr__(self):
|
|
959
971
|
return "string_t"
|
|
960
972
|
|
|
961
|
-
def c_repr(
|
|
973
|
+
def c_repr(
|
|
974
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
975
|
+
): # pylint: disable=unused-argument
|
|
962
976
|
if name is None:
|
|
963
977
|
return repr(self)
|
|
964
978
|
|
|
@@ -1034,7 +1048,9 @@ class SimTypeWString(NamedTypeMixin, SimType):
|
|
|
1034
1048
|
def __repr__(self):
|
|
1035
1049
|
return "wstring_t"
|
|
1036
1050
|
|
|
1037
|
-
def c_repr(
|
|
1051
|
+
def c_repr(
|
|
1052
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
1053
|
+
): # pylint: disable=unused-argument
|
|
1038
1054
|
if name is None:
|
|
1039
1055
|
return repr(self)
|
|
1040
1056
|
|
|
@@ -1339,15 +1355,27 @@ class SimTypeDouble(SimTypeFloat):
|
|
|
1339
1355
|
|
|
1340
1356
|
|
|
1341
1357
|
class SimStruct(NamedTypeMixin, SimType):
|
|
1342
|
-
_fields = ("name", "fields")
|
|
1358
|
+
_fields = ("name", "fields", "anonymous")
|
|
1343
1359
|
|
|
1344
|
-
def __init__(
|
|
1360
|
+
def __init__(
|
|
1361
|
+
self,
|
|
1362
|
+
fields: dict[str, SimType] | OrderedDict[str, SimType],
|
|
1363
|
+
name=None,
|
|
1364
|
+
pack=False,
|
|
1365
|
+
align=None,
|
|
1366
|
+
anonymous: bool = False,
|
|
1367
|
+
):
|
|
1345
1368
|
super().__init__(None, name="<anon>" if name is None else name)
|
|
1346
1369
|
|
|
1347
1370
|
self._pack = pack
|
|
1348
1371
|
self._align = align
|
|
1372
|
+
self.anonymous = anonymous
|
|
1349
1373
|
self.fields: OrderedDict[str, SimType] = OrderedDict(fields)
|
|
1350
1374
|
|
|
1375
|
+
# FIXME: Hack for supporting win32 struct definitions
|
|
1376
|
+
if self.name == "_Anonymous_e__Struct":
|
|
1377
|
+
self.anonymous = True
|
|
1378
|
+
|
|
1351
1379
|
self._arch_memo = {}
|
|
1352
1380
|
|
|
1353
1381
|
@property
|
|
@@ -1363,7 +1391,7 @@ class SimStruct(NamedTypeMixin, SimType):
|
|
|
1363
1391
|
offset_so_far = 0
|
|
1364
1392
|
for name, ty in self.fields.items():
|
|
1365
1393
|
if ty.size is None:
|
|
1366
|
-
l.
|
|
1394
|
+
l.debug(
|
|
1367
1395
|
"Found a bottom field in struct %s. Ignore and increment the offset using the default "
|
|
1368
1396
|
"element size.",
|
|
1369
1397
|
self.name,
|
|
@@ -1418,7 +1446,9 @@ class SimStruct(NamedTypeMixin, SimType):
|
|
|
1418
1446
|
def __repr__(self):
|
|
1419
1447
|
return f"struct {self.name}"
|
|
1420
1448
|
|
|
1421
|
-
def c_repr(
|
|
1449
|
+
def c_repr(
|
|
1450
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
1451
|
+
): # pylint: disable=unused-argument
|
|
1422
1452
|
if not full or (memo is not None and self in memo):
|
|
1423
1453
|
return super().c_repr(name, full, memo, indent)
|
|
1424
1454
|
|
|
@@ -1599,7 +1629,9 @@ class SimUnion(NamedTypeMixin, SimType):
|
|
|
1599
1629
|
|
|
1600
1630
|
@property
|
|
1601
1631
|
def size(self):
|
|
1602
|
-
|
|
1632
|
+
member_sizes = [ty.size for ty in self.members.values() if not isinstance(ty, SimTypeBottom)]
|
|
1633
|
+
# fall back to word size in case all members are SimTypeBottom
|
|
1634
|
+
return max(member_sizes) if member_sizes else self._arch.bytes
|
|
1603
1635
|
|
|
1604
1636
|
@property
|
|
1605
1637
|
def alignment(self):
|
|
@@ -1632,7 +1664,9 @@ class SimUnion(NamedTypeMixin, SimType):
|
|
|
1632
1664
|
self.name, "\n\t".join(f"{name} {ty!s};" for name, ty in self.members.items())
|
|
1633
1665
|
)
|
|
1634
1666
|
|
|
1635
|
-
def c_repr(
|
|
1667
|
+
def c_repr(
|
|
1668
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
1669
|
+
): # pylint: disable=unused-argument
|
|
1636
1670
|
if not full or (memo is not None and self in memo):
|
|
1637
1671
|
return super().c_repr(name, full, memo, indent)
|
|
1638
1672
|
|
|
@@ -1875,7 +1909,9 @@ class SimTypeRef(SimType):
|
|
|
1875
1909
|
def set_size(self, v: int):
|
|
1876
1910
|
self._size = v
|
|
1877
1911
|
|
|
1878
|
-
def c_repr(
|
|
1912
|
+
def c_repr(
|
|
1913
|
+
self, name=None, full=0, memo=None, indent=0, name_parens: bool = True
|
|
1914
|
+
) -> str: # pylint: disable=unused-argument
|
|
1879
1915
|
prefix = "unknown"
|
|
1880
1916
|
if self.original_type is SimStruct:
|
|
1881
1917
|
prefix = "struct"
|
|
@@ -3537,7 +3573,8 @@ def dereference_simtype(
|
|
|
3537
3573
|
return memo[t.name]
|
|
3538
3574
|
|
|
3539
3575
|
real_type = t.copy()
|
|
3540
|
-
|
|
3576
|
+
if not t.anonymous:
|
|
3577
|
+
memo[t.name] = real_type
|
|
3541
3578
|
fields = OrderedDict((k, dereference_simtype(v, type_collections, memo=memo)) for k, v in t.fields.items())
|
|
3542
3579
|
real_type.fields = fields
|
|
3543
3580
|
elif isinstance(t, SimTypePointer):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: angr
|
|
3
|
-
Version: 9.2.
|
|
3
|
+
Version: 9.2.123
|
|
4
4
|
Summary: A multi-architecture binary analysis toolkit, with the ability to perform dynamic symbolic execution and various static analyses on binaries
|
|
5
5
|
Home-page: https://github.com/angr/angr
|
|
6
6
|
License: BSD-2-Clause
|
|
@@ -10,18 +10,19 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
14
|
Requires-Python: >=3.10
|
|
14
15
|
Description-Content-Type: text/markdown
|
|
15
16
|
License-File: LICENSE
|
|
16
17
|
Requires-Dist: CppHeaderParser
|
|
17
18
|
Requires-Dist: GitPython
|
|
18
|
-
Requires-Dist: ailment==9.2.
|
|
19
|
-
Requires-Dist: archinfo==9.2.
|
|
19
|
+
Requires-Dist: ailment==9.2.123
|
|
20
|
+
Requires-Dist: archinfo==9.2.123
|
|
20
21
|
Requires-Dist: cachetools
|
|
21
22
|
Requires-Dist: capstone==5.0.3
|
|
22
23
|
Requires-Dist: cffi>=1.14.0
|
|
23
|
-
Requires-Dist: claripy==9.2.
|
|
24
|
-
Requires-Dist: cle==9.2.
|
|
24
|
+
Requires-Dist: claripy==9.2.123
|
|
25
|
+
Requires-Dist: cle==9.2.123
|
|
25
26
|
Requires-Dist: itanium-demangler
|
|
26
27
|
Requires-Dist: mulpyplexer
|
|
27
28
|
Requires-Dist: nampa
|
|
@@ -30,7 +31,7 @@ Requires-Dist: protobuf>=5.28.2
|
|
|
30
31
|
Requires-Dist: psutil
|
|
31
32
|
Requires-Dist: pycparser>=2.18
|
|
32
33
|
Requires-Dist: pyformlang
|
|
33
|
-
Requires-Dist: pyvex==9.2.
|
|
34
|
+
Requires-Dist: pyvex==9.2.123
|
|
34
35
|
Requires-Dist: rich>=13.1.0
|
|
35
36
|
Requires-Dist: sortedcontainers
|
|
36
37
|
Requires-Dist: sympy
|