angr 9.2.135__py3-none-manylinux2014_aarch64.whl → 9.2.137__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/__init__.py +3 -7
- angr/analyses/analysis.py +4 -0
- angr/analyses/backward_slice.py +1 -2
- angr/analyses/binary_optimizer.py +3 -4
- angr/analyses/bindiff.py +4 -6
- angr/analyses/boyscout.py +1 -3
- angr/analyses/callee_cleanup_finder.py +4 -4
- angr/analyses/calling_convention/calling_convention.py +6 -4
- angr/analyses/calling_convention/fact_collector.py +10 -3
- angr/analyses/cdg.py +1 -2
- angr/analyses/cfg/cfb.py +1 -3
- angr/analyses/cfg/cfg.py +2 -2
- angr/analyses/cfg/cfg_base.py +40 -68
- angr/analyses/cfg/cfg_emulated.py +1 -104
- angr/analyses/cfg/cfg_fast.py +90 -27
- angr/analyses/cfg/cfg_fast_soot.py +1 -1
- angr/analyses/cfg/indirect_jump_resolvers/__init__.py +2 -0
- angr/analyses/cfg/indirect_jump_resolvers/const_resolver.py +46 -10
- angr/analyses/cfg/indirect_jump_resolvers/default_resolvers.py +5 -1
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +65 -14
- angr/analyses/cfg/indirect_jump_resolvers/memload_resolver.py +81 -0
- angr/analyses/cfg/indirect_jump_resolvers/propagator_utils.py +24 -5
- angr/analyses/cfg/indirect_jump_resolvers/x86_pe_iat.py +2 -5
- angr/analyses/class_identifier.py +1 -2
- angr/analyses/complete_calling_conventions.py +3 -0
- angr/analyses/congruency_check.py +2 -3
- angr/analyses/data_dep/data_dependency_analysis.py +2 -2
- angr/analyses/ddg.py +1 -4
- angr/analyses/decompiler/ail_simplifier.py +15 -5
- angr/analyses/decompiler/block_simplifier.py +2 -2
- angr/analyses/decompiler/ccall_rewriters/__init__.py +2 -0
- angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +1 -1
- angr/analyses/decompiler/ccall_rewriters/x86_ccalls.py +69 -0
- angr/analyses/decompiler/clinic.py +119 -72
- angr/analyses/decompiler/condition_processor.py +2 -0
- angr/analyses/decompiler/decompiler.py +1 -0
- angr/analyses/decompiler/dephication/dephication_base.py +2 -0
- angr/analyses/decompiler/dephication/rewriting_engine.py +8 -6
- angr/analyses/decompiler/dephication/seqnode_dephication.py +10 -1
- angr/analyses/decompiler/optimization_passes/duplication_reverter/ail_merge_graph.py +2 -2
- angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +2 -2
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +1 -1
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +1 -1
- angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +1 -2
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +1 -1
- angr/analyses/decompiler/sequence_walker.py +6 -2
- angr/analyses/decompiler/ssailification/rewriting.py +11 -1
- angr/analyses/decompiler/ssailification/rewriting_engine.py +56 -19
- angr/analyses/decompiler/ssailification/ssailification.py +13 -3
- angr/analyses/decompiler/ssailification/traversal.py +28 -2
- angr/analyses/decompiler/ssailification/traversal_state.py +6 -1
- angr/analyses/decompiler/structured_codegen/c.py +44 -21
- angr/analyses/decompiler/structuring/phoenix.py +118 -15
- angr/analyses/decompiler/utils.py +113 -8
- angr/analyses/disassembly.py +5 -5
- angr/analyses/fcp/__init__.py +4 -0
- angr/analyses/fcp/fcp.py +429 -0
- angr/analyses/identifier/identify.py +1 -3
- angr/analyses/loopfinder.py +4 -3
- angr/analyses/patchfinder.py +1 -1
- angr/analyses/propagator/engine_base.py +4 -3
- angr/analyses/propagator/propagator.py +14 -53
- angr/analyses/reaching_definitions/function_handler.py +1 -1
- angr/analyses/reassembler.py +1 -2
- angr/analyses/s_liveness.py +5 -1
- angr/analyses/s_propagator.py +26 -7
- angr/analyses/s_reaching_definitions/s_rda_model.py +2 -1
- angr/analyses/s_reaching_definitions/s_rda_view.py +20 -1
- angr/analyses/s_reaching_definitions/s_reaching_definitions.py +11 -1
- angr/analyses/soot_class_hierarchy.py +1 -2
- angr/analyses/stack_pointer_tracker.py +29 -3
- angr/analyses/static_hooker.py +1 -2
- angr/analyses/typehoon/simple_solver.py +2 -2
- angr/analyses/variable_recovery/engine_ail.py +19 -7
- angr/analyses/variable_recovery/engine_base.py +16 -14
- angr/analyses/variable_recovery/engine_vex.py +2 -2
- angr/analyses/variable_recovery/variable_recovery_fast.py +23 -3
- angr/analyses/veritesting.py +4 -7
- angr/analyses/vfg.py +1 -1
- angr/analyses/vsa_ddg.py +1 -2
- angr/block.py +62 -22
- angr/callable.py +1 -3
- angr/calling_conventions.py +3 -3
- angr/codenode.py +5 -1
- angr/concretization_strategies/__init__.py +1 -83
- angr/concretization_strategies/any.py +2 -1
- angr/concretization_strategies/any_named.py +1 -1
- angr/concretization_strategies/base.py +81 -0
- angr/concretization_strategies/controlled_data.py +2 -1
- angr/concretization_strategies/eval.py +2 -1
- angr/concretization_strategies/logging.py +3 -1
- angr/concretization_strategies/max.py +2 -1
- angr/concretization_strategies/nonzero.py +2 -1
- angr/concretization_strategies/nonzero_range.py +2 -1
- angr/concretization_strategies/norepeats.py +2 -1
- angr/concretization_strategies/norepeats_range.py +2 -1
- angr/concretization_strategies/range.py +2 -1
- angr/concretization_strategies/signed_add.py +2 -1
- angr/concretization_strategies/single.py +2 -1
- angr/concretization_strategies/solutions.py +2 -1
- angr/concretization_strategies/unlimited_range.py +2 -1
- angr/engines/__init__.py +8 -5
- angr/engines/engine.py +3 -5
- angr/engines/failure.py +4 -5
- angr/engines/pcode/emulate.py +1 -1
- angr/engines/pcode/lifter.py +31 -18
- angr/engines/procedure.py +5 -7
- angr/engines/soot/expressions/__init__.py +20 -23
- angr/engines/soot/expressions/base.py +4 -4
- angr/engines/soot/expressions/invoke.py +1 -2
- angr/engines/soot/statements/__init__.py +10 -12
- angr/engines/soot/values/__init__.py +10 -12
- angr/engines/soot/values/arrayref.py +3 -3
- angr/engines/soot/values/instancefieldref.py +3 -2
- angr/engines/successors.py +18 -12
- angr/engines/syscall.py +4 -6
- angr/engines/unicorn.py +3 -2
- angr/engines/vex/claripy/ccall.py +8 -10
- angr/engines/vex/claripy/datalayer.py +4 -5
- angr/engines/vex/lifter.py +9 -6
- angr/exploration_techniques/__init__.py +0 -2
- angr/exploration_techniques/spiller.py +1 -3
- angr/exploration_techniques/stochastic.py +2 -3
- angr/factory.py +3 -9
- angr/flirt/build_sig.py +8 -15
- angr/knowledge_plugins/cfg/cfg_model.py +20 -17
- angr/knowledge_plugins/functions/function.py +70 -79
- angr/knowledge_plugins/functions/function_manager.py +8 -7
- angr/knowledge_plugins/functions/function_parser.py +1 -1
- angr/knowledge_plugins/functions/soot_function.py +21 -24
- angr/knowledge_plugins/propagations/propagation_model.py +4 -5
- angr/knowledge_plugins/propagations/states.py +0 -511
- angr/knowledge_plugins/variables/variable_manager.py +16 -10
- angr/procedures/libc/memcpy.py +4 -4
- angr/procedures/procedure_dict.py +3 -2
- angr/protos/__init__.py +2 -5
- angr/protos/cfg_pb2.py +21 -18
- angr/protos/function_pb2.py +17 -14
- angr/protos/primitives_pb2.py +44 -39
- angr/protos/variables_pb2.py +36 -31
- angr/protos/xrefs_pb2.py +15 -12
- angr/sim_procedure.py +15 -16
- angr/sim_variable.py +13 -1
- angr/simos/__init__.py +2 -0
- angr/simos/javavm.py +4 -6
- angr/simos/xbox.py +32 -0
- angr/state_plugins/__init__.py +0 -2
- angr/state_plugins/callstack.py +4 -4
- angr/state_plugins/cgc.py +3 -2
- angr/state_plugins/gdb.py +6 -5
- angr/state_plugins/globals.py +1 -2
- angr/state_plugins/heap/heap_brk.py +1 -2
- angr/state_plugins/history.py +10 -12
- angr/state_plugins/inspect.py +3 -5
- angr/state_plugins/libc.py +2 -2
- angr/state_plugins/log.py +8 -10
- angr/state_plugins/loop_data.py +1 -2
- angr/state_plugins/posix.py +7 -7
- angr/state_plugins/preconstrainer.py +2 -3
- angr/state_plugins/scratch.py +5 -8
- angr/state_plugins/sim_action.py +3 -3
- angr/state_plugins/solver.py +8 -3
- angr/state_plugins/symbolizer.py +5 -4
- angr/state_plugins/uc_manager.py +3 -3
- angr/state_plugins/unicorn_engine.py +5 -1
- angr/state_plugins/view.py +3 -5
- angr/storage/file.py +3 -5
- angr/storage/memory_mixins/address_concretization_mixin.py +2 -2
- angr/storage/memory_mixins/bvv_conversion_mixin.py +3 -3
- angr/storage/memory_mixins/clouseau_mixin.py +1 -3
- angr/storage/memory_mixins/name_resolution_mixin.py +1 -3
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +13 -15
- angr/storage/memory_mixins/paged_memory/pages/__init__.py +1 -22
- angr/storage/memory_mixins/paged_memory/pages/base.py +31 -0
- angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
- angr/storage/memory_mixins/paged_memory/privileged_mixin.py +3 -4
- angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +4 -2
- angr/storage/memory_mixins/smart_find_mixin.py +1 -1
- angr/storage/memory_mixins/underconstrained_mixin.py +1 -1
- angr/storage/memory_mixins/unwrapper_mixin.py +1 -3
- angr/utils/enums_conv.py +28 -12
- angr/utils/segment_list.py +25 -22
- angr/utils/timing.py +18 -1
- angr/vaults.py +5 -6
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/METADATA +7 -7
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/RECORD +193 -191
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/WHEEL +1 -1
- angr/analyses/propagator/outdated_definition_walker.py +0 -159
- angr/analyses/propagator/tmpvar_finder.py +0 -18
- angr/engines/concrete.py +0 -180
- angr/exploration_techniques/symbion.py +0 -80
- angr/state_plugins/concrete.py +0 -295
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/LICENSE +0 -0
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/entry_points.txt +0 -0
- {angr-9.2.135.dist-info → angr-9.2.137.dist-info}/top_level.txt +0 -0
angr/state_plugins/concrete.py
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
import cle
|
|
3
|
-
import io
|
|
4
|
-
import logging
|
|
5
|
-
import os
|
|
6
|
-
import re
|
|
7
|
-
import struct
|
|
8
|
-
|
|
9
|
-
from .plugin import SimStatePlugin
|
|
10
|
-
from angr.errors import SimConcreteRegisterError
|
|
11
|
-
from archinfo import ArchX86, ArchAMD64
|
|
12
|
-
|
|
13
|
-
l = logging.getLogger("state_plugin.concrete")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Concrete(SimStatePlugin):
|
|
17
|
-
def __init__(
|
|
18
|
-
self,
|
|
19
|
-
segment_registers_initialized=False,
|
|
20
|
-
segment_registers_callback_initialized=False,
|
|
21
|
-
whitelist=None,
|
|
22
|
-
fs_register_bp=None,
|
|
23
|
-
already_sync_objects_addresses=None,
|
|
24
|
-
):
|
|
25
|
-
super().__init__()
|
|
26
|
-
|
|
27
|
-
self.segment_registers_initialized = segment_registers_initialized
|
|
28
|
-
self.segment_registers_callback_initialized = segment_registers_callback_initialized
|
|
29
|
-
|
|
30
|
-
if not whitelist:
|
|
31
|
-
self.whitelist = []
|
|
32
|
-
else:
|
|
33
|
-
self.whitelist = whitelist
|
|
34
|
-
|
|
35
|
-
self.synchronize_cle = False
|
|
36
|
-
self.stubs_on_sync = False
|
|
37
|
-
|
|
38
|
-
self.fs_register_bp = fs_register_bp
|
|
39
|
-
|
|
40
|
-
if not already_sync_objects_addresses:
|
|
41
|
-
self.already_sync_objects_addresses = []
|
|
42
|
-
else:
|
|
43
|
-
self.already_sync_objects_addresses = already_sync_objects_addresses
|
|
44
|
-
|
|
45
|
-
def copy(self, _memo):
|
|
46
|
-
return Concrete(
|
|
47
|
-
segment_registers_initialized=self.segment_registers_initialized,
|
|
48
|
-
segment_registers_callback_initialized=self.segment_registers_callback_initialized,
|
|
49
|
-
whitelist=list(self.whitelist),
|
|
50
|
-
fs_register_bp=self.fs_register_bp,
|
|
51
|
-
already_sync_objects_addresses=list(self.already_sync_objects_addresses),
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
def merge(self, _others, _merge_conditions, _common_ancestor=None):
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
|
-
def widen(self, _others):
|
|
58
|
-
pass
|
|
59
|
-
|
|
60
|
-
def set_state(self, state):
|
|
61
|
-
SimStatePlugin.set_state(self, state)
|
|
62
|
-
|
|
63
|
-
def sync(self):
|
|
64
|
-
"""
|
|
65
|
-
Handle the switch between the concrete execution and angr.
|
|
66
|
-
This method takes care of:
|
|
67
|
-
1- Synchronize registers.
|
|
68
|
-
2- Set a concrete target to the memory backer so the memory reads are redirected in the concrete process memory.
|
|
69
|
-
3- If possible restore the SimProcedures with the real addresses inside the concrete process.
|
|
70
|
-
4- Set an inspect point to sync the segments register as soon as they are read during the symbolic execution.
|
|
71
|
-
5- Flush all the pages loaded until now.
|
|
72
|
-
|
|
73
|
-
:return:
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
def _sync_segments(state):
|
|
77
|
-
"""
|
|
78
|
-
Segment registers synchronization is on demand as soon as the
|
|
79
|
-
symbolic execution access a segment register.
|
|
80
|
-
"""
|
|
81
|
-
concr_target = state.project.concrete_target
|
|
82
|
-
|
|
83
|
-
if isinstance(state.arch, ArchAMD64):
|
|
84
|
-
state.project.simos.initialize_segment_register_x64(state, concr_target)
|
|
85
|
-
elif isinstance(state.arch, ArchX86):
|
|
86
|
-
gdt = state.project.simos.initialize_gdt_x86(state, concr_target)
|
|
87
|
-
state.concrete.whitelist.append((gdt.addr, gdt.addr + gdt.limit))
|
|
88
|
-
|
|
89
|
-
state.inspect.remove_breakpoint("reg_read", bp=state.concrete.fs_register_bp)
|
|
90
|
-
state.concrete.segment_registers_initialized = True
|
|
91
|
-
|
|
92
|
-
state.concrete.fs_register_bp = None
|
|
93
|
-
|
|
94
|
-
l.debug("Sync the state with the concrete memory inside the Concrete plugin")
|
|
95
|
-
|
|
96
|
-
# Configure plugin with state options
|
|
97
|
-
if options.SYMBION_SYNC_CLE in self.state.options:
|
|
98
|
-
self.synchronize_cle = True
|
|
99
|
-
if options.SYMBION_KEEP_STUBS_ON_SYNC in self.state.options:
|
|
100
|
-
self.stubs_on_sync = True
|
|
101
|
-
|
|
102
|
-
target = self.state.project.concrete_target
|
|
103
|
-
|
|
104
|
-
# Sync angr registers with the one getting from the concrete target
|
|
105
|
-
# registers that we don't want to concretize.
|
|
106
|
-
l.debug("Synchronizing general purpose registers")
|
|
107
|
-
|
|
108
|
-
to_sync_register = list(filter(lambda x: x.concrete, self.state.arch.register_list))
|
|
109
|
-
|
|
110
|
-
for register in to_sync_register:
|
|
111
|
-
# before let's sync all the subregisters of the current register.
|
|
112
|
-
# sometimes this can be helpful ( i.e. ymmm0 e xmm0 )
|
|
113
|
-
if register.subregisters:
|
|
114
|
-
subregisters_names = (x[0] for x in register.subregisters)
|
|
115
|
-
self._sync_registers(subregisters_names, target)
|
|
116
|
-
|
|
117
|
-
# finally let's synchronize the whole register
|
|
118
|
-
self._sync_registers([register.name], target)
|
|
119
|
-
|
|
120
|
-
if self.synchronize_cle:
|
|
121
|
-
self._sync_cle(target)
|
|
122
|
-
|
|
123
|
-
# Synchronize the imported functions addresses (.got, IAT) in the
|
|
124
|
-
# concrete process with ones used in the SimProcedures dictionary
|
|
125
|
-
if self.state.project.use_sim_procedures and not self.state.project.loader.main_object.pic:
|
|
126
|
-
self._sync_simproc()
|
|
127
|
-
else:
|
|
128
|
-
l.debug("SimProc not restored, you are going to simulate also the code of external libraries!")
|
|
129
|
-
|
|
130
|
-
# flush the angr memory in order to synchronize them with the content of the
|
|
131
|
-
# concrete process memory when a read/write to the page is performed
|
|
132
|
-
self.state.memory.flush_pages(self.whitelist)
|
|
133
|
-
l.info(
|
|
134
|
-
"Exiting SimEngineConcrete: simulated address %x concrete address %x ",
|
|
135
|
-
self.state.addr,
|
|
136
|
-
target.read_register("pc"),
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
# now we have to register a SimInspect in order to synchronize the segments register
|
|
140
|
-
# on demand when the symbolic execution accesses it
|
|
141
|
-
if self.state.project.arch.name in ["X86", "AMD64"] and not self.segment_registers_callback_initialized:
|
|
142
|
-
segment_register_name = self.state.project.simos.get_segment_register_name()
|
|
143
|
-
if segment_register_name:
|
|
144
|
-
self.fs_register_bp = self.state.inspect.b(
|
|
145
|
-
"reg_read", reg_read_offset=segment_register_name, action=_sync_segments
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
self.segment_registers_callback_initialized = True
|
|
149
|
-
|
|
150
|
-
l.debug("Set SimInspect breakpoint to the new state!")
|
|
151
|
-
else:
|
|
152
|
-
l.error("Can't set breakpoint to synchronize segments registers, horrible things will happen.")
|
|
153
|
-
|
|
154
|
-
def _sync_registers(self, register_names, target):
|
|
155
|
-
for register_name in register_names:
|
|
156
|
-
try:
|
|
157
|
-
reg_value = target.read_register(register_name)
|
|
158
|
-
setattr(self.state.regs, register_name, reg_value)
|
|
159
|
-
l.debug(
|
|
160
|
-
"Register: %s value: %x ",
|
|
161
|
-
register_name,
|
|
162
|
-
self.state.solver.eval(getattr(self.state.regs, register_name), cast_to=int),
|
|
163
|
-
)
|
|
164
|
-
except SimConcreteRegisterError as exc:
|
|
165
|
-
l.debug(
|
|
166
|
-
"Can't set register %s reason: %s, if this register is not used this message can be ignored",
|
|
167
|
-
register_name,
|
|
168
|
-
exc,
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
def _sync_cle(self, target):
|
|
172
|
-
def _check_mapping_name(cle_mapping_name, concrete_mapping_name):
|
|
173
|
-
if cle_mapping_name == concrete_mapping_name:
|
|
174
|
-
return True
|
|
175
|
-
# removing version and extension information from the library name
|
|
176
|
-
cle_mapping_name = re.findall(r"[\w']+", cle_mapping_name)
|
|
177
|
-
concrete_mapping_name = re.findall(r"[\w']+", concrete_mapping_name)
|
|
178
|
-
return (cle_mapping_name[0] == concrete_mapping_name[0]) if len(concrete_mapping_name) else False
|
|
179
|
-
|
|
180
|
-
l.debug("Synchronizing CLE backend with the concrete process memory mapping")
|
|
181
|
-
try:
|
|
182
|
-
vmmap = target.get_mappings()
|
|
183
|
-
except NotImplementedError:
|
|
184
|
-
l.critical("Can't synchronize CLE backend using the ConcreteTarget provided.")
|
|
185
|
-
self.synchronize_cle = False # so, deactivate this feature
|
|
186
|
-
l.debug("CLE synchronization has been deactivated")
|
|
187
|
-
return
|
|
188
|
-
|
|
189
|
-
for mapped_object in self.state.project.loader.all_elf_objects:
|
|
190
|
-
binary_name = os.path.basename(mapped_object.binary)
|
|
191
|
-
|
|
192
|
-
# this object has already been sync, skip it.
|
|
193
|
-
if binary_name in self.already_sync_objects_addresses:
|
|
194
|
-
continue
|
|
195
|
-
|
|
196
|
-
for mmap in vmmap:
|
|
197
|
-
if _check_mapping_name(binary_name, mmap.name):
|
|
198
|
-
l.debug("Match! %s -> %s", mmap.name, binary_name)
|
|
199
|
-
|
|
200
|
-
# let's make sure that we have the header at this address to confirm that it is the
|
|
201
|
-
# base address.
|
|
202
|
-
# That's not a perfect solution, but should work most of the time.
|
|
203
|
-
result = target.read_memory(mmap.start_address, 0x10)
|
|
204
|
-
|
|
205
|
-
if self.state.project.loader.main_object.check_magic_compatibility(io.BytesIO(result)):
|
|
206
|
-
if mapped_object.mapped_base == mmap.start_address:
|
|
207
|
-
# We already have the correct address for this memory mapping
|
|
208
|
-
l.debug(
|
|
209
|
-
"Object %s is already rebased correctly at 0x%x", binary_name, mapped_object.mapped_base
|
|
210
|
-
)
|
|
211
|
-
self.already_sync_objects_addresses.append(mmap.name)
|
|
212
|
-
|
|
213
|
-
break # object has been synchronized, move to the next one!
|
|
214
|
-
|
|
215
|
-
# rebase the object if the CLE address doesn't match the real one,
|
|
216
|
-
# this can happen with PIE binaries and libraries.
|
|
217
|
-
l.debug(
|
|
218
|
-
"Remapping object %s mapped at address 0x%x at address 0x%x",
|
|
219
|
-
binary_name,
|
|
220
|
-
mapped_object.mapped_base,
|
|
221
|
-
mmap.start_address,
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
old_mapped_base = mapped_object.mapped_base
|
|
225
|
-
mapped_object.mapped_base = mmap.start_address # Rebase now!
|
|
226
|
-
|
|
227
|
-
# TODO re-write this horrible thing
|
|
228
|
-
mapped_object.sections._rebase(abs(mmap.start_address - old_mapped_base)) # fix sections
|
|
229
|
-
mapped_object.segments._rebase(abs(mmap.start_address - old_mapped_base)) # fix segments
|
|
230
|
-
|
|
231
|
-
self.already_sync_objects_addresses.append(mmap.name)
|
|
232
|
-
break # object has been synchronized, move to the next one!
|
|
233
|
-
|
|
234
|
-
def _sync_simproc(self):
|
|
235
|
-
l.debug("Restoring SimProc using concrete memory")
|
|
236
|
-
|
|
237
|
-
for reloc in self.state.project.loader.main_object.relocs:
|
|
238
|
-
if reloc.symbol: # consider only reloc with a symbol
|
|
239
|
-
l.debug("Trying to re-hook SimProc %s", reloc.symbol.name)
|
|
240
|
-
# l.debug("reloc.rebased_addr: %#x " % reloc.rebased_addr)
|
|
241
|
-
|
|
242
|
-
if self.state.project.simos.name == "Win32":
|
|
243
|
-
func_address = self.state.project.concrete_target.read_memory(
|
|
244
|
-
reloc.rebased_addr, self.state.arch.bytes
|
|
245
|
-
)
|
|
246
|
-
func_address = struct.unpack(self.state.project.arch.struct_fmt(), func_address)[0]
|
|
247
|
-
elif self.state.project.simos.name == "Linux":
|
|
248
|
-
try:
|
|
249
|
-
func_address = self.state.project.loader.main_object.plt[reloc.symbol.name]
|
|
250
|
-
except KeyError:
|
|
251
|
-
continue
|
|
252
|
-
else:
|
|
253
|
-
l.info("Can't synchronize simproc, binary format not supported.")
|
|
254
|
-
return
|
|
255
|
-
|
|
256
|
-
l.debug("Function address hook is now: %#x ", func_address)
|
|
257
|
-
self.state.project.rehook_symbol(func_address, reloc.symbol.name, self.stubs_on_sync)
|
|
258
|
-
|
|
259
|
-
if self.synchronize_cle and not self.state.project.loader.main_object.contains_addr(func_address):
|
|
260
|
-
old_func_symbol = self.state.project.loader.find_symbol(reloc.symbol.name)
|
|
261
|
-
|
|
262
|
-
if old_func_symbol: # if we actually have a symbol
|
|
263
|
-
owner_obj = old_func_symbol.owner
|
|
264
|
-
|
|
265
|
-
# calculating the new real address
|
|
266
|
-
new_relative_address = func_address - owner_obj.mapped_base
|
|
267
|
-
|
|
268
|
-
new_func_symbol = cle.backends.Symbol(
|
|
269
|
-
owner_obj,
|
|
270
|
-
old_func_symbol.name,
|
|
271
|
-
new_relative_address,
|
|
272
|
-
old_func_symbol.size,
|
|
273
|
-
old_func_symbol.type,
|
|
274
|
-
)
|
|
275
|
-
|
|
276
|
-
for new_reloc in self.state.project.loader.find_relevant_relocations(old_func_symbol.name):
|
|
277
|
-
if (
|
|
278
|
-
new_reloc.symbol.name == new_func_symbol.name
|
|
279
|
-
and new_reloc.value != new_func_symbol.rebased_addr
|
|
280
|
-
):
|
|
281
|
-
l.debug(
|
|
282
|
-
"Updating CLE symbols metadata, moving %s from 0x%x to 0x%x",
|
|
283
|
-
new_reloc.symbol.name,
|
|
284
|
-
new_reloc.value,
|
|
285
|
-
new_func_symbol.rebased_addr,
|
|
286
|
-
)
|
|
287
|
-
|
|
288
|
-
new_reloc.resolve(new_func_symbol)
|
|
289
|
-
new_reloc.relocate([])
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
from angr.sim_state import SimState
|
|
293
|
-
from angr import sim_options as options
|
|
294
|
-
|
|
295
|
-
SimState.register_default("concrete", Concrete)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|