angr 9.2.118__py3-none-manylinux2014_aarch64.whl → 9.2.119__py3-none-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of angr might be problematic. Click here for more details.
- angr/__init__.py +1 -1
- angr/analyses/analysis.py +43 -1
- angr/analyses/cfg/cfg_fast.py +135 -23
- angr/analyses/decompiler/ail_simplifier.py +1 -1
- angr/analyses/decompiler/clinic.py +23 -12
- angr/analyses/decompiler/condition_processor.py +41 -16
- angr/analyses/decompiler/decompiler.py +3 -0
- angr/analyses/decompiler/jumptable_entry_condition_rewriter.py +1 -1
- angr/analyses/decompiler/optimization_passes/duplication_reverter/ail_merge_graph.py +7 -4
- angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +6 -2
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +19 -19
- angr/analyses/decompiler/structured_codegen/c.py +9 -2
- angr/analyses/decompiler/structuring/dream.py +8 -7
- angr/analyses/decompiler/structuring/phoenix.py +3 -3
- angr/analyses/propagator/engine_ail.py +2 -1
- angr/analyses/reaching_definitions/function_handler.py +6 -2
- angr/analyses/stack_pointer_tracker.py +29 -11
- angr/analyses/typehoon/translator.py +19 -2
- angr/analyses/typehoon/typeconsts.py +8 -0
- angr/analyses/variable_recovery/engine_vex.py +7 -10
- angr/calling_conventions.py +69 -24
- angr/concretization_strategies/norepeats.py +3 -3
- angr/engines/concrete.py +1 -1
- angr/engines/light/engine.py +6 -11
- angr/engines/pcode/engine.py +2 -2
- angr/engines/soot/engine.py +5 -5
- angr/engines/soot/expressions/condition.py +1 -1
- angr/engines/soot/statements/goto.py +1 -1
- angr/engines/soot/statements/if_.py +1 -1
- angr/engines/soot/statements/throw.py +1 -1
- angr/engines/successors.py +1 -1
- angr/engines/unicorn.py +2 -2
- angr/engines/vex/heavy/heavy.py +2 -2
- angr/errors.py +4 -0
- angr/exploration_techniques/driller_core.py +2 -3
- angr/exploration_techniques/suggestions.py +2 -2
- angr/knowledge_plugins/cfg/cfg_model.py +2 -1
- angr/knowledge_plugins/cfg/memory_data.py +1 -0
- angr/misc/telemetry.py +54 -0
- angr/procedures/java/unconstrained.py +1 -1
- angr/procedures/java_jni/__init__.py +21 -13
- angr/procedures/java_jni/string_operations.py +1 -1
- angr/procedures/java_lang/double.py +1 -1
- angr/procedures/java_lang/string.py +1 -1
- angr/procedures/java_util/scanner_nextline.py +1 -1
- angr/procedures/linux_kernel/vsyscall.py +1 -1
- angr/procedures/stubs/Redirect.py +1 -1
- angr/procedures/stubs/UserHook.py +1 -1
- angr/procedures/stubs/format_parser.py +1 -1
- angr/sim_procedure.py +5 -5
- angr/sim_state.py +21 -34
- angr/sim_type.py +42 -0
- angr/simos/javavm.py +7 -12
- angr/simos/linux.py +1 -1
- angr/simos/simos.py +1 -1
- angr/simos/windows.py +1 -1
- angr/state_hierarchy.py +1 -1
- angr/state_plugins/preconstrainer.py +2 -2
- angr/state_plugins/scratch.py +1 -1
- angr/state_plugins/solver.py +1 -1
- angr/state_plugins/trace_additions.py +8 -8
- angr/storage/file.py +12 -12
- angr/storage/memory_mixins/actions_mixin.py +1 -1
- angr/storage/memory_mixins/convenient_mappings_mixin.py +6 -8
- angr/storage/memory_mixins/multi_value_merger_mixin.py +5 -5
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +1 -1
- angr/storage/memory_mixins/size_resolution_mixin.py +1 -1
- angr/storage/memory_mixins/smart_find_mixin.py +2 -2
- angr/storage/memory_object.py +7 -9
- angr/utils/timing.py +30 -18
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/METADATA +8 -6
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/RECORD +76 -75
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/LICENSE +0 -0
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/WHEEL +0 -0
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/entry_points.txt +0 -0
- {angr-9.2.118.dist-info → angr-9.2.119.dist-info}/top_level.txt +0 -0
|
@@ -12,7 +12,7 @@ class UserHook(angr.SimProcedure):
|
|
|
12
12
|
result = user_func(self.state)
|
|
13
13
|
if result is None:
|
|
14
14
|
jumpkind = "Ijk_NoHook" if length == 0 else "Ijk_Boring"
|
|
15
|
-
self.successors.add_successor(self.state, self.state.addr + length, claripy.true, jumpkind)
|
|
15
|
+
self.successors.add_successor(self.state, self.state.addr + length, claripy.true(), jumpkind)
|
|
16
16
|
else:
|
|
17
17
|
for state in result:
|
|
18
18
|
self.successors.add_successor(state, state.addr, state.scratch.guard, state.history.jumpkind)
|
|
@@ -130,7 +130,7 @@ class FormatString:
|
|
|
130
130
|
if type(component) is bytes:
|
|
131
131
|
sdata, _ = simfd.read_data(len(component), short_reads=False)
|
|
132
132
|
self.state.add_constraints(sdata == component)
|
|
133
|
-
elif isinstance(component, claripy.Bits):
|
|
133
|
+
elif isinstance(component, claripy.ast.Bits):
|
|
134
134
|
sdata, _ = simfd.read_data(len(component) // 8, short_reads=False)
|
|
135
135
|
self.state.add_constraints(sdata == component)
|
|
136
136
|
elif component.spec_type == b"s":
|
angr/sim_procedure.py
CHANGED
|
@@ -477,7 +477,7 @@ class SimProcedure:
|
|
|
477
477
|
self._prepare_ret_state()
|
|
478
478
|
|
|
479
479
|
self._exit_action(self.state, ret_addr)
|
|
480
|
-
self.successors.add_successor(self.state, ret_addr, claripy.true, "Ijk_Ret")
|
|
480
|
+
self.successors.add_successor(self.state, ret_addr, claripy.true(), "Ijk_Ret")
|
|
481
481
|
|
|
482
482
|
def call(self, addr, args, continue_at, cc=None, prototype=None, jumpkind="Ijk_Call"):
|
|
483
483
|
"""
|
|
@@ -520,7 +520,7 @@ class SimProcedure:
|
|
|
520
520
|
call_state.regs.t9 = addr
|
|
521
521
|
|
|
522
522
|
self._exit_action(call_state, addr)
|
|
523
|
-
self.successors.add_successor(call_state, addr, claripy.true, jumpkind)
|
|
523
|
+
self.successors.add_successor(call_state, addr, claripy.true(), jumpkind)
|
|
524
524
|
if jumpkind != "Ijk_Call":
|
|
525
525
|
call_state.callstack.call(
|
|
526
526
|
self.state.addr, addr, retn_target=ret_addr, stack_pointer=call_state.regs.sp.concrete_value
|
|
@@ -531,7 +531,7 @@ class SimProcedure:
|
|
|
531
531
|
ret_state = self.state.copy()
|
|
532
532
|
cc.setup_callsite(ret_state, ret_addr, args, prototype)
|
|
533
533
|
ret_state.callstack.top.procedure_data = simcallstack_entry
|
|
534
|
-
guard = claripy.true if o.TRUE_RET_EMULATION_GUARD in ret_state.options else claripy.false
|
|
534
|
+
guard = claripy.true() if o.TRUE_RET_EMULATION_GUARD in ret_state.options else claripy.false()
|
|
535
535
|
self.successors.add_successor(ret_state, ret_addr, guard, "Ijk_FakeRet")
|
|
536
536
|
|
|
537
537
|
def jump(self, addr, jumpkind="Ijk_Boring"):
|
|
@@ -540,7 +540,7 @@ class SimProcedure:
|
|
|
540
540
|
"""
|
|
541
541
|
self.inhibit_autoret = True
|
|
542
542
|
self._exit_action(self.state, addr)
|
|
543
|
-
self.successors.add_successor(self.state, addr, claripy.true, jumpkind)
|
|
543
|
+
self.successors.add_successor(self.state, addr, claripy.true(), jumpkind)
|
|
544
544
|
|
|
545
545
|
def exit(self, exit_code):
|
|
546
546
|
"""
|
|
@@ -553,7 +553,7 @@ class SimProcedure:
|
|
|
553
553
|
if isinstance(exit_code, int):
|
|
554
554
|
exit_code = claripy.BVV(exit_code, self.state.arch.bits)
|
|
555
555
|
self.state.history.add_event("terminate", exit_code=exit_code)
|
|
556
|
-
self.successors.add_successor(self.state, self.state.regs.ip, claripy.true, "Ijk_Exit")
|
|
556
|
+
self.successors.add_successor(self.state, self.state.regs.ip, claripy.true(), "Ijk_Exit")
|
|
557
557
|
|
|
558
558
|
@staticmethod
|
|
559
559
|
def _exit_action(state, addr):
|
angr/sim_state.py
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
2
4
|
import functools
|
|
3
5
|
import itertools
|
|
4
|
-
import contextlib
|
|
5
|
-
import weakref
|
|
6
|
-
|
|
7
6
|
import logging
|
|
8
|
-
|
|
7
|
+
import weakref
|
|
9
8
|
from typing import TypeVar, TYPE_CHECKING
|
|
10
9
|
|
|
11
|
-
from archinfo import Arch
|
|
12
|
-
|
|
13
|
-
l = logging.getLogger(name=__name__)
|
|
14
|
-
|
|
15
|
-
import claripy
|
|
16
10
|
import archinfo
|
|
11
|
+
import claripy
|
|
12
|
+
from archinfo import Arch
|
|
17
13
|
from archinfo.arch_soot import SootAddressDescriptor
|
|
18
14
|
|
|
15
|
+
from . import sim_options as o
|
|
16
|
+
from .errors import SimMergeError, SimValueError, SimStateError, SimSolverModeError
|
|
19
17
|
from .misc.plugins import PluginHub, PluginPreset
|
|
20
18
|
from .sim_state_options import SimStateOptions
|
|
21
19
|
from .state_plugins import SimStatePlugin
|
|
22
20
|
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from .storage import DefaultMemory
|
|
23
|
+
from .state_plugins.solver import SimSolver
|
|
24
|
+
from .state_plugins.posix import SimSystemPosix
|
|
25
|
+
from .state_plugins.view import SimRegNameView, SimMemView
|
|
26
|
+
from .state_plugins.callstack import CallStack
|
|
27
|
+
from .state_plugins.inspect import SimInspector
|
|
28
|
+
from .state_plugins.jni_references import SimStateJNIReferences
|
|
29
|
+
from .state_plugins.scratch import SimStateScratch
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
l = logging.getLogger(name=__name__)
|
|
33
|
+
|
|
23
34
|
|
|
24
35
|
def arch_overridable(f):
|
|
25
36
|
@functools.wraps(f)
|
|
@@ -513,16 +524,6 @@ class SimState(PluginHub):
|
|
|
513
524
|
if self.solver.is_true(arg):
|
|
514
525
|
continue
|
|
515
526
|
|
|
516
|
-
# `is_true` and `is_false` does not use VSABackend currently (see commits 97a75366 and 2dfba73e in
|
|
517
|
-
# claripy). There is a chance that VSA backend can in fact handle it.
|
|
518
|
-
# Therefore we try to resolve it with VSABackend again
|
|
519
|
-
if claripy.backends.vsa.is_false(arg):
|
|
520
|
-
self._satisfiable = False
|
|
521
|
-
return
|
|
522
|
-
|
|
523
|
-
if claripy.backends.vsa.is_true(arg):
|
|
524
|
-
continue
|
|
525
|
-
|
|
526
527
|
# It's neither True or False. Let's try to apply the condition
|
|
527
528
|
|
|
528
529
|
# We take the argument, extract a list of constrained SIs out of it (if we could, of course), and
|
|
@@ -678,7 +679,7 @@ class SimState(PluginHub):
|
|
|
678
679
|
merge_conditions = [merge_flag == b for b in merge_values]
|
|
679
680
|
else:
|
|
680
681
|
merge_conditions = [
|
|
681
|
-
(claripy.true if len(mc) == 0 else claripy.And(*[c.to_claripy() for c in mc]))
|
|
682
|
+
(claripy.true() if len(mc) == 0 else claripy.And(*[c.to_claripy() for c in mc]))
|
|
682
683
|
for mc in merge_conditions
|
|
683
684
|
]
|
|
684
685
|
|
|
@@ -976,17 +977,3 @@ SimState.register_preset("default", default_state_plugin_preset)
|
|
|
976
977
|
from .state_plugins.history import SimStateHistory
|
|
977
978
|
from .state_plugins.inspect import BP_AFTER, BP_BEFORE
|
|
978
979
|
from .state_plugins.sim_action import SimActionConstraint
|
|
979
|
-
|
|
980
|
-
from . import sim_options as o
|
|
981
|
-
from .errors import SimMergeError, SimValueError, SimStateError, SimSolverModeError
|
|
982
|
-
|
|
983
|
-
# Type imports for annotations
|
|
984
|
-
if TYPE_CHECKING:
|
|
985
|
-
from .storage import DefaultMemory
|
|
986
|
-
from .state_plugins.solver import SimSolver
|
|
987
|
-
from .state_plugins.posix import SimSystemPosix
|
|
988
|
-
from .state_plugins.view import SimRegNameView, SimMemView
|
|
989
|
-
from .state_plugins.callstack import CallStack
|
|
990
|
-
from .state_plugins.inspect import SimInspector
|
|
991
|
-
from .state_plugins.jni_references import SimStateJNIReferences
|
|
992
|
-
from .state_plugins.scratch import SimStateScratch
|
angr/sim_type.py
CHANGED
|
@@ -495,6 +495,48 @@ class SimTypeLongLong(SimTypeInt):
|
|
|
495
495
|
_base_name = "long long"
|
|
496
496
|
|
|
497
497
|
|
|
498
|
+
class SimTypeFixedSizeInt(SimTypeInt):
|
|
499
|
+
"""
|
|
500
|
+
The base class for all fixed-size (i.e., the size stays the same on all platforms) integer types. Do not
|
|
501
|
+
instantiate this class directly.
|
|
502
|
+
"""
|
|
503
|
+
|
|
504
|
+
_base_name: str = "int"
|
|
505
|
+
_fixed_size: int = 32
|
|
506
|
+
|
|
507
|
+
def c_repr(self, name=None, full=0, memo=None, indent=0):
|
|
508
|
+
out = self._base_name
|
|
509
|
+
if not self.signed:
|
|
510
|
+
out = "u" + out
|
|
511
|
+
if name is None:
|
|
512
|
+
return out
|
|
513
|
+
return f"{out} {name}"
|
|
514
|
+
|
|
515
|
+
def __repr__(self) -> str:
|
|
516
|
+
name = self._base_name
|
|
517
|
+
if not self.signed:
|
|
518
|
+
name = "u" + name
|
|
519
|
+
|
|
520
|
+
try:
|
|
521
|
+
return name + " (%d bits)" % self.size
|
|
522
|
+
except ValueError:
|
|
523
|
+
return name
|
|
524
|
+
|
|
525
|
+
@property
|
|
526
|
+
def size(self) -> int:
|
|
527
|
+
return self._fixed_size
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
class SimTypeInt128(SimTypeFixedSizeInt):
|
|
531
|
+
_base_name = "int128_t"
|
|
532
|
+
_fixed_size = 128
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class SimTypeInt256(SimTypeFixedSizeInt):
|
|
536
|
+
_base_name = "int256_t"
|
|
537
|
+
_fixed_size = 256
|
|
538
|
+
|
|
539
|
+
|
|
498
540
|
class SimTypeChar(SimTypeReg):
|
|
499
541
|
"""
|
|
500
542
|
SimTypeChar is a type that specifies a character;
|
angr/simos/javavm.py
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
import logging
|
|
3
4
|
|
|
4
|
-
from angr import SIM_PROCEDURES, options
|
|
5
5
|
from archinfo.arch_soot import ArchSoot, SootAddressDescriptor, SootAddressTerminator, SootArgument, SootNullConstant
|
|
6
6
|
from claripy import BVS, BVV, StringS, StringV, FSORT_FLOAT, FSORT_DOUBLE, FPV, FPS
|
|
7
7
|
from claripy.ast.fp import FP, fpToIEEEBV
|
|
8
8
|
from claripy.ast.bv import BV
|
|
9
9
|
|
|
10
|
+
from angr import SIM_PROCEDURES, options
|
|
11
|
+
|
|
10
12
|
from ..calling_conventions import default_cc, SimCCSoot
|
|
11
13
|
from ..engines.soot import SootMixin
|
|
12
|
-
from ..engines.soot.expressions import SimSootExpr_NewArray
|
|
14
|
+
from ..engines.soot.expressions import SimSootExpr_NewArray
|
|
13
15
|
from ..engines.soot.values import (
|
|
14
16
|
SimSootValue_ArrayRef,
|
|
15
17
|
SimSootValue_StringRef,
|
|
@@ -106,10 +108,6 @@ class SimJavaVM(SimOS):
|
|
|
106
108
|
kwargs["arch"] = self.arch
|
|
107
109
|
if not kwargs.get("os_name", None):
|
|
108
110
|
kwargs["os_name"] = self.name
|
|
109
|
-
# enable support for string analysis
|
|
110
|
-
add_options = kwargs.get("add_options", set())
|
|
111
|
-
add_options.add(options.COMPOSITE_SOLVER)
|
|
112
|
-
kwargs["add_options"] = add_options
|
|
113
111
|
|
|
114
112
|
if self.is_javavm_with_jni_support:
|
|
115
113
|
# If the JNI support is enabled (i.e. JNI libs are loaded), the SimState
|
|
@@ -194,13 +192,13 @@ class SimJavaVM(SimOS):
|
|
|
194
192
|
return state
|
|
195
193
|
|
|
196
194
|
@staticmethod
|
|
197
|
-
def generate_symbolic_cmd_line_arg(state
|
|
195
|
+
def generate_symbolic_cmd_line_arg(state):
|
|
198
196
|
"""
|
|
199
197
|
Generates a new symbolic cmd line argument string.
|
|
200
198
|
:return: The string reference.
|
|
201
199
|
"""
|
|
202
200
|
str_ref = SimSootValue_StringRef(state.memory.get_new_uuid())
|
|
203
|
-
str_sym = StringS("cmd_line_arg"
|
|
201
|
+
str_sym = StringS("cmd_line_arg")
|
|
204
202
|
state.solver.add(str_sym != StringV(""))
|
|
205
203
|
state.memory.store(str_ref, str_sym)
|
|
206
204
|
return str_ref
|
|
@@ -312,7 +310,7 @@ class SimJavaVM(SimOS):
|
|
|
312
310
|
if type_ == "double":
|
|
313
311
|
return FPS(f"default_value_{type_}", FSORT_DOUBLE)
|
|
314
312
|
if type_ == "java.lang.String":
|
|
315
|
-
return SimSootValue_StringRef.new_string(state, StringS(f"default_value_{type_}"
|
|
313
|
+
return SimSootValue_StringRef.new_string(state, StringS(f"default_value_{type_}"))
|
|
316
314
|
if type_.endswith("[][]"):
|
|
317
315
|
raise NotImplementedError
|
|
318
316
|
if type_.endswith("[]"):
|
|
@@ -435,9 +433,6 @@ class SimJavaVM(SimOS):
|
|
|
435
433
|
jni_type_size = ArchSoot.sizeof.get(java_type, self.native_simos.arch.bits)
|
|
436
434
|
return SimTypeNum(size=jni_type_size)
|
|
437
435
|
|
|
438
|
-
def get_method_native_type(self, method):
|
|
439
|
-
return SimTypeFunction
|
|
440
|
-
|
|
441
436
|
@property
|
|
442
437
|
def native_arch(self):
|
|
443
438
|
"""
|
angr/simos/linux.py
CHANGED
|
@@ -238,7 +238,7 @@ class SimLinux(SimUserland):
|
|
|
238
238
|
fs[name] = fs[name].encode("utf-8")
|
|
239
239
|
if type(fs[name]) is bytes:
|
|
240
240
|
fs[name] = claripy.BVV(fs[name])
|
|
241
|
-
if isinstance(fs[name], claripy.Bits):
|
|
241
|
+
if isinstance(fs[name], claripy.ast.Bits):
|
|
242
242
|
fs[name] = SimFile(name, content=fs[name])
|
|
243
243
|
if not isinstance(fs[name], SimFileBase):
|
|
244
244
|
raise TypeError(f"Provided fs initializer with unusable type {type(fs[name])!r}")
|
angr/simos/simos.py
CHANGED
|
@@ -149,7 +149,7 @@ class SimOS:
|
|
|
149
149
|
if type(stdin) is type:
|
|
150
150
|
stdin = stdin(name="stdin", has_end=False)
|
|
151
151
|
else:
|
|
152
|
-
if isinstance(stdin, claripy.Bits):
|
|
152
|
+
if isinstance(stdin, claripy.ast.Bits):
|
|
153
153
|
num_bytes = len(stdin) // self.project.arch.byte_width
|
|
154
154
|
else:
|
|
155
155
|
num_bytes = len(stdin)
|
angr/simos/windows.py
CHANGED
|
@@ -422,7 +422,7 @@ class SimWindows(SimOS):
|
|
|
422
422
|
|
|
423
423
|
# let's go let's go!
|
|
424
424
|
# we want to use a true guard here. if it's not true, then it's already been added in windup.
|
|
425
|
-
successors.add_successor(exc_state, self._exception_handler, claripy.true, "Ijk_Exception")
|
|
425
|
+
successors.add_successor(exc_state, self._exception_handler, claripy.true(), "Ijk_Exception")
|
|
426
426
|
successors.processed = True
|
|
427
427
|
|
|
428
428
|
# these two methods load and store register state from a struct CONTEXT
|
angr/state_hierarchy.py
CHANGED
|
@@ -213,7 +213,7 @@ class StateHierarchy:
|
|
|
213
213
|
n()._satisfiable = False
|
|
214
214
|
try:
|
|
215
215
|
if n().state is not None:
|
|
216
|
-
n().state.add_constraints(claripy.false)
|
|
216
|
+
n().state.add_constraints(claripy.false())
|
|
217
217
|
except ReferenceError:
|
|
218
218
|
pass
|
|
219
219
|
self._graph.remove_nodes_from(all_children)
|
|
@@ -147,13 +147,13 @@ class SimStatePreconstrainer(SimStatePlugin):
|
|
|
147
147
|
precon_cache_keys = set()
|
|
148
148
|
|
|
149
149
|
for con in self.preconstraints:
|
|
150
|
-
precon_cache_keys.add(con.
|
|
150
|
+
precon_cache_keys.add(con.hash())
|
|
151
151
|
|
|
152
152
|
# if we used the replacement solver we didn't add constraints we need to remove so keep all constraints
|
|
153
153
|
if o.REPLACEMENT_SOLVER in self.state.options:
|
|
154
154
|
new_constraints = self.state.solver.constraints
|
|
155
155
|
else:
|
|
156
|
-
new_constraints = [x for x in self.state.solver.constraints if x.
|
|
156
|
+
new_constraints = [x for x in self.state.solver.constraints if x.hash() not in precon_cache_keys]
|
|
157
157
|
|
|
158
158
|
if self.state.has_plugin("zen_plugin"):
|
|
159
159
|
new_constraints = self.state.get_plugin("zen_plugin").filter_constraints(new_constraints)
|
angr/state_plugins/scratch.py
CHANGED
angr/state_plugins/solver.py
CHANGED
|
@@ -95,7 +95,7 @@ def error_converter(f):
|
|
|
95
95
|
return f(*args, **kwargs)
|
|
96
96
|
except claripy.UnsatError as e:
|
|
97
97
|
raise SimUnsatError("Got an unsat result") from e
|
|
98
|
-
except claripy.
|
|
98
|
+
except claripy.ClaripyError as e:
|
|
99
99
|
raise SimSolverModeError("Claripy threw an error") from e
|
|
100
100
|
|
|
101
101
|
return wrapped_f
|
|
@@ -219,7 +219,7 @@ def end_info_hook(state):
|
|
|
219
219
|
)
|
|
220
220
|
chall_resp_plugin.str_to_int_pairs.append((input_bvs, new_var))
|
|
221
221
|
if pending_info.allows_negative:
|
|
222
|
-
chall_resp_plugin.allows_negative_bvs.add(input_bvs.
|
|
222
|
+
chall_resp_plugin.allows_negative_bvs.add(input_bvs.hash())
|
|
223
223
|
chall_resp_plugin.replacement_pairs.append((input_bvs, input_val))
|
|
224
224
|
elif pending_info.get_type() == "IntToStr":
|
|
225
225
|
# result constraint
|
|
@@ -459,11 +459,11 @@ class ChallRespInfo(angr.state_plugins.SimStatePlugin):
|
|
|
459
459
|
base = int(int_var_name.split("_")[1], 10)
|
|
460
460
|
original_len = str_var.size() // 8
|
|
461
461
|
abs_max = (1 << int_var.size()) - 1
|
|
462
|
-
if str_var.
|
|
462
|
+
if str_var.hash() in self.allows_negative_bvs:
|
|
463
463
|
abs_max = (1 << (int_var.size() - 1)) - 1
|
|
464
464
|
max_val = base ** (original_len) - 1
|
|
465
465
|
min_val = 0
|
|
466
|
-
if str_var.
|
|
466
|
+
if str_var.hash() in self.allows_negative_bvs and original_len > 1:
|
|
467
467
|
min_val = -(base ** (original_len - 1) - 1)
|
|
468
468
|
|
|
469
469
|
max_val = min(max_val, abs_max)
|
|
@@ -569,10 +569,10 @@ def zen_hook(state, expr):
|
|
|
569
569
|
if len(flag_args) > 1:
|
|
570
570
|
zen_plugin = state.get_plugin("zen_plugin")
|
|
571
571
|
|
|
572
|
-
if expr.
|
|
572
|
+
if expr.hash() in zen_plugin.replacements:
|
|
573
573
|
# we already have the replacement
|
|
574
574
|
concrete_val = state.solver.eval(expr)
|
|
575
|
-
replacement = zen_plugin.replacements[expr.
|
|
575
|
+
replacement = zen_plugin.replacements[expr.hash()]
|
|
576
576
|
state.preconstrainer.preconstrain(concrete_val, replacement)
|
|
577
577
|
zen_plugin.preconstraints.append(replacement == concrete_val)
|
|
578
578
|
else:
|
|
@@ -603,7 +603,7 @@ def zen_hook(state, expr):
|
|
|
603
603
|
zen_plugin.state.preconstrainer.preconstraints.append(constraint)
|
|
604
604
|
zen_plugin.preconstraints.append(replacement == concrete_val)
|
|
605
605
|
|
|
606
|
-
zen_plugin.replacements[expr.
|
|
606
|
+
zen_plugin.replacements[expr.hash()] = replacement
|
|
607
607
|
|
|
608
608
|
return replacement
|
|
609
609
|
return None
|
|
@@ -701,11 +701,11 @@ class ZenPlugin(angr.state_plugins.SimStatePlugin):
|
|
|
701
701
|
return contained_bytes
|
|
702
702
|
|
|
703
703
|
def filter_constraints(self, constraints):
|
|
704
|
-
zen_cache_keys = {x.
|
|
704
|
+
zen_cache_keys = {x.hash() for x in self.zen_constraints}
|
|
705
705
|
new_cons = []
|
|
706
706
|
for con in constraints:
|
|
707
707
|
if (
|
|
708
|
-
con.
|
|
708
|
+
con.hash() in zen_cache_keys
|
|
709
709
|
or not all(v.startswith(("cgc-flag", "random")) for v in con.variables)
|
|
710
710
|
or len(con.variables) == 0
|
|
711
711
|
):
|
angr/storage/file.py
CHANGED
|
@@ -209,7 +209,7 @@ class SimFile(SimFileBase, DefaultMemory): # TODO: pick a better base class omg
|
|
|
209
209
|
content = claripy.BVV(content.encode())
|
|
210
210
|
elif content is None:
|
|
211
211
|
pass
|
|
212
|
-
elif isinstance(content, claripy.Bits):
|
|
212
|
+
elif isinstance(content, claripy.ast.Bits):
|
|
213
213
|
if concrete is None and not content.symbolic:
|
|
214
214
|
concrete = True
|
|
215
215
|
else:
|
|
@@ -322,7 +322,7 @@ class SimFile(SimFileBase, DefaultMemory): # TODO: pick a better base class omg
|
|
|
322
322
|
|
|
323
323
|
data = _deps_unpack(data)[0]
|
|
324
324
|
if size is None:
|
|
325
|
-
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.Bits) else len(data)
|
|
325
|
+
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.ast.Bits) else len(data)
|
|
326
326
|
# \(_^^)/
|
|
327
327
|
self.store(pos, data, size=size)
|
|
328
328
|
new_end = _deps_unpack(pos + size)[0] # decline to store SAO
|
|
@@ -442,7 +442,7 @@ class SimPackets(SimFileBase):
|
|
|
442
442
|
if type(x) is tuple
|
|
443
443
|
else (
|
|
444
444
|
(x, len(x) // 8)
|
|
445
|
-
if isinstance(x, claripy.Bits)
|
|
445
|
+
if isinstance(x, claripy.ast.Bits)
|
|
446
446
|
else (
|
|
447
447
|
(x.ast, len(x) // 8)
|
|
448
448
|
if isinstance(x, SimActionObject)
|
|
@@ -593,7 +593,7 @@ class SimPackets(SimFileBase):
|
|
|
593
593
|
if type(data) is bytes:
|
|
594
594
|
data = claripy.BVV(data)
|
|
595
595
|
if size is None:
|
|
596
|
-
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.Bits) else len(data)
|
|
596
|
+
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.ast.Bits) else len(data)
|
|
597
597
|
if type(size) is int:
|
|
598
598
|
size = claripy.BVV(size, self.state.arch.bits)
|
|
599
599
|
|
|
@@ -903,7 +903,7 @@ class SimFileDescriptor(SimFileDescriptorBase):
|
|
|
903
903
|
|
|
904
904
|
data = _deps_unpack(data)[0]
|
|
905
905
|
if size is None:
|
|
906
|
-
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.Bits) else len(data)
|
|
906
|
+
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.ast.Bits) else len(data)
|
|
907
907
|
|
|
908
908
|
size = self._prep_write(size)
|
|
909
909
|
self._pos = self.file.write(self._pos, data, size)
|
|
@@ -911,7 +911,7 @@ class SimFileDescriptor(SimFileDescriptorBase):
|
|
|
911
911
|
|
|
912
912
|
def seek(self, offset, whence="start"):
|
|
913
913
|
if not self.file.seekable:
|
|
914
|
-
return claripy.false
|
|
914
|
+
return claripy.false()
|
|
915
915
|
|
|
916
916
|
if type(offset) is int:
|
|
917
917
|
offset = claripy.BVV(offset, self.state.arch.bits)
|
|
@@ -929,9 +929,9 @@ class SimFileDescriptor(SimFileDescriptorBase):
|
|
|
929
929
|
|
|
930
930
|
def eof(self):
|
|
931
931
|
if not self.file.seekable:
|
|
932
|
-
return claripy.false
|
|
932
|
+
return claripy.false()
|
|
933
933
|
if not getattr(self.file, "has_end", True):
|
|
934
|
-
return claripy.false
|
|
934
|
+
return claripy.false()
|
|
935
935
|
return self._pos == self.file.size
|
|
936
936
|
|
|
937
937
|
def tell(self):
|
|
@@ -1034,7 +1034,7 @@ class SimFileDescriptorDuplex(SimFileDescriptorBase):
|
|
|
1034
1034
|
def write_data(self, data, size=None, **kwargs):
|
|
1035
1035
|
data = _deps_unpack(data)[0]
|
|
1036
1036
|
if size is None:
|
|
1037
|
-
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.Bits) else len(data)
|
|
1037
|
+
size = len(data) // self.state.arch.byte_width if isinstance(data, claripy.ast.Bits) else len(data)
|
|
1038
1038
|
|
|
1039
1039
|
size = self._prep_write(size)
|
|
1040
1040
|
self._write_pos = self._write_file.write(self._write_pos, data, size)
|
|
@@ -1048,16 +1048,16 @@ class SimFileDescriptorDuplex(SimFileDescriptorBase):
|
|
|
1048
1048
|
def eof(self):
|
|
1049
1049
|
# the thing that makes the most sense is for this to refer to the read eof status...
|
|
1050
1050
|
if not self._read_file.seekable:
|
|
1051
|
-
return claripy.false
|
|
1051
|
+
return claripy.false()
|
|
1052
1052
|
if not getattr(self._read_file, "has_end", True):
|
|
1053
|
-
return claripy.false
|
|
1053
|
+
return claripy.false()
|
|
1054
1054
|
return self._read_pos == self._read_file.size
|
|
1055
1055
|
|
|
1056
1056
|
def tell(self):
|
|
1057
1057
|
return None
|
|
1058
1058
|
|
|
1059
1059
|
def seek(self, offset, whence="start"):
|
|
1060
|
-
return claripy.false
|
|
1060
|
+
return claripy.false()
|
|
1061
1061
|
|
|
1062
1062
|
def size(self):
|
|
1063
1063
|
return None
|
|
@@ -46,7 +46,7 @@ class ActionsMixinHigh(MemoryMixin):
|
|
|
46
46
|
self.state, region_type, kind, addr=addr, data=data, size=ref_size, condition=condition, fallback=fallback
|
|
47
47
|
)
|
|
48
48
|
|
|
49
|
-
action.added_constraints = claripy.true
|
|
49
|
+
action.added_constraints = claripy.true()
|
|
50
50
|
return action
|
|
51
51
|
|
|
52
52
|
def _add_constraints(self, c, action=None, **kwargs):
|
|
@@ -63,7 +63,7 @@ class ConvenientMappingsMixin(MemoryMixin):
|
|
|
63
63
|
self._updated_mappings.remove((v, id(self._name_mapping)))
|
|
64
64
|
|
|
65
65
|
if options.REVERSE_MEMORY_HASH_MAP in self.state.options:
|
|
66
|
-
h = old_obj.
|
|
66
|
+
h = old_obj.hash()
|
|
67
67
|
self._mark_updated_mapping(self._hash_mapping, h)
|
|
68
68
|
self._hash_mapping[h].difference_update(range(addr, addr + size))
|
|
69
69
|
if len(self._hash_mapping[h]) == 0:
|
|
@@ -82,7 +82,7 @@ class ConvenientMappingsMixin(MemoryMixin):
|
|
|
82
82
|
|
|
83
83
|
if options.REVERSE_MEMORY_HASH_MAP in self.state.options:
|
|
84
84
|
# add the new variables to the hash->addrs mapping
|
|
85
|
-
h = data.
|
|
85
|
+
h = data.hash()
|
|
86
86
|
self._mark_updated_mapping(self._hash_mapping, h)
|
|
87
87
|
if h not in self._hash_mapping:
|
|
88
88
|
self._hash_mapping[h] = set()
|
|
@@ -148,7 +148,7 @@ class ConvenientMappingsMixin(MemoryMixin):
|
|
|
148
148
|
self._name_mapping.pop(v, None)
|
|
149
149
|
|
|
150
150
|
if options.REVERSE_MEMORY_HASH_MAP in self.state.options:
|
|
151
|
-
h = hash(
|
|
151
|
+
h = old_obj.hash()
|
|
152
152
|
self._mark_updated_mapping(self._hash_mapping, h)
|
|
153
153
|
self._hash_mapping[h].discard(actual_addr)
|
|
154
154
|
if len(self._hash_mapping[h]) == 0:
|
|
@@ -166,7 +166,7 @@ class ConvenientMappingsMixin(MemoryMixin):
|
|
|
166
166
|
|
|
167
167
|
if options.REVERSE_MEMORY_HASH_MAP in self.state.options:
|
|
168
168
|
# add the new variables to the hash->addrs mapping
|
|
169
|
-
h = hash(
|
|
169
|
+
h = new_obj.hash()
|
|
170
170
|
self._mark_updated_mapping(self._hash_mapping, h)
|
|
171
171
|
if h not in self._hash_mapping:
|
|
172
172
|
self._hash_mapping[h] = set()
|
|
@@ -208,10 +208,8 @@ class ConvenientMappingsMixin(MemoryMixin):
|
|
|
208
208
|
for e in self._hash_mapping[h]:
|
|
209
209
|
try:
|
|
210
210
|
present = self.load(e, size=1)
|
|
211
|
-
if h == present.
|
|
212
|
-
present.op == "Extract"
|
|
213
|
-
and present.args[0] - present.args[1] == 7
|
|
214
|
-
and h == present.args[2].cache_key
|
|
211
|
+
if h == present.hash() or (
|
|
212
|
+
present.op == "Extract" and present.args[0] - present.args[1] == 7 and h == present.args[2].hash()
|
|
215
213
|
):
|
|
216
214
|
yield e
|
|
217
215
|
else:
|
|
@@ -41,16 +41,16 @@ class MultiValueMergerMixin(MemoryMixin):
|
|
|
41
41
|
ret_val = self._top_func(merged_size * self.state.arch.byte_width)
|
|
42
42
|
else:
|
|
43
43
|
# strip annotations from each value and see how many raw values there are in total
|
|
44
|
-
# We have to use
|
|
44
|
+
# We have to use hash manually to determine uniqueness here, because if __hash__ collides,
|
|
45
45
|
# python implicitly calls __eq__ to determine if the two objects are actually the same
|
|
46
46
|
# and that just results in a new AST for a BV. Python then tries to convert that AST to a bool
|
|
47
47
|
# which fails with the safeguard in claripy.ast.bool.Bool.__bool__.
|
|
48
|
-
|
|
49
|
-
if len(
|
|
48
|
+
stripped_values_dict = {v.hash(): v for v in values_set}
|
|
49
|
+
if len(stripped_values_dict) > 1:
|
|
50
50
|
ret_val = self._top_func(merged_size * self.state.arch.byte_width)
|
|
51
51
|
else:
|
|
52
|
-
# Get the AST back from the
|
|
53
|
-
ret_val = next(iter(
|
|
52
|
+
# Get the AST back from the hash dict
|
|
53
|
+
ret_val = stripped_values_dict[next(iter(stripped_values_dict))]
|
|
54
54
|
|
|
55
55
|
# migrate annotations
|
|
56
56
|
annotations = []
|
|
@@ -464,7 +464,7 @@ class UltraPage(MemoryObjectMixin, PageBase):
|
|
|
464
464
|
if replaced_object is not None:
|
|
465
465
|
self._replace_memory_object(mo, replaced_object, memory=memory)
|
|
466
466
|
|
|
467
|
-
def _replace_memory_object(self, old: SimMemoryObject, new_content: claripy.Bits, memory=None):
|
|
467
|
+
def _replace_memory_object(self, old: SimMemoryObject, new_content: claripy.ast.Bits, memory=None):
|
|
468
468
|
"""
|
|
469
469
|
Replaces the memory object `old` with a new memory object containing `new_content`.
|
|
470
470
|
|
|
@@ -136,7 +136,7 @@ class SizeConcretizationMixin(MemoryMixin):
|
|
|
136
136
|
conc_sizes = [min(cs, self._max_symbolic_size) for cs in conc_sizes]
|
|
137
137
|
|
|
138
138
|
if condition is None:
|
|
139
|
-
condition = claripy.true
|
|
139
|
+
condition = claripy.true()
|
|
140
140
|
for conc_size in conc_sizes:
|
|
141
141
|
if conc_size == 0:
|
|
142
142
|
continue
|
|
@@ -99,7 +99,7 @@ class SmartFindMixin(MemoryMixin):
|
|
|
99
99
|
able to handle wide characters
|
|
100
100
|
"""
|
|
101
101
|
if condition is None:
|
|
102
|
-
condition = claripy.true
|
|
102
|
+
condition = claripy.true()
|
|
103
103
|
chunk = None
|
|
104
104
|
chunk_progress = chunk_size
|
|
105
105
|
|
|
@@ -139,7 +139,7 @@ class SmartFindMixin(MemoryMixin):
|
|
|
139
139
|
|
|
140
140
|
def _find_condition(self, target_addr): # pylint:disable=unused-argument,no-self-use
|
|
141
141
|
# TODO: fill this in in order to make each load have the correct condition associated with it
|
|
142
|
-
return claripy.true
|
|
142
|
+
return claripy.true()
|
|
143
143
|
|
|
144
144
|
def _find_compare(self, element, target):
|
|
145
145
|
comparison = element == target
|