angr 9.2.115__py3-none-manylinux2014_aarch64.whl → 9.2.117__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/__main__.py +1 -1
- angr/analyses/cfg/cfg_emulated.py +4 -4
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +7 -7
- angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +3 -2
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +5 -1
- angr/analyses/decompiler/structured_codegen/c.py +10 -13
- angr/analyses/decompiler/structuring/dream.py +3 -4
- angr/analyses/decompiler/structuring/phoenix.py +4 -5
- angr/analyses/decompiler/structuring/structurer_base.py +2 -3
- angr/analyses/decompiler/structuring/structurer_nodes.py +3 -3
- angr/analyses/identifier/functions/free.py +3 -1
- angr/analyses/identifier/identify.py +13 -15
- angr/analyses/identifier/runner.py +2 -2
- angr/analyses/reaching_definitions/dep_graph.py +62 -5
- angr/analyses/reaching_definitions/function_handler_library/__init__.py +11 -0
- angr/analyses/reaching_definitions/function_handler_library/stdio.py +15 -13
- angr/analyses/reaching_definitions/function_handler_library/stdlib.py +17 -11
- angr/analyses/reaching_definitions/function_handler_library/string.py +1 -1
- angr/analyses/reaching_definitions/function_handler_library/unistd.py +2 -2
- angr/analyses/reaching_definitions/rd_state.py +26 -29
- angr/analyses/variable_recovery/engine_vex.py +0 -9
- angr/analyses/vfg.py +4 -4
- angr/calling_conventions.py +4 -2
- angr/concretization_strategies/any_named.py +3 -1
- angr/concretization_strategies/controlled_data.py +4 -2
- angr/concretization_strategies/signed_add.py +3 -1
- angr/engines/concrete.py +3 -1
- angr/engines/pcode/behavior.py +2 -0
- angr/engines/pcode/cc.py +2 -0
- angr/engines/pcode/emulate.py +4 -4
- angr/engines/pcode/engine.py +3 -7
- angr/engines/soot/engine.py +7 -6
- angr/engines/soot/expressions/constants.py +6 -5
- angr/engines/soot/expressions/newArray.py +3 -1
- angr/engines/soot/expressions/newMultiArray.py +3 -1
- angr/engines/soot/statements/goto.py +3 -1
- angr/engines/soot/statements/if_.py +3 -1
- angr/engines/soot/statements/switch.py +3 -1
- angr/engines/soot/statements/throw.py +4 -2
- angr/engines/soot/values/arrayref.py +5 -5
- angr/engines/unicorn.py +8 -7
- angr/engines/vex/heavy/concretizers.py +6 -6
- angr/engines/vex/heavy/dirty.py +20 -22
- angr/engines/vex/heavy/heavy.py +4 -8
- angr/exploration_techniques/director.py +1 -1
- angr/exploration_techniques/driller_core.py +3 -1
- angr/exploration_techniques/tracer.py +2 -1
- angr/knowledge_plugins/key_definitions/live_definitions.py +12 -13
- angr/procedures/cgc/allocate.py +8 -10
- angr/procedures/cgc/deallocate.py +10 -3
- angr/procedures/cgc/fdwait.py +15 -13
- angr/procedures/cgc/random.py +11 -5
- angr/procedures/cgc/receive.py +5 -3
- angr/procedures/cgc/transmit.py +5 -4
- angr/procedures/glibc/__libc_start_main.py +5 -4
- angr/procedures/java_jni/__init__.py +4 -4
- angr/procedures/java_jni/array_operations.py +3 -1
- angr/procedures/java_lang/string.py +1 -1
- angr/procedures/java_util/random.py +3 -1
- angr/procedures/libc/access.py +4 -2
- angr/procedures/libc/feof.py +4 -3
- angr/procedures/libc/fgetc.py +3 -1
- angr/procedures/libc/fgets.py +5 -5
- angr/procedures/libc/fopen.py +5 -4
- angr/procedures/libc/fread.py +4 -3
- angr/procedures/libc/fseek.py +4 -3
- angr/procedures/libc/getdelim.py +7 -4
- angr/procedures/libc/gets.py +4 -2
- angr/procedures/libc/memcmp.py +18 -15
- angr/procedures/libc/memset.py +9 -7
- angr/procedures/libc/puts.py +3 -1
- angr/procedures/libc/snprintf.py +4 -2
- angr/procedures/libc/sprintf.py +3 -1
- angr/procedures/libc/strchr.py +6 -3
- angr/procedures/libc/strcmp.py +5 -3
- angr/procedures/libc/strlen.py +3 -3
- angr/procedures/libc/strncmp.py +28 -28
- angr/procedures/libc/strncpy.py +5 -2
- angr/procedures/libc/strstr.py +10 -7
- angr/procedures/libc/strtol.py +32 -34
- angr/procedures/libc/tolower.py +3 -1
- angr/procedures/libc/toupper.py +3 -1
- angr/procedures/linux_kernel/fstat.py +13 -13
- angr/procedures/linux_kernel/fstat64.py +15 -15
- angr/procedures/linux_kernel/lseek.py +5 -3
- angr/procedures/linux_kernel/sigaction.py +4 -2
- angr/procedures/linux_kernel/sigprocmask.py +5 -3
- angr/procedures/linux_kernel/tgkill.py +3 -1
- angr/procedures/linux_kernel/time.py +7 -4
- angr/procedures/msvcr/fmode.py +3 -1
- angr/procedures/ntdll/exceptions.py +3 -1
- angr/procedures/posix/bzero.py +3 -1
- angr/procedures/posix/fdopen.py +6 -4
- angr/procedures/posix/fork.py +6 -4
- angr/procedures/posix/mmap.py +6 -3
- angr/procedures/posix/poll.py +6 -5
- angr/procedures/posix/readdir.py +10 -7
- angr/procedures/posix/select.py +4 -2
- angr/procedures/posix/send.py +4 -3
- angr/procedures/posix/sigaction.py +4 -2
- angr/procedures/posix/sim_time.py +3 -1
- angr/procedures/posix/strcasecmp.py +3 -1
- angr/procedures/posix/strtok_r.py +10 -7
- angr/procedures/stubs/Redirect.py +3 -1
- angr/procedures/stubs/ReturnChar.py +3 -3
- angr/procedures/stubs/UserHook.py +3 -1
- angr/procedures/stubs/b64_decode.py +3 -1
- angr/procedures/stubs/crazy_scanf.py +6 -4
- angr/procedures/stubs/format_parser.py +13 -15
- angr/procedures/tracer/receive.py +3 -1
- angr/procedures/tracer/transmit.py +3 -1
- angr/procedures/win32/GetLastInputInfo.py +4 -2
- angr/procedures/win32/GetProcessAffinityMask.py +4 -2
- angr/procedures/win32/gethostbyname.py +3 -1
- angr/procedures/win32/heap.py +3 -1
- angr/procedures/win32/local_storage.py +4 -2
- angr/procedures/win32/sim_time.py +7 -4
- angr/procedures/win_user32/chars.py +4 -2
- angr/procedures/win_user32/messagebox.py +3 -1
- angr/sim_procedure.py +7 -7
- angr/sim_state.py +10 -7
- angr/sim_type.py +3 -3
- angr/simos/cgc.py +2 -2
- angr/simos/simos.py +5 -4
- angr/simos/windows.py +5 -5
- angr/state_plugins/heap/heap_brk.py +5 -3
- angr/state_plugins/heap/heap_ptmalloc.py +5 -4
- angr/state_plugins/history.py +7 -5
- angr/state_plugins/light_registers.py +2 -2
- angr/state_plugins/plugin.py +2 -2
- angr/state_plugins/posix.py +28 -26
- angr/state_plugins/preconstrainer.py +2 -1
- angr/state_plugins/solver.py +11 -27
- angr/state_plugins/trace_additions.py +9 -13
- angr/state_plugins/uc_manager.py +4 -2
- angr/state_plugins/unicorn_engine.py +1 -1
- angr/state_plugins/view.py +1 -1
- angr/storage/file.py +21 -26
- angr/storage/memory_mixins/actions_mixin.py +4 -2
- angr/storage/memory_mixins/address_concretization_mixin.py +3 -3
- angr/storage/memory_mixins/default_filler_mixin.py +6 -4
- angr/storage/memory_mixins/javavm_memory/javavm_memory_mixin.py +7 -5
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/cooperation.py +2 -1
- angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +1 -1
- angr/storage/memory_mixins/regioned_memory/region_data.py +3 -1
- angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +1 -1
- angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +5 -4
- angr/storage/memory_mixins/simple_interface_mixin.py +2 -2
- angr/storage/memory_mixins/size_resolution_mixin.py +3 -1
- angr/storage/memory_mixins/slotted_memory.py +1 -1
- angr/storage/memory_mixins/smart_find_mixin.py +2 -2
- angr/storage/memory_mixins/symbolic_merger_mixin.py +5 -3
- angr/tablespecs.py +3 -3
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/METADATA +7 -7
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/RECORD +161 -161
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/WHEEL +1 -1
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/LICENSE +0 -0
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/entry_points.txt +0 -0
- {angr-9.2.115.dist-info → angr-9.2.117.dist-info}/top_level.txt +0 -0
angr/procedures/cgc/random.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
import angr
|
|
6
|
+
from angr.state_plugins.sim_action_object import SimActionObject
|
|
4
7
|
|
|
5
8
|
rand_count = itertools.count()
|
|
6
9
|
|
|
@@ -9,6 +12,9 @@ class random(angr.SimProcedure):
|
|
|
9
12
|
# pylint:disable=arguments-differ,missing-class-docstring
|
|
10
13
|
|
|
11
14
|
def run(self, buf, count, rnd_bytes, concrete_data=None):
|
|
15
|
+
if isinstance(rnd_bytes, SimActionObject):
|
|
16
|
+
rnd_bytes = rnd_bytes.ast
|
|
17
|
+
|
|
12
18
|
if self.state.mode == "fastpath":
|
|
13
19
|
# Special case for CFG
|
|
14
20
|
if (
|
|
@@ -28,15 +34,15 @@ class random(angr.SimProcedure):
|
|
|
28
34
|
self.state.memory.store(rnd_bytes, count, endness="Iend_LE")
|
|
29
35
|
|
|
30
36
|
# We always return something in fastpath mode
|
|
31
|
-
return
|
|
37
|
+
return claripy.BVV(0, self.state.arch.bits)
|
|
32
38
|
|
|
33
39
|
# return code
|
|
34
|
-
r =
|
|
40
|
+
r = claripy.ite_cases(
|
|
35
41
|
(
|
|
36
42
|
(self.state.cgc.addr_invalid(buf), self.state.cgc.EFAULT),
|
|
37
|
-
(
|
|
43
|
+
(claripy.And(rnd_bytes != 0, self.state.cgc.addr_invalid(rnd_bytes)), self.state.cgc.EFAULT),
|
|
38
44
|
),
|
|
39
|
-
|
|
45
|
+
claripy.BVV(0, self.state.arch.bits),
|
|
40
46
|
)
|
|
41
47
|
|
|
42
48
|
if self.state.satisfiable(extra_constraints=[count != 0]):
|
|
@@ -46,7 +52,7 @@ class random(angr.SimProcedure):
|
|
|
46
52
|
)
|
|
47
53
|
|
|
48
54
|
if concrete_data:
|
|
49
|
-
value =
|
|
55
|
+
value = claripy.BVS(f"random_{next(rand_count)}", max_size)
|
|
50
56
|
self.state.preconstrainer.preconstrain(concrete_data, value)
|
|
51
57
|
else:
|
|
52
58
|
value = self.state.solver.Unconstrained(
|
angr/procedures/cgc/receive.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from itertools import count
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
import angr
|
|
4
6
|
|
|
5
7
|
from ... import sim_options as o
|
|
@@ -30,7 +32,7 @@ class receive(angr.SimProcedure):
|
|
|
30
32
|
count = self.state.solver.Unconstrained("receive_length", self.state.arch.bits)
|
|
31
33
|
self.state.memory.store(rx_bytes, count, endness="Iend_LE")
|
|
32
34
|
|
|
33
|
-
return
|
|
35
|
+
return claripy.BVV(0, self.state.arch.bits)
|
|
34
36
|
|
|
35
37
|
# check invalid memory accesses
|
|
36
38
|
# rules for invalid: greater than 0xc0 or wraps around
|
|
@@ -56,7 +58,7 @@ class receive(angr.SimProcedure):
|
|
|
56
58
|
)
|
|
57
59
|
read_length = simfd.read(buf, count, short_reads=False, do_concrete_update=do_concrete_update)
|
|
58
60
|
if type(read_length) is int:
|
|
59
|
-
read_length =
|
|
61
|
+
read_length = claripy.BVV(read_length, 32)
|
|
60
62
|
self.state.memory.store(rx_bytes, read_length, condition=rx_bytes != 0, endness="Iend_LE")
|
|
61
63
|
self.size = read_length
|
|
62
64
|
|
|
@@ -86,6 +88,6 @@ class receive(angr.SimProcedure):
|
|
|
86
88
|
|
|
87
89
|
self.size = read_length
|
|
88
90
|
if type(read_length) is int:
|
|
89
|
-
read_length =
|
|
91
|
+
read_length = claripy.BVV(read_length, 32)
|
|
90
92
|
self.state.memory.store(rx_bytes, read_length, condition=rx_bytes != 0, endness="Iend_LE")
|
|
91
93
|
return 0
|
angr/procedures/cgc/transmit.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import claripy
|
|
2
2
|
|
|
3
|
+
import angr
|
|
3
4
|
from ... import sim_options as o
|
|
4
5
|
|
|
5
6
|
|
|
@@ -17,7 +18,7 @@ class transmit(angr.SimProcedure):
|
|
|
17
18
|
if self.state.mode == "fastpath":
|
|
18
19
|
# Special case for CFG generation
|
|
19
20
|
self.state.memory.store(tx_bytes, count, endness="Iend_LE")
|
|
20
|
-
return
|
|
21
|
+
return claripy.BVV(0, self.state.arch.bits)
|
|
21
22
|
|
|
22
23
|
if o.ABSTRACT_MEMORY in self.state.options:
|
|
23
24
|
simfd.write(buf, count)
|
|
@@ -54,10 +55,10 @@ class transmit(angr.SimProcedure):
|
|
|
54
55
|
)
|
|
55
56
|
|
|
56
57
|
if do_concrete_update and count.symbolic:
|
|
57
|
-
concrete_count =
|
|
58
|
+
concrete_count = claripy.BVV(self.state.solver.eval(count), 32)
|
|
58
59
|
self.state.memory.store(tx_bytes, concrete_count, endness="Iend_LE", condition=tx_bytes != 0)
|
|
59
60
|
|
|
60
61
|
self.state.memory.store(tx_bytes, count, endness="Iend_LE", condition=tx_bytes != 0)
|
|
61
62
|
|
|
62
63
|
# TODO: transmit failure
|
|
63
|
-
return
|
|
64
|
+
return claripy.BVV(0, self.state.arch.bits)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
3
4
|
from cle import AT
|
|
4
5
|
|
|
5
6
|
import angr
|
|
@@ -28,7 +29,7 @@ class __libc_start_main(angr.SimProcedure):
|
|
|
28
29
|
# Each entry is 2 bytes
|
|
29
30
|
self.state.memory.store(
|
|
30
31
|
table + (pos * 2),
|
|
31
|
-
|
|
32
|
+
claripy.BVV(c, 16),
|
|
32
33
|
inspect=False,
|
|
33
34
|
disable_actions=True,
|
|
34
35
|
)
|
|
@@ -60,7 +61,7 @@ class __libc_start_main(angr.SimProcedure):
|
|
|
60
61
|
for pos, c in enumerate(self.state.libc.TOLOWER_LOC_ARRAY):
|
|
61
62
|
self.state.memory.store(
|
|
62
63
|
table + (pos * 4),
|
|
63
|
-
|
|
64
|
+
claripy.BVV(c, 32),
|
|
64
65
|
endness=self.state.arch.memory_endness,
|
|
65
66
|
inspect=False,
|
|
66
67
|
disable_actions=True,
|
|
@@ -93,7 +94,7 @@ class __libc_start_main(angr.SimProcedure):
|
|
|
93
94
|
for pos, c in enumerate(self.state.libc.TOUPPER_LOC_ARRAY):
|
|
94
95
|
self.state.memory.store(
|
|
95
96
|
table + (pos * 4),
|
|
96
|
-
|
|
97
|
+
claripy.BVV(c, 32),
|
|
97
98
|
endness=self.state.arch.memory_endness,
|
|
98
99
|
inspect=False,
|
|
99
100
|
disable_actions=True,
|
|
@@ -122,7 +123,7 @@ class __libc_start_main(angr.SimProcedure):
|
|
|
122
123
|
errno_loc = self.inline_call(malloc, self.state.arch.bytes).ret_expr
|
|
123
124
|
|
|
124
125
|
self.state.libc.errno_location = errno_loc
|
|
125
|
-
self.state.memory.store(errno_loc,
|
|
126
|
+
self.state.memory.store(errno_loc, claripy.BVV(0, self.state.arch.bits))
|
|
126
127
|
|
|
127
128
|
@property
|
|
128
129
|
def envp(self):
|
|
@@ -4,7 +4,7 @@ import logging
|
|
|
4
4
|
import typing
|
|
5
5
|
|
|
6
6
|
from archinfo import ArchSoot
|
|
7
|
-
|
|
7
|
+
import claripy
|
|
8
8
|
|
|
9
9
|
from ...calling_conventions import default_cc
|
|
10
10
|
from ...sim_procedure import SimProcedure
|
|
@@ -66,7 +66,7 @@ class JNISimProcedure(SimProcedure):
|
|
|
66
66
|
if isinstance(data, int):
|
|
67
67
|
if addr is None:
|
|
68
68
|
addr = self._allocate_native_memory(size=type_size // 8)
|
|
69
|
-
value =
|
|
69
|
+
value = claripy.BVV(data, type_size)
|
|
70
70
|
self.state.memory.store(addr, value, endness=native_memory_endness)
|
|
71
71
|
# store array
|
|
72
72
|
elif isinstance(data, list):
|
|
@@ -173,11 +173,11 @@ class JNISimProcedure(SimProcedure):
|
|
|
173
173
|
# store chars one by one
|
|
174
174
|
str_len = len(string) // 8
|
|
175
175
|
for idx in range(str_len):
|
|
176
|
-
str_byte = StrSubstr(idx, 1, string)
|
|
176
|
+
str_byte = claripy.StrSubstr(idx, 1, string)
|
|
177
177
|
self.state.memory.store(addr + idx, str_byte)
|
|
178
178
|
|
|
179
179
|
# store terminating zero
|
|
180
|
-
self.state.memory.store(len(string), BVV(0, 8))
|
|
180
|
+
self.state.memory.store(len(string), claripy.BVV(0, 8))
|
|
181
181
|
|
|
182
182
|
return addr
|
|
183
183
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
from . import JNISimProcedure
|
|
4
6
|
from ...engines.soot.expressions import SimSootExpr_NewArray
|
|
5
7
|
from ...engines.soot.values import SimSootValue_ArrayRef
|
|
@@ -239,7 +241,7 @@ class GetArrayRegion(JNISimProcedure):
|
|
|
239
241
|
# - start_idx <= last_idx < array_size
|
|
240
242
|
# with last_idx := start_idx+length-1
|
|
241
243
|
# - 0 <= length <= array_size
|
|
242
|
-
range_constraints =
|
|
244
|
+
range_constraints = claripy.And(
|
|
243
245
|
start_idx.SGE(0),
|
|
244
246
|
start_idx.SLT(array.size),
|
|
245
247
|
array.size.SGT(start_idx + length - 1),
|
|
@@ -26,7 +26,7 @@ class StringEquals(JavaSimProcedure):
|
|
|
26
26
|
def run(self, str_ref_1, str_ref_2): # pylint: disable=unused-argument
|
|
27
27
|
str_1 = self.state.memory.load(str_ref_1)
|
|
28
28
|
str_2 = self.state.memory.load(str_ref_2)
|
|
29
|
-
return
|
|
29
|
+
return claripy.If(str_1 == str_2, claripy.BVV(1, 32), claripy.BVV(0, 32))
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class StringSplit(JavaSimProcedure):
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import claripy
|
|
2
|
+
|
|
1
3
|
from ..java import JavaSimProcedure
|
|
2
4
|
|
|
3
5
|
|
|
@@ -5,7 +7,7 @@ class NextInt(JavaSimProcedure):
|
|
|
5
7
|
__provides__ = (("java.util.Random", "nextInt(int)"),)
|
|
6
8
|
|
|
7
9
|
def run(self, obj, bound): # pylint: disable=arguments-differ,unused-argument
|
|
8
|
-
rand =
|
|
10
|
+
rand = claripy.BVS("rand", 32)
|
|
9
11
|
self.state.solver.add(rand.UGE(0))
|
|
10
12
|
self.state.solver.add(rand.ULT(bound))
|
|
11
13
|
return rand
|
angr/procedures/libc/access.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import claripy
|
|
2
|
+
|
|
1
3
|
import angr
|
|
2
4
|
|
|
3
5
|
|
|
@@ -5,6 +7,6 @@ class access(angr.SimProcedure):
|
|
|
5
7
|
# pylint:disable=arguments-differ
|
|
6
8
|
|
|
7
9
|
def run(self, path, mode):
|
|
8
|
-
ret =
|
|
9
|
-
self.state.add_constraints(
|
|
10
|
+
ret = claripy.BVS("access", self.arch.sizeof["int"])
|
|
11
|
+
self.state.add_constraints(claripy.Or(ret == 0, ret == -1))
|
|
10
12
|
return ret
|
angr/procedures/libc/feof.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import claripy
|
|
3
2
|
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
4
3
|
|
|
4
|
+
import angr
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
class feof(angr.SimProcedure):
|
|
7
8
|
# pylint:disable=arguments-differ
|
|
@@ -13,7 +14,7 @@ class feof(angr.SimProcedure):
|
|
|
13
14
|
simfd = self.state.posix.get_fd(fileno)
|
|
14
15
|
if simfd is None:
|
|
15
16
|
return None
|
|
16
|
-
return
|
|
17
|
+
return claripy.If(simfd.eof(), claripy.BVV(1, self.arch.sizeof["int"]), 0)
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
feof_unlocked = feof
|
angr/procedures/libc/fgetc.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import claripy
|
|
2
|
+
|
|
1
3
|
import angr
|
|
2
4
|
|
|
3
5
|
|
|
@@ -16,7 +18,7 @@ class fgetc(angr.SimProcedure):
|
|
|
16
18
|
data,
|
|
17
19
|
real_length,
|
|
18
20
|
) = simfd.read_data(1)
|
|
19
|
-
return
|
|
21
|
+
return claripy.If(real_length == 0, -1, data.zero_extend(self.arch.sizeof["int"] - 8))
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
getc = fgetc
|
angr/procedures/libc/fgets.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import claripy
|
|
2
|
+
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
3
|
+
|
|
1
4
|
import angr
|
|
2
5
|
from angr.storage.memory_mixins.address_concretization_mixin import MultiwriteAnnotation
|
|
3
6
|
|
|
4
7
|
|
|
5
|
-
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
6
|
-
|
|
7
|
-
|
|
8
8
|
class fgets(angr.SimProcedure):
|
|
9
9
|
# pylint:disable=arguments-differ
|
|
10
10
|
|
|
@@ -47,10 +47,10 @@ class fgets(angr.SimProcedure):
|
|
|
47
47
|
|
|
48
48
|
for i, byte in enumerate(data.chop(8)):
|
|
49
49
|
self.state.add_constraints(
|
|
50
|
-
|
|
50
|
+
claripy.If(
|
|
51
51
|
i + 1 != real_size,
|
|
52
52
|
byte != b"\n", # if not last byte returned, not newline
|
|
53
|
-
|
|
53
|
+
claripy.Or( # otherwise one of the following must be true:
|
|
54
54
|
i + 2 == size, # - we ran out of space, or
|
|
55
55
|
simfd.eof(), # - the file is at EOF, or
|
|
56
56
|
byte == b"\n", # - it is a newline
|
angr/procedures/libc/fopen.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import claripy
|
|
3
2
|
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
4
3
|
|
|
4
|
+
import angr
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
def mode_to_flag(mode):
|
|
7
8
|
# TODO improve this: handle mode = strings
|
|
@@ -60,5 +61,5 @@ class fopen(angr.SimProcedure):
|
|
|
60
61
|
return file_struct_ptr
|
|
61
62
|
else:
|
|
62
63
|
# still possible that open failed
|
|
63
|
-
null =
|
|
64
|
-
return
|
|
64
|
+
null = claripy.BVV(0, self.state.arch.bits)
|
|
65
|
+
return claripy.If(fd == fd_concr, file_struct_ptr, null)
|
angr/procedures/libc/fread.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import claripy
|
|
3
2
|
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
4
3
|
|
|
4
|
+
import angr
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
class fread(angr.SimProcedure):
|
|
7
8
|
# pylint:disable=arguments-differ
|
|
@@ -16,7 +17,7 @@ class fread(angr.SimProcedure):
|
|
|
16
17
|
return -1
|
|
17
18
|
|
|
18
19
|
ret = simfd.read(dst, size * nm)
|
|
19
|
-
return
|
|
20
|
+
return claripy.If(claripy.Or(size == 0, nm == 0), 0, ret // size)
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
fread_unlocked = fread
|
angr/procedures/libc/fseek.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import claripy
|
|
3
2
|
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
3
|
+
|
|
4
|
+
import angr
|
|
4
5
|
from ...errors import SimSolverError
|
|
5
6
|
|
|
6
7
|
|
|
@@ -26,7 +27,7 @@ class fseek(angr.SimProcedure):
|
|
|
26
27
|
simfd = self.state.posix.get_fd(fd)
|
|
27
28
|
if simfd is None:
|
|
28
29
|
return -1
|
|
29
|
-
return
|
|
30
|
+
return claripy.If(simfd.seek(offset, whence), claripy.BVV(0, self.arch.sizeof["int"]), -1)
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
fseeko = fseek
|
angr/procedures/libc/getdelim.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import claripy
|
|
2
4
|
from cle.backends.externs.simdata.io_file import io_file_data_for_arch
|
|
3
5
|
|
|
4
|
-
import
|
|
6
|
+
import angr
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
l = logging.getLogger(name=__name__)
|
|
7
10
|
|
|
@@ -72,10 +75,10 @@ class __getdelim(angr.SimProcedure):
|
|
|
72
75
|
|
|
73
76
|
for i, byte in enumerate(data.chop(8)):
|
|
74
77
|
self.state.add_constraints(
|
|
75
|
-
|
|
78
|
+
claripy.If(
|
|
76
79
|
i + 1 != real_size,
|
|
77
80
|
byte != delim_byte, # if not last byte returned, not newline
|
|
78
|
-
|
|
81
|
+
claripy.Or( # otherwise one of the following must be true:
|
|
79
82
|
i + 2 == size, # - we ran out of space, or
|
|
80
83
|
simfd.eof(), # - the file is at EOF, or
|
|
81
84
|
byte == delim_byte, # - it is a newline
|
angr/procedures/libc/gets.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
import angr
|
|
4
6
|
from angr.storage.memory_mixins.address_concretization_mixin import MultiwriteAnnotation
|
|
5
7
|
from angr.misc.ux import once
|
|
@@ -48,10 +50,10 @@ class gets(angr.SimProcedure):
|
|
|
48
50
|
|
|
49
51
|
for i, byte in enumerate(data.chop(8)):
|
|
50
52
|
self.state.add_constraints(
|
|
51
|
-
|
|
53
|
+
claripy.If(
|
|
52
54
|
i + 1 != real_size,
|
|
53
55
|
byte != b"\n", # if not last byte returned, not newline
|
|
54
|
-
|
|
56
|
+
claripy.Or( # otherwise one of the following must be true:
|
|
55
57
|
i + 2 == max_size, # - we ran out of space, or
|
|
56
58
|
simfd.eof(), # - the file is at EOF, or
|
|
57
59
|
byte == b"\n", # - it is a newline
|
angr/procedures/libc/memcmp.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import angr
|
|
2
1
|
import logging
|
|
3
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
5
|
+
import angr
|
|
6
|
+
|
|
4
7
|
l = logging.getLogger(name=__name__)
|
|
5
8
|
|
|
6
9
|
|
|
@@ -25,19 +28,19 @@ class memcmp(angr.SimProcedure):
|
|
|
25
28
|
s1_part = self.state.memory.load(s1_addr, definite_size, endness="Iend_BE")
|
|
26
29
|
s2_part = self.state.memory.load(s2_addr, definite_size, endness="Iend_BE")
|
|
27
30
|
cases = [
|
|
28
|
-
[s1_part == s2_part,
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
+
[s1_part == s2_part, claripy.BVV(0, int_bits)],
|
|
32
|
+
[claripy.ULT(s1_part, s2_part), claripy.BVV(-1, int_bits)],
|
|
33
|
+
[claripy.UGT(s1_part, s2_part), claripy.BVV(1, int_bits)],
|
|
31
34
|
]
|
|
32
|
-
definite_answer =
|
|
33
|
-
constraint =
|
|
35
|
+
definite_answer = claripy.ite_cases(cases, 2)
|
|
36
|
+
constraint = claripy.Or(*[c for c, _ in cases])
|
|
34
37
|
self.state.add_constraints(constraint)
|
|
35
38
|
|
|
36
39
|
l.debug("Created definite answer: %s", definite_answer)
|
|
37
40
|
l.debug("Created constraint: %s", constraint)
|
|
38
41
|
l.debug("... crom cases: %s", cases)
|
|
39
42
|
else:
|
|
40
|
-
definite_answer =
|
|
43
|
+
definite_answer = claripy.BVV(0, int_bits)
|
|
41
44
|
|
|
42
45
|
if not self.state.solver.symbolic(definite_answer) and self.state.solver.eval(definite_answer) != 0:
|
|
43
46
|
return definite_answer
|
|
@@ -51,19 +54,19 @@ class memcmp(angr.SimProcedure):
|
|
|
51
54
|
s1_part = s1_all[conditional_size * 8 - 1 : bit - 8]
|
|
52
55
|
s2_part = s2_all[conditional_size * 8 - 1 : bit - 8]
|
|
53
56
|
cases = [
|
|
54
|
-
[s1_part == s2_part,
|
|
55
|
-
[
|
|
56
|
-
[
|
|
57
|
+
[s1_part == s2_part, claripy.BVV(0, int_bits)],
|
|
58
|
+
[claripy.ULT(s1_part, s2_part), claripy.BVV(-1, int_bits)],
|
|
59
|
+
[claripy.UGT(s1_part, s2_part), claripy.BVV(1, int_bits)],
|
|
57
60
|
]
|
|
58
|
-
conditional_rets[byte + 1] =
|
|
59
|
-
self.state.add_constraints(
|
|
61
|
+
conditional_rets[byte + 1] = claripy.ite_cases(cases, 0)
|
|
62
|
+
self.state.add_constraints(claripy.Or(*[c for c, _ in cases]))
|
|
60
63
|
|
|
61
|
-
ret_expr =
|
|
64
|
+
ret_expr = claripy.If(
|
|
62
65
|
definite_answer == 0,
|
|
63
|
-
|
|
66
|
+
claripy.ite_dict(n - definite_size, conditional_rets, 2),
|
|
64
67
|
definite_answer,
|
|
65
68
|
)
|
|
66
|
-
self.state.add_constraints(
|
|
69
|
+
self.state.add_constraints(claripy.Or(*[n - definite_size == c for c in conditional_rets]))
|
|
67
70
|
return ret_expr
|
|
68
71
|
else:
|
|
69
72
|
return definite_answer
|
angr/procedures/libc/memset.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import angr
|
|
2
|
-
|
|
3
1
|
import logging
|
|
4
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
5
|
+
import angr
|
|
6
|
+
|
|
5
7
|
l = logging.getLogger(name=__name__)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -37,12 +39,12 @@ class memset(angr.SimProcedure):
|
|
|
37
39
|
|
|
38
40
|
def run(self, dst_addr, char, num):
|
|
39
41
|
if char.size() != self.state.arch.byte_width: # sizeof(char)
|
|
40
|
-
char =
|
|
42
|
+
char = claripy.Extract(self.state.arch.byte_width - 1, 0, char)
|
|
41
43
|
|
|
42
44
|
if self.state.solver.symbolic(num):
|
|
43
45
|
l.debug("symbolic length")
|
|
44
46
|
max_size = self.state.solver.min_int(num) + self.state.libc.max_buffer_size
|
|
45
|
-
write_bytes =
|
|
47
|
+
write_bytes = claripy.Concat(*([char] * max_size))
|
|
46
48
|
self.state.memory.store(dst_addr, write_bytes, size=num)
|
|
47
49
|
else:
|
|
48
50
|
max_size = self.state.solver.eval(num)
|
|
@@ -54,14 +56,14 @@ class memset(angr.SimProcedure):
|
|
|
54
56
|
|
|
55
57
|
if self.state.solver.symbolic(char):
|
|
56
58
|
l.debug("symbolic char")
|
|
57
|
-
write_bytes =
|
|
59
|
+
write_bytes = claripy.Concat(*([char] * chunksize))
|
|
58
60
|
else:
|
|
59
61
|
# Concatenating many bytes is slow, so some sort of optimization is required
|
|
60
62
|
if char.concrete_value == 0:
|
|
61
|
-
write_bytes =
|
|
63
|
+
write_bytes = claripy.BVV(0, chunksize * 8)
|
|
62
64
|
else:
|
|
63
65
|
rb = memset._repeat_bytes(char.concrete_value, chunksize)
|
|
64
|
-
write_bytes =
|
|
66
|
+
write_bytes = claripy.BVV(rb, chunksize * 8)
|
|
65
67
|
|
|
66
68
|
self.state.memory.store(dst_addr + offset, write_bytes)
|
|
67
69
|
offset += chunksize
|
angr/procedures/libc/puts.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import claripy
|
|
2
|
+
|
|
1
3
|
import angr
|
|
2
4
|
|
|
3
5
|
|
|
@@ -12,5 +14,5 @@ class puts(angr.SimProcedure):
|
|
|
12
14
|
strlen = angr.SIM_PROCEDURES["libc"]["strlen"]
|
|
13
15
|
length = self.inline_call(strlen, string).ret_expr
|
|
14
16
|
out = stdout.write(string, length)
|
|
15
|
-
stdout.write_data(
|
|
17
|
+
stdout.write_data(claripy.BVV(b"\n"))
|
|
16
18
|
return (out + 1)[31:0]
|
angr/procedures/libc/snprintf.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
from angr.procedures.stubs.format_parser import FormatParser
|
|
4
6
|
|
|
5
7
|
l = logging.getLogger(name=__name__)
|
|
@@ -15,7 +17,7 @@ class snprintf(FormatParser):
|
|
|
15
17
|
self.state.memory.store(dst_ptr, out_str)
|
|
16
18
|
|
|
17
19
|
# place the terminating null byte
|
|
18
|
-
self.state.memory.store(dst_ptr + (out_str.size() // self.arch.byte_width),
|
|
20
|
+
self.state.memory.store(dst_ptr + (out_str.size() // self.arch.byte_width), claripy.BVV(0, 8))
|
|
19
21
|
|
|
20
22
|
return out_str.size() // self.arch.byte_width
|
|
21
23
|
|
|
@@ -28,6 +30,6 @@ class __snprintf_chk(FormatParser):
|
|
|
28
30
|
self.state.memory.store(dst_ptr, out_str)
|
|
29
31
|
|
|
30
32
|
# place the terminating null byte
|
|
31
|
-
self.state.memory.store(dst_ptr + (out_str.size() // self.arch.byte_width),
|
|
33
|
+
self.state.memory.store(dst_ptr + (out_str.size() // self.arch.byte_width), claripy.BVV(0, 8))
|
|
32
34
|
|
|
33
35
|
return out_str.size() // self.arch.byte_width
|
angr/procedures/libc/sprintf.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
from angr.procedures.stubs.format_parser import FormatParser
|
|
4
6
|
|
|
5
7
|
l = logging.getLogger(name=__name__)
|
|
@@ -16,7 +18,7 @@ class sprintf(FormatParser):
|
|
|
16
18
|
|
|
17
19
|
# place the terminating null byte
|
|
18
20
|
self.state.memory.store(
|
|
19
|
-
dst_ptr + (out_str.size() // self.arch.byte_width),
|
|
21
|
+
dst_ptr + (out_str.size() // self.arch.byte_width), claripy.BVV(0, self.arch.byte_width)
|
|
20
22
|
)
|
|
21
23
|
|
|
22
24
|
return out_str.size() // self.arch.byte_width
|
angr/procedures/libc/strchr.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
1
5
|
import angr
|
|
2
6
|
from angr.storage.memory_mixins.address_concretization_mixin import MultiwriteAnnotation
|
|
3
7
|
from angr.sim_options import MEMORY_CHUNK_INDIVIDUAL_READS
|
|
4
8
|
|
|
5
|
-
import logging
|
|
6
9
|
|
|
7
10
|
l = logging.getLogger(name=__name__)
|
|
8
11
|
|
|
@@ -36,9 +39,9 @@ class strchr(angr.SimProcedure):
|
|
|
36
39
|
# ensure that the string length is long enough to include
|
|
37
40
|
# the character!
|
|
38
41
|
chrpos = a - s_addr
|
|
39
|
-
self.state.add_constraints(
|
|
42
|
+
self.state.add_constraints(claripy.If(a != 0, chrpos <= s_strlen.ret_expr, True))
|
|
40
43
|
|
|
41
44
|
return a
|
|
42
|
-
# self.state.add_constraints(
|
|
45
|
+
# self.state.add_constraints(claripy.ULT(a - s_addr, s_strlen.ret_expr))
|
|
43
46
|
# self.max_chr_index = max(i)
|
|
44
47
|
# return a
|
angr/procedures/libc/strcmp.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import angr
|
|
2
|
-
|
|
3
1
|
import logging
|
|
4
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
5
|
+
import angr
|
|
6
|
+
|
|
5
7
|
l = logging.getLogger(name=__name__)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -13,7 +15,7 @@ class strcmp(angr.SimProcedure):
|
|
|
13
15
|
|
|
14
16
|
a_strlen = self.inline_call(strlen, a_addr, wchar=wchar)
|
|
15
17
|
b_strlen = self.inline_call(strlen, b_addr, wchar=wchar)
|
|
16
|
-
maxlen =
|
|
18
|
+
maxlen = claripy.BVV(max(a_strlen.max_null_index, b_strlen.max_null_index), self.state.arch.bits)
|
|
17
19
|
|
|
18
20
|
strncmp = self.inline_call(
|
|
19
21
|
angr.SIM_PROCEDURES["libc"]["strncmp"],
|
angr/procedures/libc/strlen.py
CHANGED
|
@@ -16,10 +16,10 @@ class strlen(angr.SimProcedure):
|
|
|
16
16
|
|
|
17
17
|
def run(self, s, wchar=False, maxlen=None):
|
|
18
18
|
if wchar:
|
|
19
|
-
null_seq =
|
|
19
|
+
null_seq = claripy.BVV(0, 16)
|
|
20
20
|
char_size = 2
|
|
21
21
|
else:
|
|
22
|
-
null_seq =
|
|
22
|
+
null_seq = claripy.BVV(0, 8)
|
|
23
23
|
char_size = 1
|
|
24
24
|
|
|
25
25
|
max_symbolic_bytes = self.state.libc.buf_symbolic_bytes
|
|
@@ -38,7 +38,7 @@ class strlen(angr.SimProcedure):
|
|
|
38
38
|
addr_desc: AbstractAddressDescriptor = self.state.memory._normalize_address(s)
|
|
39
39
|
|
|
40
40
|
# size_t
|
|
41
|
-
length =
|
|
41
|
+
length = claripy.ESI(self.arch.bits)
|
|
42
42
|
for s_aw in self.state.memory._concretize_address_descriptor(addr_desc, None):
|
|
43
43
|
s_ptr = s_aw.to_valueset(self.state)
|
|
44
44
|
r, c, i = self.state.memory.find(
|