angr 9.2.116__py3-none-manylinux2014_x86_64.whl → 9.2.117__py3-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of angr might be problematic. Click here for more details.
- angr/__init__.py +1 -1
- angr/analyses/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/identifier/functions/free.py +3 -1
- angr/analyses/identifier/identify.py +13 -15
- angr/analyses/identifier/runner.py +2 -2
- 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/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/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/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.116.dist-info → angr-9.2.117.dist-info}/METADATA +6 -6
- {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/RECORD +143 -143
- {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/WHEEL +1 -1
- {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/LICENSE +0 -0
- {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/entry_points.txt +0 -0
- {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/top_level.txt +0 -0
|
@@ -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(
|
angr/procedures/libc/strncmp.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
|
|
|
@@ -50,9 +52,9 @@ class strncmp(angr.SimProcedure):
|
|
|
50
52
|
maxlen = max(a_strlen.max_null_index, b_strlen.max_null_index)
|
|
51
53
|
|
|
52
54
|
match_constraints.append(
|
|
53
|
-
|
|
55
|
+
claripy.Or(
|
|
54
56
|
a_len == b_len,
|
|
55
|
-
|
|
57
|
+
claripy.And(claripy.UGE(a_len, limit), claripy.UGE(b_len, limit)),
|
|
56
58
|
)
|
|
57
59
|
)
|
|
58
60
|
|
|
@@ -62,7 +64,7 @@ class strncmp(angr.SimProcedure):
|
|
|
62
64
|
if self.state.solver.single_valued(limit) and self.state.solver.eval(limit) == 0:
|
|
63
65
|
# limit is 0
|
|
64
66
|
l.debug("returning equal for 0-limit")
|
|
65
|
-
return
|
|
67
|
+
return claripy.BVV(0, 32)
|
|
66
68
|
elif (
|
|
67
69
|
self.state.solver.single_valued(a_len)
|
|
68
70
|
and self.state.solver.single_valued(b_len)
|
|
@@ -70,14 +72,14 @@ class strncmp(angr.SimProcedure):
|
|
|
70
72
|
):
|
|
71
73
|
# two empty strings
|
|
72
74
|
l.debug("returning equal for two empty strings")
|
|
73
|
-
return
|
|
75
|
+
return claripy.BVV(0, 32)
|
|
74
76
|
else:
|
|
75
77
|
# all other cases fall into this branch
|
|
76
78
|
l.debug("returning non-equal for comparison of an empty string and a non-empty string")
|
|
77
79
|
if a_strlen.max_null_index == 0:
|
|
78
|
-
return
|
|
80
|
+
return claripy.BVV(-1, 32)
|
|
79
81
|
else:
|
|
80
|
-
return
|
|
82
|
+
return claripy.BVV(1, 32)
|
|
81
83
|
|
|
82
84
|
# the bytes
|
|
83
85
|
max_byte_len = maxlen * char_size
|
|
@@ -111,9 +113,9 @@ class strncmp(angr.SimProcedure):
|
|
|
111
113
|
if a_conc != b_conc:
|
|
112
114
|
l.debug("... found mis-matching concrete bytes 0x%x and 0x%x", a_conc, b_conc)
|
|
113
115
|
if a_conc < b_conc:
|
|
114
|
-
return
|
|
116
|
+
return claripy.BVV(-1, 32)
|
|
115
117
|
else:
|
|
116
|
-
return
|
|
118
|
+
return claripy.BVV(1, 32)
|
|
117
119
|
else:
|
|
118
120
|
if self.state.mode == "static":
|
|
119
121
|
return_values.append(a_byte - b_byte)
|
|
@@ -122,17 +124,17 @@ class strncmp(angr.SimProcedure):
|
|
|
122
124
|
|
|
123
125
|
if self.state.mode != "static":
|
|
124
126
|
if ignore_case:
|
|
125
|
-
byte_constraint =
|
|
126
|
-
|
|
127
|
+
byte_constraint = claripy.Or(
|
|
128
|
+
claripy.Or(
|
|
127
129
|
a_byte == b_byte,
|
|
128
|
-
|
|
130
|
+
claripy.And(
|
|
129
131
|
ord("A") <= a_byte,
|
|
130
132
|
a_byte <= ord("Z"),
|
|
131
133
|
ord("a") <= b_byte,
|
|
132
134
|
b_byte <= ord("z"),
|
|
133
135
|
b_byte - ord(" ") == a_byte,
|
|
134
136
|
),
|
|
135
|
-
|
|
137
|
+
claripy.And(
|
|
136
138
|
ord("A") <= b_byte,
|
|
137
139
|
b_byte <= ord("Z"),
|
|
138
140
|
ord("a") <= a_byte,
|
|
@@ -140,21 +142,19 @@ class strncmp(angr.SimProcedure):
|
|
|
140
142
|
a_byte - ord(" ") == b_byte,
|
|
141
143
|
),
|
|
142
144
|
),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
claripy.ULT(a_len, i),
|
|
146
|
+
claripy.ULE(limit, i),
|
|
145
147
|
)
|
|
146
148
|
else:
|
|
147
|
-
byte_constraint =
|
|
148
|
-
a_byte == b_byte, self.state.solver.ULT(a_len, i), self.state.solver.ULE(limit, i)
|
|
149
|
-
)
|
|
149
|
+
byte_constraint = claripy.Or(a_byte == b_byte, claripy.ULT(a_len, i), claripy.ULE(limit, i))
|
|
150
150
|
match_constraints.append(byte_constraint)
|
|
151
151
|
|
|
152
152
|
if concrete_run:
|
|
153
153
|
l.debug("concrete run made it to the end!")
|
|
154
|
-
return
|
|
154
|
+
return claripy.BVV(0, 32)
|
|
155
155
|
|
|
156
156
|
if self.state.mode == "static":
|
|
157
|
-
ret_expr =
|
|
157
|
+
ret_expr = claripy.ESI(8)
|
|
158
158
|
for expr in return_values:
|
|
159
159
|
ret_expr = ret_expr.union(expr)
|
|
160
160
|
|
|
@@ -164,17 +164,17 @@ class strncmp(angr.SimProcedure):
|
|
|
164
164
|
# make the constraints
|
|
165
165
|
|
|
166
166
|
l.debug("returning symbolic")
|
|
167
|
-
match_constraint =
|
|
168
|
-
nomatch_constraint =
|
|
167
|
+
match_constraint = claripy.And(*match_constraints)
|
|
168
|
+
nomatch_constraint = claripy.Not(match_constraint)
|
|
169
169
|
|
|
170
170
|
# l.debug("match constraints: %s", match_constraint)
|
|
171
171
|
# l.debug("nomatch constraints: %s", nomatch_constraint)
|
|
172
172
|
|
|
173
|
-
match_case =
|
|
174
|
-
nomatch_case =
|
|
175
|
-
l0_case =
|
|
176
|
-
empty_case =
|
|
173
|
+
match_case = claripy.And(limit != 0, match_constraint, ret_expr == 0)
|
|
174
|
+
nomatch_case = claripy.And(limit != 0, nomatch_constraint, ret_expr == 1)
|
|
175
|
+
l0_case = claripy.And(limit == 0, ret_expr == 0)
|
|
176
|
+
empty_case = claripy.And(a_strlen.ret_expr == 0, b_strlen.ret_expr == 0, ret_expr == 0)
|
|
177
177
|
|
|
178
|
-
self.state.add_constraints(
|
|
178
|
+
self.state.add_constraints(claripy.Or(match_case, nomatch_case, l0_case, empty_case))
|
|
179
179
|
|
|
180
180
|
return ret_expr
|
angr/procedures/libc/strncpy.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
|
|
|
@@ -12,7 +15,7 @@ class strncpy(angr.SimProcedure):
|
|
|
12
15
|
memcpy = angr.SIM_PROCEDURES["libc"]["memcpy"]
|
|
13
16
|
|
|
14
17
|
src_len = src_len if src_len is not None else self.inline_call(strlen, src_addr).ret_expr
|
|
15
|
-
cpy_size =
|
|
18
|
+
cpy_size = claripy.If(claripy.ULE(limit, src_len + 1), limit, src_len + 1)
|
|
16
19
|
|
|
17
20
|
self.inline_call(memcpy, dst_addr, src_addr, cpy_size)
|
|
18
21
|
return dst_addr
|