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
angr/sim_type.py
CHANGED
|
@@ -335,7 +335,7 @@ class SimTypeReg(SimType):
|
|
|
335
335
|
if value.size() != self.size:
|
|
336
336
|
raise ValueError("size of expression is wrong size for type")
|
|
337
337
|
elif isinstance(value, int):
|
|
338
|
-
value =
|
|
338
|
+
value = claripy.BVV(value, self.size)
|
|
339
339
|
elif isinstance(value, bytes):
|
|
340
340
|
store_endness = "Iend_BE"
|
|
341
341
|
else:
|
|
@@ -527,7 +527,7 @@ class SimTypeChar(SimTypeReg):
|
|
|
527
527
|
super().store(state, addr, value)
|
|
528
528
|
except TypeError:
|
|
529
529
|
if isinstance(value, bytes) and len(value) == 1:
|
|
530
|
-
value =
|
|
530
|
+
value = claripy.BVV(value[0], state.arch.byte_width)
|
|
531
531
|
super().store(state, addr, value)
|
|
532
532
|
else:
|
|
533
533
|
raise
|
|
@@ -580,7 +580,7 @@ class SimTypeWideChar(SimTypeReg):
|
|
|
580
580
|
super().store(state, addr, value)
|
|
581
581
|
except TypeError:
|
|
582
582
|
if isinstance(value, bytes) and len(value) == 2:
|
|
583
|
-
value =
|
|
583
|
+
value = claripy.BVV(value[0], state.arch.byte_width)
|
|
584
584
|
super().store(state, addr, value)
|
|
585
585
|
else:
|
|
586
586
|
raise
|
angr/simos/cgc.py
CHANGED
|
@@ -51,7 +51,7 @@ class SimCGC(SimUserland):
|
|
|
51
51
|
if flag_page is None:
|
|
52
52
|
flag_page = [s.solver.BVS("cgc-flag-byte-%d" % i, 8, key=("flag", i), eternal=True) for i in range(0x1000)]
|
|
53
53
|
elif type(flag_page) is bytes:
|
|
54
|
-
flag_page = [
|
|
54
|
+
flag_page = [claripy.BVV(c, 8) for c in flag_page]
|
|
55
55
|
elif type(flag_page) is list:
|
|
56
56
|
pass
|
|
57
57
|
else:
|
|
@@ -93,7 +93,7 @@ class SimCGC(SimUserland):
|
|
|
93
93
|
for size in writes_backer:
|
|
94
94
|
if size == 0:
|
|
95
95
|
continue
|
|
96
|
-
str_to_write =
|
|
96
|
+
str_to_write = claripy.BVS("file_write", size * 8)
|
|
97
97
|
a = SimActionData(
|
|
98
98
|
state, "file_1_0", "write", addr=claripy.BVV(pos, state.arch.bits), data=str_to_write, size=size
|
|
99
99
|
)
|
angr/simos/simos.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import struct
|
|
3
3
|
|
|
4
|
-
import angr # for types
|
|
5
|
-
|
|
6
|
-
import claripy
|
|
7
4
|
from archinfo import ArchMIPS32, ArchS390X
|
|
5
|
+
import claripy
|
|
8
6
|
|
|
7
|
+
import angr
|
|
9
8
|
from ..errors import (
|
|
10
9
|
AngrCallableError,
|
|
11
10
|
AngrCallableMultistateError,
|
|
@@ -179,7 +178,7 @@ class SimOS:
|
|
|
179
178
|
for reg in state.arch.default_symbolic_registers:
|
|
180
179
|
state.registers.store(
|
|
181
180
|
reg,
|
|
182
|
-
|
|
181
|
+
claripy.BVS(
|
|
183
182
|
initial_prefix + "_" + reg, state.arch.bits, explicit_name=True, key=("reg", reg), eternal=True
|
|
184
183
|
),
|
|
185
184
|
)
|
|
@@ -437,6 +436,8 @@ class SimOS:
|
|
|
437
436
|
|
|
438
437
|
|
|
439
438
|
class GlobalDescriptorTable:
|
|
439
|
+
"""GlobalDescriptorTable object to store the GDT table and the segment registers values"""
|
|
440
|
+
|
|
440
441
|
def __init__(self, addr, limit, table, gdt_sel, cs_sel, ds_sel, es_sel, ss_sel, fs_sel, gs_sel):
|
|
441
442
|
self.addr = addr
|
|
442
443
|
self.limit = limit
|
angr/simos/windows.py
CHANGED
|
@@ -170,7 +170,7 @@ class SimWindows(SimOS):
|
|
|
170
170
|
state.mem[state.regs.sp].dword = return_addr
|
|
171
171
|
|
|
172
172
|
# first argument appears to be PEB
|
|
173
|
-
tib_addr = state.regs.fs.concat(
|
|
173
|
+
tib_addr = state.regs.fs.concat(claripy.BVV(0, 16))
|
|
174
174
|
peb_addr = state.mem[tib_addr + 0x30].dword.resolved
|
|
175
175
|
state.mem[state.regs.sp + 4].dword = peb_addr
|
|
176
176
|
|
|
@@ -377,7 +377,7 @@ class SimWindows(SimOS):
|
|
|
377
377
|
|
|
378
378
|
# first check that we actually have an exception handler
|
|
379
379
|
# we check is_true since if it's symbolic this is exploitable maybe?
|
|
380
|
-
tib_addr = exc_state.regs._fs.concat(
|
|
380
|
+
tib_addr = exc_state.regs._fs.concat(claripy.BVV(0, 16))
|
|
381
381
|
if exc_state.solver.is_true(exc_state.mem[tib_addr].long.resolved == -1):
|
|
382
382
|
_l.debug("... no handlers registered")
|
|
383
383
|
exception.args = ("Unhandled exception: %r" % exception,)
|
|
@@ -419,7 +419,7 @@ class SimWindows(SimOS):
|
|
|
419
419
|
|
|
420
420
|
# let's go let's go!
|
|
421
421
|
# we want to use a true guard here. if it's not true, then it's already been added in windup.
|
|
422
|
-
successors.add_successor(exc_state, self._exception_handler,
|
|
422
|
+
successors.add_successor(exc_state, self._exception_handler, claripy.true, "Ijk_Exception")
|
|
423
423
|
successors.processed = True
|
|
424
424
|
|
|
425
425
|
# these two methods load and store register state from a struct CONTEXT
|
|
@@ -433,8 +433,8 @@ class SimWindows(SimOS):
|
|
|
433
433
|
state.mem[addr + 0].uint32_t = 0x07 # contextflags = control | integer | segments
|
|
434
434
|
# dr0 - dr7 are at 0x4-0x18
|
|
435
435
|
# fp state is at 0x1c: 8 ulongs plus a char[80] gives it size 0x70
|
|
436
|
-
state.mem[addr + 0x8C].uint32_t = state.regs.gs.concat(
|
|
437
|
-
state.mem[addr + 0x90].uint32_t = state.regs.fs.concat(
|
|
436
|
+
state.mem[addr + 0x8C].uint32_t = state.regs.gs.concat(claripy.BVV(0, 16))
|
|
437
|
+
state.mem[addr + 0x90].uint32_t = state.regs.fs.concat(claripy.BVV(0, 16))
|
|
438
438
|
state.mem[addr + 0x94].uint32_t = 0 # es
|
|
439
439
|
state.mem[addr + 0x98].uint32_t = 0 # ds
|
|
440
440
|
state.mem[addr + 0x9C].uint32_t = state.regs.edi
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
1
5
|
from angr.errors import SimSolverError
|
|
2
6
|
from ..plugin import SimStatePlugin
|
|
3
7
|
from . import SimHeapBase
|
|
4
8
|
|
|
5
|
-
import logging
|
|
6
|
-
|
|
7
9
|
l = logging.getLogger(__name__)
|
|
8
10
|
|
|
9
11
|
|
|
@@ -92,7 +94,7 @@ class SimHeapBrk(SimHeapBase):
|
|
|
92
94
|
final_size = plugin.max_variable_size
|
|
93
95
|
|
|
94
96
|
addr = self.state.heap.allocate(final_size)
|
|
95
|
-
v =
|
|
97
|
+
v = claripy.BVV(0, final_size * 8)
|
|
96
98
|
self.state.memory.store(addr, v)
|
|
97
99
|
return addr
|
|
98
100
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
1
5
|
from ..plugin import SimStatePlugin
|
|
2
6
|
from .heap_freelist import SimHeapFreelist, Chunk
|
|
3
7
|
from .utils import concretize
|
|
4
|
-
|
|
5
8
|
from ...errors import SimHeapError, SimMergeError, SimSolverError
|
|
6
9
|
|
|
7
10
|
|
|
8
|
-
import logging
|
|
9
|
-
|
|
10
11
|
l = logging.getLogger("angr.state_plugins.heap.heap_ptmalloc")
|
|
11
12
|
sml = logging.getLogger("angr.state_plugins.symbolic_memory")
|
|
12
13
|
|
|
@@ -526,7 +527,7 @@ class SimHeapPTMalloc(SimHeapFreelist):
|
|
|
526
527
|
if addr == 0:
|
|
527
528
|
return 0
|
|
528
529
|
if size != 0:
|
|
529
|
-
z =
|
|
530
|
+
z = claripy.BVV(0, size * 8)
|
|
530
531
|
self.state.memory.store(addr, z)
|
|
531
532
|
return addr
|
|
532
533
|
|
angr/state_plugins/history.py
CHANGED
|
@@ -140,17 +140,19 @@ class SimStateHistory(SimStatePlugin):
|
|
|
140
140
|
self.parent = common_ancestor if common_ancestor is not None else self.parent
|
|
141
141
|
|
|
142
142
|
# rebuild recent constraints
|
|
143
|
-
recent_constraints = [
|
|
143
|
+
recent_constraints = [
|
|
144
|
+
[c.ast for c in h.constraints_since(common_ancestor)] for h in itertools.chain([self], others)
|
|
145
|
+
]
|
|
144
146
|
if sim_options.SIMPLIFY_MERGED_CONSTRAINTS in self.state.options:
|
|
145
|
-
combined_constraint =
|
|
147
|
+
combined_constraint = claripy.Or(
|
|
146
148
|
*[
|
|
147
|
-
self.state.solver.simplify(
|
|
149
|
+
self.state.solver.simplify(claripy.And(*history_constraints))
|
|
148
150
|
for history_constraints in recent_constraints
|
|
149
151
|
]
|
|
150
152
|
)
|
|
151
153
|
else:
|
|
152
|
-
combined_constraint =
|
|
153
|
-
*[
|
|
154
|
+
combined_constraint = claripy.Or(
|
|
155
|
+
*[claripy.And(*history_constraints) for history_constraints in recent_constraints]
|
|
154
156
|
)
|
|
155
157
|
self.recent_events = [
|
|
156
158
|
e.recent_events for e in itertools.chain([self], others) if not isinstance(e, SimActionConstraint)
|
|
@@ -118,7 +118,7 @@ class SimLightRegisters(SimStatePlugin):
|
|
|
118
118
|
raise SimFastMemoryError("Invalid register store value") from None
|
|
119
119
|
|
|
120
120
|
if type(value) is int:
|
|
121
|
-
value =
|
|
121
|
+
value = claripy.BVV(value, xsize)
|
|
122
122
|
|
|
123
123
|
if endness is not None and endness != self.state.arch.register_endness:
|
|
124
124
|
# ???????
|
|
@@ -142,7 +142,7 @@ class SimLightRegisters(SimStatePlugin):
|
|
|
142
142
|
def _fill(self, name, size):
|
|
143
143
|
size_bits = size * self.state.arch.byte_width
|
|
144
144
|
if options.ZERO_FILL_UNCONSTRAINED_REGISTERS in self.state.options:
|
|
145
|
-
value =
|
|
145
|
+
value = claripy.BVV(0, size_bits)
|
|
146
146
|
else:
|
|
147
147
|
if options.SYMBOL_FILL_UNCONSTRAINED_REGISTERS not in self.state.options:
|
|
148
148
|
if once("mem_fill_warning"):
|
angr/state_plugins/plugin.py
CHANGED
|
@@ -98,8 +98,8 @@ class SimStatePlugin:
|
|
|
98
98
|
``state.solver.union(values)``.
|
|
99
99
|
TODO: fish please make this less bullshit
|
|
100
100
|
|
|
101
|
-
There is a utility ``
|
|
102
|
-
Use it like ``self.bar =
|
|
101
|
+
There is a utility ``claripy.ite_cases`` which will help with constructing arbitrarily large merged ASTs.
|
|
102
|
+
Use it like ``self.bar = claripy.ite_cases(zip(conditions[1:], [o.bar for o in others]), self.bar)``
|
|
103
103
|
|
|
104
104
|
:param others: the other state plugins to merge with
|
|
105
105
|
:param merge_conditions: a symbolic condition for each of the plugins
|
angr/state_plugins/posix.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import claripy
|
|
4
|
+
|
|
3
5
|
from .plugin import SimStatePlugin
|
|
4
6
|
from .filesystem import SimMount, Stat
|
|
5
7
|
from ..storage.file import SimFile, SimPacketsStream, Flags, SimFileDescriptor, SimFileDescriptorDuplex
|
|
@@ -239,11 +241,11 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
239
241
|
def set_brk(self, new_brk):
|
|
240
242
|
# arch word size is not available at init for some reason, fix that here
|
|
241
243
|
if isinstance(self.brk, int):
|
|
242
|
-
self.brk =
|
|
244
|
+
self.brk = claripy.BVV(self.brk, self.state.arch.bits)
|
|
243
245
|
|
|
244
246
|
if new_brk.symbolic:
|
|
245
247
|
l.warning("Program is requesting a symbolic brk! This cannot be emulated cleanly!")
|
|
246
|
-
self.brk =
|
|
248
|
+
self.brk = claripy.If(new_brk < self.brk, self.brk, new_brk)
|
|
247
249
|
|
|
248
250
|
else:
|
|
249
251
|
conc_start = self.state.solver.eval(self.brk)
|
|
@@ -342,7 +344,7 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
342
344
|
if not create_file:
|
|
343
345
|
if options.ALL_FILES_EXIST not in self.state.options:
|
|
344
346
|
if options.ANY_FILE_MIGHT_EXIST in self.state.options:
|
|
345
|
-
file_exists =
|
|
347
|
+
file_exists = claripy.BoolS("file_exists_%s" % ident, explicit_name=True)
|
|
346
348
|
else:
|
|
347
349
|
return -1
|
|
348
350
|
else:
|
|
@@ -369,8 +371,8 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
369
371
|
if self.state.solver.is_true(simfd.file_exists):
|
|
370
372
|
return fd
|
|
371
373
|
else:
|
|
372
|
-
m1 =
|
|
373
|
-
return
|
|
374
|
+
m1 = claripy.BVV(-1, self.state.arch.sizeof["int"])
|
|
375
|
+
return claripy.If(simfd.file_exists, fd, m1)
|
|
374
376
|
|
|
375
377
|
def open_socket(self, ident):
|
|
376
378
|
fd = self._pick_fd()
|
|
@@ -513,8 +515,8 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
513
515
|
else:
|
|
514
516
|
if options.ALL_FILES_EXIST not in self.state.options:
|
|
515
517
|
if options.ANY_FILE_MIGHT_EXIST in self.state.options:
|
|
516
|
-
m1 =
|
|
517
|
-
result =
|
|
518
|
+
m1 = claripy.BVV(-1, self.state.arch.bits)
|
|
519
|
+
result = claripy.If(claripy.BoolS("file_exists"), 0, m1)
|
|
518
520
|
else:
|
|
519
521
|
result = -1
|
|
520
522
|
else:
|
|
@@ -536,7 +538,7 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
536
538
|
mode = (
|
|
537
539
|
self.state.solver.BVS("st_mode", 32, key=("api", "fstat", "st_mode"))
|
|
538
540
|
if fd > 2
|
|
539
|
-
else
|
|
541
|
+
else claripy.BVV(0, 32)
|
|
540
542
|
)
|
|
541
543
|
size = self.state.solver.BVS("st_size", 64, key=("api", "fstat", "st_size")) # st_size
|
|
542
544
|
ino = 0
|
|
@@ -544,22 +546,22 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
544
546
|
# return this weird bogus zero value to keep code paths in libc simple :\
|
|
545
547
|
return (
|
|
546
548
|
Stat(
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
549
|
+
claripy.BVV(0, 64), # st_dev
|
|
550
|
+
claripy.BVV(ino, 64), # st_ino
|
|
551
|
+
claripy.BVV(0, 64), # st_nlink
|
|
550
552
|
mode, # st_mode
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
553
|
+
claripy.BVV(0, 32), # st_uid (lol root)
|
|
554
|
+
claripy.BVV(0, 32), # st_gid
|
|
555
|
+
claripy.BVV(0, 64), # st_rdev
|
|
554
556
|
size, # st_size
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
claripy.BVV(0x400, 64), # st_blksize
|
|
558
|
+
claripy.BVV(0, 64), # st_blocks
|
|
559
|
+
claripy.BVV(0, 64), # st_atime
|
|
560
|
+
claripy.BVV(0, 64), # st_atimensec
|
|
561
|
+
claripy.BVV(0, 64), # st_mtime
|
|
562
|
+
claripy.BVV(0, 64), # st_mtimensec
|
|
563
|
+
claripy.BVV(0, 64), # st_ctime
|
|
564
|
+
claripy.BVV(0, 64), # st_ctimensec
|
|
563
565
|
),
|
|
564
566
|
result,
|
|
565
567
|
)
|
|
@@ -594,15 +596,15 @@ class SimSystemPosix(SimStatePlugin):
|
|
|
594
596
|
:param valid_ptr: is set if the new_mask was not NULL
|
|
595
597
|
"""
|
|
596
598
|
oldmask = self.sigmask(sigsetsize)
|
|
597
|
-
self._sigmask =
|
|
599
|
+
self._sigmask = claripy.If(
|
|
598
600
|
valid_ptr,
|
|
599
|
-
|
|
601
|
+
claripy.If(
|
|
600
602
|
how == self.SIG_BLOCK,
|
|
601
603
|
oldmask | new_mask,
|
|
602
|
-
|
|
604
|
+
claripy.If(
|
|
603
605
|
how == self.SIG_UNBLOCK,
|
|
604
606
|
oldmask & (~new_mask),
|
|
605
|
-
|
|
607
|
+
claripy.If(how == self.SIG_SETMASK, new_mask, oldmask),
|
|
606
608
|
),
|
|
607
609
|
),
|
|
608
610
|
oldmask,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
|
|
2
3
|
import claripy
|
|
3
4
|
|
|
4
5
|
from .plugin import SimStatePlugin
|
|
@@ -52,7 +53,7 @@ class SimStatePreconstrainer(SimStatePlugin):
|
|
|
52
53
|
:param variable: The BVS to preconstrain.
|
|
53
54
|
"""
|
|
54
55
|
if not isinstance(value, claripy.ast.Base):
|
|
55
|
-
value =
|
|
56
|
+
value = claripy.BVV(value, len(variable))
|
|
56
57
|
elif value.op != "BVV":
|
|
57
58
|
raise ValueError("Passed a value to preconstrain that was not a BVV or a string")
|
|
58
59
|
|
angr/state_plugins/solver.py
CHANGED
|
@@ -4,11 +4,12 @@ import logging
|
|
|
4
4
|
import os
|
|
5
5
|
from typing import TypeVar, overload
|
|
6
6
|
|
|
7
|
-
from angr import sim_options as o
|
|
8
|
-
from angr.errors import SimValueError, SimUnsatError, SimSolverModeError, SimSolverOptionError
|
|
9
7
|
import claripy
|
|
10
8
|
from claripy import backend_manager
|
|
11
9
|
|
|
10
|
+
from angr import sim_options as o
|
|
11
|
+
from angr.errors import SimValueError, SimUnsatError, SimSolverModeError, SimSolverOptionError
|
|
12
|
+
from angr.sim_state import SimState
|
|
12
13
|
from .plugin import SimStatePlugin
|
|
13
14
|
from .sim_action_object import ast_stripping_decorator, SimActionObject
|
|
14
15
|
|
|
@@ -234,13 +235,16 @@ class SimSolver(SimStatePlugin):
|
|
|
234
235
|
[(('mem', 0x1000), <BV64 mem_1000_4_64>), (('mem', 0x1008), <BV64 mem_1008_5_64>)]
|
|
235
236
|
|
|
236
237
|
>>> list(s.solver.get_variables('file'))
|
|
237
|
-
[(('file', 1, 0), <BV8 file_1_0_6_8>), (('file', 1, 1), <BV8 file_1_1_7_8>),
|
|
238
|
+
[(('file', 1, 0), <BV8 file_1_0_6_8>), (('file', 1, 1), <BV8 file_1_1_7_8>),
|
|
239
|
+
(('file', 2, 0), <BV8 file_2_0_8_8>)]
|
|
238
240
|
|
|
239
241
|
>>> list(s.solver.get_variables('file', 2))
|
|
240
242
|
[(('file', 2, 0), <BV8 file_2_0_8_8>)]
|
|
241
243
|
|
|
242
244
|
>>> list(s.solver.get_variables())
|
|
243
|
-
[(('mem', 0x1000), <BV64 mem_1000_4_64>), (('mem', 0x1008), <BV64 mem_1008_5_64>),
|
|
245
|
+
[(('mem', 0x1000), <BV64 mem_1000_4_64>), (('mem', 0x1008), <BV64 mem_1008_5_64>),
|
|
246
|
+
(('file', 1, 0), <BV8 file_1_0_6_8>), (('file', 1, 1), <BV8 file_1_1_7_8>),
|
|
247
|
+
(('file', 2, 0), <BV8 file_2_0_8_8>)]
|
|
244
248
|
"""
|
|
245
249
|
for k, v in self.eternal_tracked_variables.items():
|
|
246
250
|
if len(k) >= len(keys) and all(x == y for x, y in zip(keys, k)):
|
|
@@ -464,24 +468,6 @@ class SimSolver(SimStatePlugin):
|
|
|
464
468
|
self.all_variables.append(r)
|
|
465
469
|
return r
|
|
466
470
|
|
|
467
|
-
#
|
|
468
|
-
# Operation passthroughs to claripy
|
|
469
|
-
#
|
|
470
|
-
|
|
471
|
-
def __getattr__(self, a):
|
|
472
|
-
f = getattr(claripy._all_operations, a)
|
|
473
|
-
if hasattr(f, "__call__"):
|
|
474
|
-
ff = error_converter(ast_stripping_decorator(f))
|
|
475
|
-
if _timing_enabled:
|
|
476
|
-
ff = functools.partial(timed_function(ff), the_solver=self)
|
|
477
|
-
ff.__doc__ = f.__doc__
|
|
478
|
-
return ff
|
|
479
|
-
else:
|
|
480
|
-
return f
|
|
481
|
-
|
|
482
|
-
def __dir__(self):
|
|
483
|
-
return sorted(set(dir(super()) + dir(claripy._all_operations) + dir(self.__class__)))
|
|
484
|
-
|
|
485
471
|
#
|
|
486
472
|
# Branching stuff
|
|
487
473
|
#
|
|
@@ -508,7 +494,7 @@ class SimSolver(SimStatePlugin):
|
|
|
508
494
|
|
|
509
495
|
@error_converter
|
|
510
496
|
def widen(self, others):
|
|
511
|
-
c =
|
|
497
|
+
c = claripy.BVS("random_widen_condition", 32)
|
|
512
498
|
merge_conditions = [[c == i] for i in range(len(others) + 1)]
|
|
513
499
|
merging_occurred = self.merge(others, merge_conditions)
|
|
514
500
|
return merging_occurred
|
|
@@ -538,7 +524,7 @@ class SimSolver(SimStatePlugin):
|
|
|
538
524
|
l.critical("PLEASE REPORT THIS MESSAGE, AND WHAT YOU WERE DOING, TO YAN")
|
|
539
525
|
return self.state._global_condition
|
|
540
526
|
else:
|
|
541
|
-
return
|
|
527
|
+
return claripy.Or(claripy.Not(self.state._global_condition), c)
|
|
542
528
|
|
|
543
529
|
def _adjust_constraint_list(self, constraints):
|
|
544
530
|
if self.state._global_condition is None:
|
|
@@ -546,7 +532,7 @@ class SimSolver(SimStatePlugin):
|
|
|
546
532
|
if len(constraints) == 0:
|
|
547
533
|
return constraints.__class__((self.state._global_condition,))
|
|
548
534
|
else:
|
|
549
|
-
return constraints.__class__((self._adjust_constraint(
|
|
535
|
+
return constraints.__class__((self._adjust_constraint(claripy.And(*constraints)),))
|
|
550
536
|
|
|
551
537
|
@timed_function
|
|
552
538
|
@ast_stripping_decorator
|
|
@@ -1108,8 +1094,6 @@ class SimSolver(SimStatePlugin):
|
|
|
1108
1094
|
return e.variables
|
|
1109
1095
|
|
|
1110
1096
|
|
|
1111
|
-
from angr.sim_state import SimState
|
|
1112
|
-
|
|
1113
1097
|
SimState.register_default("solver", SimSolver)
|
|
1114
1098
|
|
|
1115
1099
|
from .inspect import BP_AFTER
|
|
@@ -196,7 +196,7 @@ def end_info_hook(state):
|
|
|
196
196
|
if pending_info.get_type() == "StrToInt":
|
|
197
197
|
# mark the input
|
|
198
198
|
input_val = state.mem[pending_info.input_val].string.resolved
|
|
199
|
-
result =
|
|
199
|
+
result = claripy.BVV(state.solver.eval(state.regs.eax, cast_to=bytes))
|
|
200
200
|
real_len = chall_resp_plugin.get_real_len(
|
|
201
201
|
input_val, pending_info.input_base, result, pending_info.allows_negative
|
|
202
202
|
)
|
|
@@ -207,7 +207,7 @@ def end_info_hook(state):
|
|
|
207
207
|
return
|
|
208
208
|
|
|
209
209
|
# result constraint
|
|
210
|
-
new_var =
|
|
210
|
+
new_var = claripy.BVS(pending_info.get_type() + "_" + str(pending_info.input_base) + "_result", 32)
|
|
211
211
|
constraint = new_var == result
|
|
212
212
|
chall_resp_plugin.replacement_pairs.append((new_var, state.regs.eax))
|
|
213
213
|
state.regs.eax = new_var
|
|
@@ -215,7 +215,7 @@ def end_info_hook(state):
|
|
|
215
215
|
# finish marking the input
|
|
216
216
|
input_val = state.memory.load(pending_info.input_val, real_len)
|
|
217
217
|
l.debug("string len was %d, value was %d", real_len, state.solver.eval(result))
|
|
218
|
-
input_bvs =
|
|
218
|
+
input_bvs = claripy.BVS(
|
|
219
219
|
pending_info.get_type() + "_" + str(pending_info.input_base) + "_input", input_val.size()
|
|
220
220
|
)
|
|
221
221
|
chall_resp_plugin.str_to_int_pairs.append((input_bvs, new_var))
|
|
@@ -224,23 +224,19 @@ def end_info_hook(state):
|
|
|
224
224
|
chall_resp_plugin.replacement_pairs.append((input_bvs, input_val))
|
|
225
225
|
elif pending_info.get_type() == "IntToStr":
|
|
226
226
|
# result constraint
|
|
227
|
-
result = state.solver.
|
|
228
|
-
state.solver.eval(state.mem[pending_info.str_dst_addr].string.resolved, cast_to=bytes)
|
|
229
|
-
)
|
|
227
|
+
result = claripy.BVV(state.solver.eval(state.mem[pending_info.str_dst_addr].string.resolved, cast_to=bytes))
|
|
230
228
|
if result is None or result.size() == 0:
|
|
231
229
|
l.warning("zero len string")
|
|
232
230
|
chall_resp_plugin.pop_from_backup()
|
|
233
231
|
return
|
|
234
|
-
new_var =
|
|
235
|
-
pending_info.get_type() + "_" + str(pending_info.input_base) + "_result", result.size()
|
|
236
|
-
)
|
|
232
|
+
new_var = claripy.BVS(pending_info.get_type() + "_" + str(pending_info.input_base) + "_result", result.size())
|
|
237
233
|
chall_resp_plugin.replacement_pairs.append((new_var, state.mem[pending_info.str_dst_addr].string.resolved))
|
|
238
234
|
state.memory.store(pending_info.str_dst_addr, new_var)
|
|
239
235
|
constraint = new_var == result
|
|
240
236
|
|
|
241
237
|
# mark the input
|
|
242
238
|
input_val = pending_info.input_val
|
|
243
|
-
input_bvs =
|
|
239
|
+
input_bvs = claripy.BVS(pending_info.get_type() + "_" + str(pending_info.input_base) + "_input", 32)
|
|
244
240
|
chall_resp_plugin.int_to_str_pairs.append((input_bvs, new_var))
|
|
245
241
|
chall_resp_plugin.replacement_pairs.append((input_bvs, input_val))
|
|
246
242
|
# here we need the constraint that the input was equal to the StrToInt_input
|
|
@@ -298,8 +294,8 @@ def syscall_hook(state):
|
|
|
298
294
|
num_bytes = state.solver.eval(state.regs.ecx)
|
|
299
295
|
buf = state.solver.eval(state.regs.ebx)
|
|
300
296
|
if num_bytes != 0:
|
|
301
|
-
rand_bytes =
|
|
302
|
-
concrete_val =
|
|
297
|
+
rand_bytes = claripy.BVS("random", num_bytes * 8)
|
|
298
|
+
concrete_val = claripy.BVV("A" * num_bytes)
|
|
303
299
|
state.solver._solver.add_replacement(rand_bytes, concrete_val, invalidate_cache=False)
|
|
304
300
|
state.memory.store(buf, rand_bytes)
|
|
305
301
|
|
|
@@ -509,7 +505,7 @@ class ChallRespInfo(angr.state_plugins.SimStatePlugin):
|
|
|
509
505
|
solns = solns[0]
|
|
510
506
|
|
|
511
507
|
# now make the real stdin
|
|
512
|
-
stdin = state.solver.eval(
|
|
508
|
+
stdin = state.solver.eval(claripy.BVV(solns[0], pos * 8), cast_to=bytes)
|
|
513
509
|
|
|
514
510
|
stdin_replacements = []
|
|
515
511
|
for soln, (_, int_var) in zip(solns[1:], chall_resp_plugin.str_to_int_pairs):
|
angr/state_plugins/uc_manager.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import claripy
|
|
4
4
|
|
|
5
5
|
from .plugin import SimStatePlugin
|
|
6
6
|
from ..errors import SimUCManagerAllocationError
|
|
7
7
|
|
|
8
|
+
l = logging.getLogger(name=__name__)
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
class SimUCManager(SimStatePlugin):
|
|
10
12
|
def __init__(self, man=None):
|
|
@@ -45,7 +47,7 @@ class SimUCManager(SimStatePlugin):
|
|
|
45
47
|
)
|
|
46
48
|
|
|
47
49
|
abs_addr = self._region_base + self._pos
|
|
48
|
-
ptr =
|
|
50
|
+
ptr = claripy.BVV(abs_addr, self.state.arch.bits)
|
|
49
51
|
self._pos += self._region_size
|
|
50
52
|
|
|
51
53
|
self._alloc_depth_map[(abs_addr - self._region_base) // self._region_size] = dst_addr_ast.uc_alloc_depth
|
|
@@ -1791,7 +1791,7 @@ class Unicorn(SimStatePlugin):
|
|
|
1791
1791
|
# some architecture-specific register fixups
|
|
1792
1792
|
if state.arch.name in {"X86", "AMD64"}:
|
|
1793
1793
|
# update the eflags
|
|
1794
|
-
state.regs.eflags =
|
|
1794
|
+
state.regs.eflags = claripy.BVV(self.uc.reg_read(self._uc_const.UC_X86_REG_EFLAGS), state.arch.bits)
|
|
1795
1795
|
|
|
1796
1796
|
# sync the fp clerical data
|
|
1797
1797
|
status = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPSW)
|
angr/state_plugins/view.py
CHANGED
|
@@ -157,7 +157,7 @@ class SimMemView(SimStatePlugin):
|
|
|
157
157
|
|
|
158
158
|
# Make sure self._addr is always an AST
|
|
159
159
|
if isinstance(self._addr, int):
|
|
160
|
-
self._addr =
|
|
160
|
+
self._addr = claripy.BVV(self._addr, self.state.arch.bits)
|
|
161
161
|
|
|
162
162
|
def _deeper(self, **kwargs) -> "SimMemView":
|
|
163
163
|
if "ty" not in kwargs:
|