angr 9.2.87__py3-none-manylinux2014_x86_64.whl → 9.2.89__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 +4 -1
- angr/analyses/decompiler/clinic.py +16 -0
- angr/analyses/decompiler/decompiler.py +3 -0
- angr/analyses/decompiler/optimization_passes/__init__.py +5 -0
- angr/analyses/decompiler/optimization_passes/cross_jump_reverter.py +108 -0
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +17 -4
- angr/analyses/decompiler/optimization_passes/return_duplicator.py +4 -32
- angr/analyses/decompiler/structured_codegen/c.py +12 -2
- angr/analyses/decompiler/utils.py +13 -0
- angr/analyses/typehoon/dfa.py +108 -0
- angr/analyses/typehoon/lifter.py +34 -2
- angr/analyses/typehoon/simple_solver.py +1043 -503
- angr/analyses/typehoon/translator.py +13 -4
- angr/analyses/typehoon/typeconsts.py +117 -36
- angr/analyses/typehoon/typehoon.py +31 -11
- angr/analyses/typehoon/typevars.py +88 -21
- angr/analyses/typehoon/variance.py +10 -0
- angr/analyses/variable_recovery/engine_ail.py +28 -9
- angr/analyses/variable_recovery/engine_base.py +50 -43
- angr/analyses/variable_recovery/variable_recovery_base.py +16 -3
- angr/analyses/variable_recovery/variable_recovery_fast.py +14 -5
- angr/exploration_techniques/tracer.py +2 -0
- angr/misc/autoimport.py +26 -0
- angr/procedures/definitions/__init__.py +32 -3
- angr/utils/constants.py +1 -0
- angr/utils/graph.py +20 -1
- {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/METADATA +7 -6
- {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/RECORD +32 -244
- angr-9.2.89.dist-info/top_level.txt +1 -0
- angr/procedures/definitions/ntdll.py +0 -12
- angr-9.2.87.dist-info/top_level.txt +0 -2
- tests/__init__.py +0 -0
- tests/analyses/__init__.py +0 -0
- tests/analyses/cfg/__init__.py +0 -0
- tests/analyses/cfg/test_cfg_clflush.py +0 -43
- tests/analyses/cfg/test_cfg_get_any_node.py +0 -34
- tests/analyses/cfg/test_cfg_manager.py +0 -32
- tests/analyses/cfg/test_cfg_model.py +0 -55
- tests/analyses/cfg/test_cfg_patching.py +0 -378
- tests/analyses/cfg/test_cfg_rust_got_resolution.py +0 -36
- tests/analyses/cfg/test_cfg_thumb_firmware.py +0 -50
- tests/analyses/cfg/test_cfg_vex_postprocessor.py +0 -27
- tests/analyses/cfg/test_cfgemulated.py +0 -634
- tests/analyses/cfg/test_cfgfast.py +0 -1123
- tests/analyses/cfg/test_cfgfast_soot.py +0 -38
- tests/analyses/cfg/test_const_resolver.py +0 -38
- tests/analyses/cfg/test_iat_resolver.py +0 -37
- tests/analyses/cfg/test_jumptables.py +0 -3008
- tests/analyses/cfg/test_noop_blocks.py +0 -54
- tests/analyses/cfg_slice_to_sink/__init__.py +0 -0
- tests/analyses/cfg_slice_to_sink/test_cfg_slice_to_sink.py +0 -93
- tests/analyses/cfg_slice_to_sink/test_graph.py +0 -114
- tests/analyses/cfg_slice_to_sink/test_transitions.py +0 -28
- tests/analyses/decompiler/__init__.py +0 -0
- tests/analyses/decompiler/test_baseptr_save_simplifier.py +0 -80
- tests/analyses/decompiler/test_decompiler.py +0 -3336
- tests/analyses/decompiler/test_peephole_optimizations.py +0 -48
- tests/analyses/decompiler/test_propagator_loops.py +0 -101
- tests/analyses/decompiler/test_structurer.py +0 -275
- tests/analyses/reaching_definitions/__init__.py +0 -0
- tests/analyses/reaching_definitions/test_dep_graph.py +0 -432
- tests/analyses/reaching_definitions/test_function_handler.py +0 -131
- tests/analyses/reaching_definitions/test_heap_allocator.py +0 -46
- tests/analyses/reaching_definitions/test_rd_state.py +0 -78
- tests/analyses/reaching_definitions/test_reachingdefinitions.py +0 -463
- tests/analyses/reaching_definitions/test_subject.py +0 -76
- tests/analyses/test_bindiff.py +0 -52
- tests/analyses/test_block_simplifier.py +0 -112
- tests/analyses/test_boyscout.py +0 -104
- tests/analyses/test_calling_convention_analysis.py +0 -352
- tests/analyses/test_callsite_maker.py +0 -60
- tests/analyses/test_cdg.py +0 -165
- tests/analyses/test_cfb.py +0 -37
- tests/analyses/test_class_identifier.py +0 -46
- tests/analyses/test_clinic.py +0 -30
- tests/analyses/test_codetagging.py +0 -32
- tests/analyses/test_constantpropagation.py +0 -88
- tests/analyses/test_ddg.py +0 -95
- tests/analyses/test_ddg_global_var_dependencies.py +0 -83
- tests/analyses/test_ddg_memvar_addresses.py +0 -40
- tests/analyses/test_disassembly.py +0 -121
- tests/analyses/test_find_objects_static.py +0 -35
- tests/analyses/test_flirt.py +0 -49
- tests/analyses/test_identifier.py +0 -33
- tests/analyses/test_init_finder.py +0 -38
- tests/analyses/test_proximitygraph.py +0 -31
- tests/analyses/test_reassembler.py +0 -295
- tests/analyses/test_regionidentifier.py +0 -27
- tests/analyses/test_slicing.py +0 -164
- tests/analyses/test_stack_pointer_tracker.py +0 -74
- tests/analyses/test_static_hooker.py +0 -28
- tests/analyses/test_typehoon.py +0 -55
- tests/analyses/test_variablerecovery.py +0 -464
- tests/analyses/test_vfg.py +0 -221
- tests/analyses/test_vtable.py +0 -31
- tests/analyses/test_xrefs.py +0 -77
- tests/common.py +0 -128
- tests/engines/__init__.py +0 -0
- tests/engines/light/__init__.py +0 -0
- tests/engines/light/test_data.py +0 -17
- tests/engines/pcode/__init__.py +0 -0
- tests/engines/pcode/test_emulate.py +0 -607
- tests/engines/pcode/test_pcode.py +0 -84
- tests/engines/test_actions.py +0 -27
- tests/engines/test_hook.py +0 -112
- tests/engines/test_java.py +0 -697
- tests/engines/test_unicorn.py +0 -518
- tests/engines/vex/__init__.py +0 -0
- tests/engines/vex/test_lifter.py +0 -124
- tests/engines/vex/test_vex.py +0 -574
- tests/exploration_techniques/__init__.py +0 -0
- tests/exploration_techniques/test_cacher.py +0 -45
- tests/exploration_techniques/test_director.py +0 -67
- tests/exploration_techniques/test_driller_core.py +0 -48
- tests/exploration_techniques/test_loop_seer.py +0 -158
- tests/exploration_techniques/test_memory_watcher.py +0 -46
- tests/exploration_techniques/test_oppologist.py +0 -65
- tests/exploration_techniques/test_spiller.py +0 -82
- tests/exploration_techniques/test_stochastic.py +0 -40
- tests/exploration_techniques/test_tech_builder.py +0 -61
- tests/exploration_techniques/test_tracer.py +0 -856
- tests/exploration_techniques/test_unique.py +0 -40
- tests/exploration_techniques/test_veritesting.py +0 -120
- tests/factory/__init__.py +0 -0
- tests/factory/block/__init__.py +0 -0
- tests/factory/block/test_block_cache.py +0 -33
- tests/factory/block/test_keystone.py +0 -106
- tests/factory/test_argc.py +0 -101
- tests/factory/test_argc_sym.py +0 -110
- tests/factory/test_argv.py +0 -158
- tests/factory/test_callable.py +0 -266
- tests/factory/test_windows_args.py +0 -36
- tests/knowledge_plugins/__init__.py +0 -0
- tests/knowledge_plugins/cfg/__init__.py +0 -0
- tests/knowledge_plugins/cfg/test_cfg_manager.py +0 -36
- tests/knowledge_plugins/functions/__init__.py +0 -0
- tests/knowledge_plugins/functions/test_function.py +0 -91
- tests/knowledge_plugins/functions/test_function2.py +0 -79
- tests/knowledge_plugins/functions/test_function_manager.py +0 -139
- tests/knowledge_plugins/functions/test_prototypes.py +0 -53
- tests/knowledge_plugins/key_definitions/__init__.py +0 -0
- tests/knowledge_plugins/key_definitions/test_atoms.py +0 -24
- tests/knowledge_plugins/key_definitions/test_environment.py +0 -126
- tests/knowledge_plugins/key_definitions/test_heap_address.py +0 -27
- tests/knowledge_plugins/key_definitions/test_live_definitions.py +0 -72
- tests/knowledge_plugins/test_dwarf_variables.py +0 -240
- tests/knowledge_plugins/test_kb_plugins.py +0 -91
- tests/knowledge_plugins/test_kb_plugins_dwarf.py +0 -36
- tests/knowledge_plugins/test_patches.py +0 -48
- tests/misc/__init__.py +0 -0
- tests/misc/test_hookset.py +0 -57
- tests/perf/__init__.py +0 -0
- tests/perf/perf_cfgemulated.py +0 -19
- tests/perf/perf_cfgfast.py +0 -18
- tests/perf/perf_concrete_execution.py +0 -41
- tests/perf/perf_siminspect_nop.py +0 -36
- tests/perf/perf_state_copy.py +0 -33
- tests/perf/perf_unicorn_0.py +0 -27
- tests/perf/perf_unicorn_1.py +0 -23
- tests/procedures/__init__.py +0 -0
- tests/procedures/glibc/__init__.py +0 -0
- tests/procedures/glibc/test_ctype_locale.py +0 -164
- tests/procedures/libc/__init__.py +0 -0
- tests/procedures/libc/test_fgets.py +0 -53
- tests/procedures/libc/test_scanf.py +0 -205
- tests/procedures/libc/test_sprintf.py +0 -44
- tests/procedures/libc/test_sscanf.py +0 -63
- tests/procedures/libc/test_strcasecmp.py +0 -37
- tests/procedures/libc/test_string.py +0 -1102
- tests/procedures/libc/test_strtol.py +0 -78
- tests/procedures/linux_kernel/__init__.py +0 -0
- tests/procedures/linux_kernel/test_lseek.py +0 -174
- tests/procedures/posix/__init__.py +0 -0
- tests/procedures/posix/test_chroot.py +0 -33
- tests/procedures/posix/test_getenv.py +0 -78
- tests/procedures/posix/test_pwrite_pread.py +0 -57
- tests/procedures/posix/test_sim_time.py +0 -46
- tests/procedures/posix/test_unlink.py +0 -46
- tests/procedures/test_project_resolve_simproc.py +0 -43
- tests/procedures/test_sim_procedure.py +0 -117
- tests/procedures/test_stub_procedure_args.py +0 -53
- tests/serialization/__init__.py +0 -0
- tests/serialization/test_db.py +0 -197
- tests/serialization/test_pickle.py +0 -95
- tests/serialization/test_serialization.py +0 -132
- tests/serialization/test_vault.py +0 -169
- tests/sim/__init__.py +0 -3
- tests/sim/exec_func/__init__.py +0 -0
- tests/sim/exec_func/test_mem_funcs.py +0 -55
- tests/sim/exec_func/test_str_funcs.py +0 -93
- tests/sim/exec_func/test_syscall_result.py +0 -39
- tests/sim/exec_insn/__init__.py +0 -0
- tests/sim/exec_insn/test_adc.py +0 -44
- tests/sim/exec_insn/test_ops.py +0 -83
- tests/sim/exec_insn/test_rcr.py +0 -26
- tests/sim/exec_insn/test_rol.py +0 -51
- tests/sim/exec_insn/test_signed_div.py +0 -34
- tests/sim/exec_insn/test_sqrt.py +0 -56
- tests/sim/options/__init__.py +0 -0
- tests/sim/options/test_0div.py +0 -54
- tests/sim/options/test_symbolic_fd.py +0 -59
- tests/sim/options/test_unsupported.py +0 -34
- tests/sim/test_accuracy.py +0 -137
- tests/sim/test_checkbyte.py +0 -53
- tests/sim/test_echo.py +0 -36
- tests/sim/test_fauxware.py +0 -202
- tests/sim/test_self_modifying_code.py +0 -65
- tests/sim/test_simple_api.py +0 -36
- tests/sim/test_simulation_manager.py +0 -147
- tests/sim/test_stack_alignment.py +0 -65
- tests/sim/test_state.py +0 -303
- tests/sim/test_state_customization.py +0 -54
- tests/sim/test_symbol_hooked_by.py +0 -49
- tests/simos/__init__.py +0 -0
- tests/simos/windows/__init__.py +0 -0
- tests/simos/windows/test_windows_stack_cookie.py +0 -58
- tests/state_plugins/__init__.py +0 -0
- tests/state_plugins/inspect/__init__.py +0 -0
- tests/state_plugins/inspect/test_inspect.py +0 -310
- tests/state_plugins/inspect/test_syscall_override.py +0 -90
- tests/state_plugins/posix/__init__.py +0 -0
- tests/state_plugins/posix/test_file_struct_funcs.py +0 -56
- tests/state_plugins/posix/test_files.py +0 -69
- tests/state_plugins/posix/test_posix.py +0 -72
- tests/state_plugins/solver/__init__.py +0 -0
- tests/state_plugins/solver/test_simsolver.py +0 -58
- tests/state_plugins/solver/test_symbolic.py +0 -153
- tests/state_plugins/solver/test_variable_registration.py +0 -46
- tests/state_plugins/test_callstack.py +0 -54
- tests/state_plugins/test_gdb_plugin.py +0 -35
- tests/state_plugins/test_multi_open_file.py +0 -47
- tests/state_plugins/test_symbolization.py +0 -38
- tests/storage/__init__.py +0 -0
- tests/storage/test_memory.py +0 -960
- tests/storage/test_memory_merge.py +0 -114
- tests/storage/test_memview.py +0 -205
- tests/storage/test_mmap.py +0 -26
- tests/storage/test_multivalues.py +0 -44
- tests/storage/test_permissions.py +0 -32
- tests/storage/test_ptmalloc.py +0 -291
- tests/storage/test_relro_perm.py +0 -49
- tests/test_calling_conventions.py +0 -86
- tests/test_types.py +0 -329
- tests/utils/__init__.py +0 -0
- tests/utils/test_graph.py +0 -41
- {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/LICENSE +0 -0
- {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/WHEEL +0 -0
- {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/entry_points.txt +0 -0
tests/factory/test_callable.py
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.factory" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import unittest
|
|
6
|
-
|
|
7
|
-
import claripy
|
|
8
|
-
import archinfo
|
|
9
|
-
|
|
10
|
-
import angr
|
|
11
|
-
from angr.sim_type import SimTypePointer, SimTypeFunction, SimTypeChar, SimTypeInt, parse_defns
|
|
12
|
-
from angr.errors import AngrCallableMultistateError
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from ..common import bin_location, slow_test
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
test_location = os.path.join(bin_location, "tests")
|
|
19
|
-
|
|
20
|
-
addresses_fauxware = {
|
|
21
|
-
"armel": 0x8524,
|
|
22
|
-
"armhf": 0x104C9, # addr+1 to force thumb
|
|
23
|
-
"i386": 0x8048524,
|
|
24
|
-
"mips": 0x400710,
|
|
25
|
-
"mipsel": 0x4006D0,
|
|
26
|
-
"ppc": 0x1000054C,
|
|
27
|
-
"ppc64": 0x10000698,
|
|
28
|
-
"x86_64": 0x400664,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
addresses_manysum = {
|
|
32
|
-
"armel": 0x1041C,
|
|
33
|
-
"armhf": 0x103BD,
|
|
34
|
-
"i386": 0x80483D8,
|
|
35
|
-
"mips": 0x400704,
|
|
36
|
-
"mipsel": 0x400704,
|
|
37
|
-
"ppc": 0x10000418,
|
|
38
|
-
"ppc64": 0x10000500,
|
|
39
|
-
"x86_64": 0x4004CA,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type_cache = None
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class TestCallable(unittest.TestCase):
|
|
46
|
-
def run_fauxware(self, arch):
|
|
47
|
-
addr = addresses_fauxware[arch]
|
|
48
|
-
p = angr.Project(os.path.join(test_location, arch, "fauxware"))
|
|
49
|
-
charstar = SimTypePointer(SimTypeChar())
|
|
50
|
-
prototype = SimTypeFunction((charstar, charstar), SimTypeInt(False))
|
|
51
|
-
authenticate = p.factory.callable(
|
|
52
|
-
addr, toc=0x10018E80 if arch == "ppc64" else None, concrete_only=True, prototype=prototype
|
|
53
|
-
)
|
|
54
|
-
assert authenticate("asdf", "SOSNEAKY").concrete_value == 1
|
|
55
|
-
self.assertRaises(AngrCallableMultistateError, authenticate, "asdf", "NOSNEAKY")
|
|
56
|
-
|
|
57
|
-
def run_callable_c_fauxware(self, arch):
|
|
58
|
-
addr = addresses_fauxware[arch]
|
|
59
|
-
p = angr.Project(os.path.join(test_location, arch, "fauxware"))
|
|
60
|
-
authenticate = p.factory.callable(
|
|
61
|
-
addr, toc=0x10018E80 if arch == "ppc64" else None, concrete_only=True, prototype="int f(char*, char*)"
|
|
62
|
-
)
|
|
63
|
-
retval = authenticate.call_c('("asdf", "SOSNEAKY")')
|
|
64
|
-
assert retval.concrete_value == 1
|
|
65
|
-
|
|
66
|
-
def run_manysum(self, arch):
|
|
67
|
-
addr = addresses_manysum[arch]
|
|
68
|
-
p = angr.Project(os.path.join(test_location, arch, "manysum"))
|
|
69
|
-
inttype = SimTypeInt()
|
|
70
|
-
prototype = SimTypeFunction([inttype] * 11, inttype)
|
|
71
|
-
sumlots = p.factory.callable(addr, prototype=prototype)
|
|
72
|
-
result = sumlots(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
|
|
73
|
-
assert not result.symbolic
|
|
74
|
-
assert result.concrete_value == sum(range(12))
|
|
75
|
-
|
|
76
|
-
def run_callable_c_manysum(self, arch):
|
|
77
|
-
addr = addresses_manysum[arch]
|
|
78
|
-
p = angr.Project(os.path.join(test_location, arch, "manysum"))
|
|
79
|
-
sumlots = p.factory.callable(addr, prototype="int f(int, int, int, int, int, int, int, int, int, int, int)")
|
|
80
|
-
result = sumlots.call_c("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)")
|
|
81
|
-
assert not result.symbolic
|
|
82
|
-
assert result.concrete_value == sum(range(12))
|
|
83
|
-
|
|
84
|
-
def run_manyfloatsum(self, arch):
|
|
85
|
-
global type_cache
|
|
86
|
-
if type_cache is None:
|
|
87
|
-
with open(os.path.join(bin_location, "tests_src", "manyfloatsum.c")) as fp:
|
|
88
|
-
type_cache = parse_defns(fp.read())
|
|
89
|
-
|
|
90
|
-
p = angr.Project(os.path.join(test_location, arch, "manyfloatsum"))
|
|
91
|
-
for function in (
|
|
92
|
-
"sum_floats",
|
|
93
|
-
"sum_combo",
|
|
94
|
-
"sum_segregated",
|
|
95
|
-
"sum_doubles",
|
|
96
|
-
"sum_combo_doubles",
|
|
97
|
-
"sum_segregated_doubles",
|
|
98
|
-
):
|
|
99
|
-
args = list(range(len(type_cache[function].args)))
|
|
100
|
-
answer = float(sum(args))
|
|
101
|
-
addr = p.loader.main_object.get_symbol(function).rebased_addr
|
|
102
|
-
my_callable = p.factory.callable(addr, prototype=type_cache[function])
|
|
103
|
-
result = my_callable(*args)
|
|
104
|
-
assert not result.symbolic
|
|
105
|
-
result_concrete = result.args[0]
|
|
106
|
-
assert answer == result_concrete
|
|
107
|
-
|
|
108
|
-
@slow_test
|
|
109
|
-
def run_manyfloatsum_symbolic(self, arch):
|
|
110
|
-
global type_cache
|
|
111
|
-
if type_cache is None:
|
|
112
|
-
with open(os.path.join(bin_location, "tests_src", "manyfloatsum.c")) as fp:
|
|
113
|
-
type_cache = parse_defns(fp.read())
|
|
114
|
-
|
|
115
|
-
p = angr.Project(os.path.join(test_location, arch, "manyfloatsum"))
|
|
116
|
-
function = "sum_doubles"
|
|
117
|
-
args = [claripy.FPS("arg_%d" % i, claripy.FSORT_DOUBLE) for i in range(len(type_cache[function].args))]
|
|
118
|
-
addr = p.loader.main_object.get_symbol(function).rebased_addr
|
|
119
|
-
my_callable = p.factory.callable(addr, prototype=type_cache[function])
|
|
120
|
-
result = my_callable(*args)
|
|
121
|
-
assert result.symbolic
|
|
122
|
-
|
|
123
|
-
s = claripy.Solver(timeout=15 * 60 * 1000)
|
|
124
|
-
for arg in args:
|
|
125
|
-
s.add(arg > claripy.FPV(1.0, claripy.FSORT_DOUBLE))
|
|
126
|
-
s.add(result == claripy.FPV(27.7, claripy.FSORT_DOUBLE))
|
|
127
|
-
|
|
128
|
-
args_conc = s.batch_eval(args, 1)[0]
|
|
129
|
-
assert s.eval(result, 1)[0] == 27.7
|
|
130
|
-
# not almost equal!! totally equal!!! z3 is magic, if kinda slow!!!!!
|
|
131
|
-
for arg_conc in args_conc:
|
|
132
|
-
assert arg_conc > 1.0
|
|
133
|
-
assert sum(args_conc) == 27.7
|
|
134
|
-
|
|
135
|
-
def test_fauxware_armel(self):
|
|
136
|
-
self.run_fauxware("armel")
|
|
137
|
-
|
|
138
|
-
def test_fauxware_armhf(self):
|
|
139
|
-
self.run_fauxware("armhf")
|
|
140
|
-
|
|
141
|
-
def test_fauxware_i386(self):
|
|
142
|
-
self.run_fauxware("i386")
|
|
143
|
-
|
|
144
|
-
def test_fauxware_mips(self):
|
|
145
|
-
self.run_fauxware("mips")
|
|
146
|
-
|
|
147
|
-
def test_fauxware_mipsel(self):
|
|
148
|
-
self.run_fauxware("mipsel")
|
|
149
|
-
|
|
150
|
-
def test_fauxware_ppc(self):
|
|
151
|
-
self.run_fauxware("ppc")
|
|
152
|
-
|
|
153
|
-
def test_fauxware_ppc64(self):
|
|
154
|
-
self.run_fauxware("ppc64")
|
|
155
|
-
|
|
156
|
-
def test_fauxware_x86_64(self):
|
|
157
|
-
self.run_fauxware("x86_64")
|
|
158
|
-
|
|
159
|
-
def test_manysum_armel(self):
|
|
160
|
-
self.run_manysum("armel")
|
|
161
|
-
|
|
162
|
-
def test_manysum_armhf(self):
|
|
163
|
-
self.run_manysum("armhf")
|
|
164
|
-
|
|
165
|
-
def test_manysum_i386(self):
|
|
166
|
-
self.run_manysum("i386")
|
|
167
|
-
|
|
168
|
-
def test_manysum_mips(self):
|
|
169
|
-
self.run_manysum("mips")
|
|
170
|
-
|
|
171
|
-
def test_manysum_mipsel(self):
|
|
172
|
-
self.run_manysum("mipsel")
|
|
173
|
-
|
|
174
|
-
def test_manysum_ppc(self):
|
|
175
|
-
self.run_manysum("ppc")
|
|
176
|
-
|
|
177
|
-
def test_manysum_ppc64(self):
|
|
178
|
-
self.run_manysum("ppc64")
|
|
179
|
-
|
|
180
|
-
def test_manysum_x86_64(self):
|
|
181
|
-
self.run_manysum("x86_64")
|
|
182
|
-
|
|
183
|
-
def test_manyfloatsum_i386(self):
|
|
184
|
-
self.run_manyfloatsum("i386")
|
|
185
|
-
|
|
186
|
-
def test_manyfloatsum_x86_64(self):
|
|
187
|
-
self.run_manyfloatsum("x86_64")
|
|
188
|
-
|
|
189
|
-
@slow_test
|
|
190
|
-
def test_manyfloatsum_symbolic_i386(self):
|
|
191
|
-
# doesn't have to be slow but it might be
|
|
192
|
-
# https://github.com/Z3Prover/z3/issues/2584
|
|
193
|
-
self.run_manyfloatsum_symbolic("i386")
|
|
194
|
-
|
|
195
|
-
@slow_test
|
|
196
|
-
def test_manyfloatsum_symbolic_x86_64(self):
|
|
197
|
-
# doesn't have to be slow but it might be
|
|
198
|
-
# https://github.com/Z3Prover/z3/issues/2584
|
|
199
|
-
self.run_manyfloatsum_symbolic("x86_64")
|
|
200
|
-
|
|
201
|
-
def test_callable_c_fauxware_armel(self):
|
|
202
|
-
self.run_callable_c_fauxware("armel")
|
|
203
|
-
|
|
204
|
-
def test_callable_c_fauxware_armhf(self):
|
|
205
|
-
self.run_callable_c_fauxware("armhf")
|
|
206
|
-
|
|
207
|
-
def test_callable_c_fauxware_i386(self):
|
|
208
|
-
self.run_callable_c_fauxware("i386")
|
|
209
|
-
|
|
210
|
-
def test_callable_c_fauxware_mips(self):
|
|
211
|
-
self.run_callable_c_fauxware("mips")
|
|
212
|
-
|
|
213
|
-
def test_callable_c_fauxware_mipsel(self):
|
|
214
|
-
self.run_callable_c_fauxware("mipsel")
|
|
215
|
-
|
|
216
|
-
def test_callable_c_fauxware_ppc(self):
|
|
217
|
-
self.run_callable_c_fauxware("ppc")
|
|
218
|
-
|
|
219
|
-
def test_callable_c_fauxware_ppc64(self):
|
|
220
|
-
self.run_callable_c_fauxware("ppc64")
|
|
221
|
-
|
|
222
|
-
def test_callable_c_fauxware_x86_64(self):
|
|
223
|
-
self.run_callable_c_fauxware("x86_64")
|
|
224
|
-
|
|
225
|
-
def test_callable_c_manyfloatsum_armel(self):
|
|
226
|
-
self.run_callable_c_manysum("armel")
|
|
227
|
-
|
|
228
|
-
def test_callable_c_manyfloatsum_armhf(self):
|
|
229
|
-
self.run_callable_c_manysum("armhf")
|
|
230
|
-
|
|
231
|
-
def test_callable_c_manyfloatsum_i386(self):
|
|
232
|
-
self.run_callable_c_manysum("i386")
|
|
233
|
-
|
|
234
|
-
def test_callable_c_manyfloatsum_mips(self):
|
|
235
|
-
self.run_callable_c_manysum("mips")
|
|
236
|
-
|
|
237
|
-
def test_callable_c_manyfloatsum_mipsel(self):
|
|
238
|
-
self.run_callable_c_manysum("mipsel")
|
|
239
|
-
|
|
240
|
-
def test_callable_c_manyfloatsum_ppc(self):
|
|
241
|
-
self.run_callable_c_manysum("ppc")
|
|
242
|
-
|
|
243
|
-
def test_callable_c_manyfloatsum_ppc64(self):
|
|
244
|
-
self.run_callable_c_manysum("ppc64")
|
|
245
|
-
|
|
246
|
-
def test_callable_c_manyfloatsum_x86_64(self):
|
|
247
|
-
self.run_callable_c_manysum("x86_64")
|
|
248
|
-
|
|
249
|
-
def test_setup_callsite(self):
|
|
250
|
-
p = angr.load_shellcode(b"b", arch=archinfo.ArchX86())
|
|
251
|
-
|
|
252
|
-
s = p.factory.call_state(
|
|
253
|
-
0, "hello", prototype="void x(char*)", stack_base=0x1234, alloc_base=0x5678, grow_like_stack=False
|
|
254
|
-
)
|
|
255
|
-
assert (s.regs.sp == 0x1234).is_true()
|
|
256
|
-
assert (s.mem[0x1234 + 4].long.resolved == 0x5678).is_true()
|
|
257
|
-
assert (s.memory.load(0x5678, 5) == b"hello").is_true()
|
|
258
|
-
|
|
259
|
-
s = p.factory.call_state(0, "hello", prototype="void x(char*)", stack_base=0x1234)
|
|
260
|
-
assert (s.regs.sp == 0x1234).is_true()
|
|
261
|
-
assert (s.mem[0x1234 + 4].long.resolved == 0x1234 + 8).is_true()
|
|
262
|
-
assert (s.memory.load(0x1234 + 8, 5) == b"hello").is_true()
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if __name__ == "__main__":
|
|
266
|
-
unittest.main()
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,no-self-use,line-too-long
|
|
3
|
-
__package__ = __package__ or "tests.factory" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import logging
|
|
6
|
-
import os
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
|
|
11
|
-
from ..common import bin_location
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test_location = os.path.join(bin_location, "tests")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestWindowsArgs(unittest.TestCase):
|
|
18
|
-
def test_i386(self):
|
|
19
|
-
after_puts = 0x40105B
|
|
20
|
-
else_paths = [0x401062, 0x401009]
|
|
21
|
-
|
|
22
|
-
p = angr.Project(os.path.join(test_location, "i386", "simple_windows.exe"), auto_load_libs=False)
|
|
23
|
-
|
|
24
|
-
s = p.factory.entry_state(args=("simple_windows.exe", "angr_can_windows?", "1497715489"))
|
|
25
|
-
simgr = p.factory.simulation_manager(s)
|
|
26
|
-
simgr.explore(find=after_puts, avoid=else_paths, num_find=10)
|
|
27
|
-
|
|
28
|
-
assert len(simgr.avoid) == 0
|
|
29
|
-
assert len(simgr.found) > 0
|
|
30
|
-
for f in simgr.found:
|
|
31
|
-
assert b"ok" in f.posix.dumps(1)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if __name__ == "__main__":
|
|
35
|
-
logging.getLogger("angr.engines").setLevel("INFO")
|
|
36
|
-
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from unittest import main, TestCase
|
|
3
|
-
|
|
4
|
-
from angr.knowledge_plugins.cfg import CFGManager
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class TestCFGManager(TestCase):
|
|
8
|
-
def setUp(self):
|
|
9
|
-
self.cfg_manager = CFGManager(None)
|
|
10
|
-
|
|
11
|
-
def test_when_both_cfg_emulated_and_cfg_fast_are_present(self):
|
|
12
|
-
self.cfg_manager["CFGEmulated"] = "fake CFGEmulated"
|
|
13
|
-
self.cfg_manager["CFGFast"] = "fake CFGFast"
|
|
14
|
-
|
|
15
|
-
result = self.cfg_manager.get_most_accurate()
|
|
16
|
-
self.assertEqual(result, "fake CFGEmulated")
|
|
17
|
-
|
|
18
|
-
def test_when_only_cfg_emulated_is_present(self):
|
|
19
|
-
self.cfg_manager["CFGEmulated"] = "fake CFGEmulated"
|
|
20
|
-
|
|
21
|
-
result = self.cfg_manager.get_most_accurate()
|
|
22
|
-
self.assertEqual(result, "fake CFGEmulated")
|
|
23
|
-
|
|
24
|
-
def test_when_only_cfg_fast_is_present(self):
|
|
25
|
-
self.cfg_manager["CFGFast"] = "fake CFGFast"
|
|
26
|
-
|
|
27
|
-
result = self.cfg_manager.get_most_accurate()
|
|
28
|
-
self.assertEqual(result, "fake CFGFast")
|
|
29
|
-
|
|
30
|
-
def test_when_no_cfg_is_present(self):
|
|
31
|
-
result = self.cfg_manager.get_most_accurate()
|
|
32
|
-
self.assertEqual(result, None)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if __name__ == "__main__":
|
|
36
|
-
main()
|
|
File without changes
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from unittest import main, TestCase
|
|
3
|
-
|
|
4
|
-
import networkx
|
|
5
|
-
|
|
6
|
-
from angr.knowledge_plugins.functions import Function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def makeFunction(function_manager, function_address, function_name):
|
|
10
|
-
# Fill some value that are not relevant for the tests, but help circumvent a lot of mocking.
|
|
11
|
-
f = Function(
|
|
12
|
-
function_manager,
|
|
13
|
-
function_address,
|
|
14
|
-
name=function_name,
|
|
15
|
-
syscall=False,
|
|
16
|
-
is_simprocedure=False,
|
|
17
|
-
is_plt=False,
|
|
18
|
-
binary_name="rpaulson.bin",
|
|
19
|
-
returning=True,
|
|
20
|
-
)
|
|
21
|
-
function_manager._function_map[function_address] = f
|
|
22
|
-
return f
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class MockFunctionManager:
|
|
26
|
-
def __init__(self):
|
|
27
|
-
self.callgraph = networkx.MultiDiGraph()
|
|
28
|
-
self._function_map = {}
|
|
29
|
-
|
|
30
|
-
def function(self, address):
|
|
31
|
-
return self._function_map[address]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class TestFunction(TestCase):
|
|
35
|
-
def setUp(self):
|
|
36
|
-
self.function_manager = MockFunctionManager()
|
|
37
|
-
|
|
38
|
-
def test_functions_called_returns_all_functions_that_can_be_reached_from_the_function(self):
|
|
39
|
-
A = makeFunction(self.function_manager, 0x40, "A")
|
|
40
|
-
B = makeFunction(self.function_manager, 0x41, "B")
|
|
41
|
-
function = makeFunction(self.function_manager, 0x42, "function")
|
|
42
|
-
C = makeFunction(self.function_manager, 0x43, "C")
|
|
43
|
-
D = makeFunction(self.function_manager, 0x44, "D")
|
|
44
|
-
E = makeFunction(self.function_manager, 0x45, "E")
|
|
45
|
-
|
|
46
|
-
# A -> B
|
|
47
|
-
# function -> C -> D
|
|
48
|
-
# function -> E
|
|
49
|
-
self.function_manager.callgraph.add_edges_from(
|
|
50
|
-
[
|
|
51
|
-
(A.addr, B.addr),
|
|
52
|
-
(function.addr, C.addr),
|
|
53
|
-
(function.addr, E.addr),
|
|
54
|
-
(C.addr, D.addr),
|
|
55
|
-
]
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
self.assertEqual(function.functions_called(), {C, D, E})
|
|
59
|
-
|
|
60
|
-
def test_functions_called_with_recursive_function(self):
|
|
61
|
-
recursive_function = makeFunction(self.function_manager, 0x40, "recursive_function")
|
|
62
|
-
B = makeFunction(self.function_manager, 0x41, "B")
|
|
63
|
-
|
|
64
|
-
# recursive_function -> B
|
|
65
|
-
# recursive_function -> recursive_function
|
|
66
|
-
self.function_manager.callgraph.add_edges_from(
|
|
67
|
-
[
|
|
68
|
-
(recursive_function.addr, B.addr),
|
|
69
|
-
(recursive_function.addr, recursive_function.addr),
|
|
70
|
-
]
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
self.assertEqual(recursive_function.functions_called(), {recursive_function, B})
|
|
74
|
-
|
|
75
|
-
def test_functions_called_with_cyclic_dependencies(self):
|
|
76
|
-
function = makeFunction(self.function_manager, 0x42, "function")
|
|
77
|
-
C = makeFunction(self.function_manager, 0x43, "C")
|
|
78
|
-
|
|
79
|
-
# function -> C -> function
|
|
80
|
-
self.function_manager.callgraph.add_edges_from(
|
|
81
|
-
[
|
|
82
|
-
(function.addr, C.addr),
|
|
83
|
-
(C.addr, function.addr),
|
|
84
|
-
]
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
self.assertEqual(function.functions_called(), {function, C})
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if __name__ == "__main__":
|
|
91
|
-
main()
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.knowledge_plugins.functions" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import unittest
|
|
7
|
-
|
|
8
|
-
import angr
|
|
9
|
-
|
|
10
|
-
from ...common import bin_location
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
test_location = os.path.join(bin_location, "tests")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class TestFunction(unittest.TestCase):
|
|
17
|
-
def test_function_serialization(self):
|
|
18
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
19
|
-
cfg = p.analyses.CFG()
|
|
20
|
-
|
|
21
|
-
func_main = cfg.kb.functions["main"]
|
|
22
|
-
s = func_main.serialize()
|
|
23
|
-
|
|
24
|
-
assert type(s) is bytes
|
|
25
|
-
assert len(s) > 10
|
|
26
|
-
|
|
27
|
-
f = angr.knowledge_plugins.Function.parse(s)
|
|
28
|
-
assert func_main.addr == f.addr
|
|
29
|
-
assert func_main.name == f.name
|
|
30
|
-
assert func_main.is_prototype_guessed == f.is_prototype_guessed
|
|
31
|
-
|
|
32
|
-
def test_function_definition_application(self):
|
|
33
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
34
|
-
cfg = p.analyses.CFG()
|
|
35
|
-
func_main: angr.knowledge_plugins.Function = cfg.kb.functions["main"]
|
|
36
|
-
|
|
37
|
-
func_main.apply_definition("int main(int argc, char** argv)")
|
|
38
|
-
|
|
39
|
-
# Check prototype of function
|
|
40
|
-
assert func_main.prototype.args == [
|
|
41
|
-
angr.sim_type.SimTypeInt().with_arch(p.arch),
|
|
42
|
-
angr.sim_type.SimTypePointer(
|
|
43
|
-
angr.sim_type.SimTypePointer(angr.sim_type.SimTypeChar()).with_arch(p.arch)
|
|
44
|
-
).with_arch(p.arch),
|
|
45
|
-
]
|
|
46
|
-
# Check that the default calling convention of the architecture was applied
|
|
47
|
-
assert isinstance(func_main.calling_convention, angr.calling_conventions.DefaultCC[p.arch.name]["Linux"])
|
|
48
|
-
|
|
49
|
-
func_main.apply_definition("int main(int argc, char** argv)")
|
|
50
|
-
|
|
51
|
-
def test_function_instruction_addr_from_any_addr(self):
|
|
52
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
53
|
-
cfg = p.analyses.CFG()
|
|
54
|
-
|
|
55
|
-
func_main = cfg.kb.functions["main"]
|
|
56
|
-
|
|
57
|
-
assert func_main.addr_to_instruction_addr(0x400739) == 0x400739
|
|
58
|
-
assert func_main.addr_to_instruction_addr(0x40073A) == 0x400739
|
|
59
|
-
assert func_main.addr_to_instruction_addr(0x40073D) == 0x400739
|
|
60
|
-
assert func_main.addr_to_instruction_addr(0x400742) == 0x400742
|
|
61
|
-
assert func_main.addr_to_instruction_addr(0x400743) == 0x400742
|
|
62
|
-
|
|
63
|
-
def test_function_instruction_size(self):
|
|
64
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
65
|
-
cfg = p.analyses.CFG()
|
|
66
|
-
|
|
67
|
-
func_main = cfg.kb.functions["main"]
|
|
68
|
-
|
|
69
|
-
assert func_main.instruction_size(0x40071D) == 1
|
|
70
|
-
assert func_main.instruction_size(0x40071E) == 3
|
|
71
|
-
assert func_main.instruction_size(0x400721) == 4
|
|
72
|
-
assert func_main.instruction_size(0x400725) == 3
|
|
73
|
-
assert func_main.instruction_size(0x400728) == 4
|
|
74
|
-
assert func_main.instruction_size(0x400739) == 5
|
|
75
|
-
assert func_main.instruction_size(0x400742) == 5
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if __name__ == "__main__":
|
|
79
|
-
unittest.main()
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.knowledge_plugins.functions" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import unittest
|
|
6
|
-
|
|
7
|
-
from archinfo import ArchAMD64
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
from angr.utils.constants import DEFAULT_STATEMENT
|
|
11
|
-
|
|
12
|
-
from ...common import bin_location
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
test_location = os.path.join(bin_location, "tests")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class TestFunctionManager(unittest.TestCase):
|
|
19
|
-
@classmethod
|
|
20
|
-
def setUpClass(cls):
|
|
21
|
-
cls.project = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
22
|
-
|
|
23
|
-
def test_amd64(self):
|
|
24
|
-
expected_functions = {
|
|
25
|
-
0x4004E0,
|
|
26
|
-
0x400510,
|
|
27
|
-
0x400520,
|
|
28
|
-
0x400530,
|
|
29
|
-
0x400540,
|
|
30
|
-
0x400550,
|
|
31
|
-
0x400560,
|
|
32
|
-
0x400570,
|
|
33
|
-
0x400580,
|
|
34
|
-
0x4005AC,
|
|
35
|
-
0x400640,
|
|
36
|
-
0x400664,
|
|
37
|
-
0x4006ED,
|
|
38
|
-
0x4006FD,
|
|
39
|
-
0x40071D,
|
|
40
|
-
0x4007E0,
|
|
41
|
-
0x400880,
|
|
42
|
-
}
|
|
43
|
-
expected_blocks = {
|
|
44
|
-
0x40071D,
|
|
45
|
-
0x40073E,
|
|
46
|
-
0x400754,
|
|
47
|
-
0x40076A,
|
|
48
|
-
0x400774,
|
|
49
|
-
0x40078A,
|
|
50
|
-
0x4007A0,
|
|
51
|
-
0x4007B3,
|
|
52
|
-
0x4007C7,
|
|
53
|
-
0x4007C9,
|
|
54
|
-
0x4007BD,
|
|
55
|
-
0x4007D3,
|
|
56
|
-
}
|
|
57
|
-
expected_callsites = {0x40071D, 0x40073E, 0x400754, 0x40076A, 0x400774, 0x40078A, 0x4007A0, 0x4007BD, 0x4007C9}
|
|
58
|
-
expected_callsite_targets = {4195600, 4195632, 4195632, 4195600, 4195632, 4195632, 4195940, 4196077, 4196093}
|
|
59
|
-
expected_callsite_returns = {
|
|
60
|
-
0x40073E,
|
|
61
|
-
0x400754,
|
|
62
|
-
0x40076A,
|
|
63
|
-
0x400774,
|
|
64
|
-
0x40078A,
|
|
65
|
-
0x4007A0,
|
|
66
|
-
0x4007B3,
|
|
67
|
-
0x4007C7,
|
|
68
|
-
None,
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
self.project.analyses.CFGEmulated()
|
|
72
|
-
assert {k for k in self.project.kb.functions.keys() if k < 0x500000} == expected_functions
|
|
73
|
-
|
|
74
|
-
main = self.project.kb.functions.function(name="main")
|
|
75
|
-
assert main.startpoint.addr == 0x40071D
|
|
76
|
-
assert set(main.block_addrs) == expected_blocks
|
|
77
|
-
assert [0x4007D3] == [bl.addr for bl in main.endpoints]
|
|
78
|
-
assert set(main.get_call_sites()) == expected_callsites
|
|
79
|
-
assert set(map(main.get_call_target, main.get_call_sites())) == expected_callsite_targets
|
|
80
|
-
assert set(map(main.get_call_return, main.get_call_sites())) == expected_callsite_returns
|
|
81
|
-
assert main.has_return
|
|
82
|
-
|
|
83
|
-
rejected = self.project.kb.functions.function(name="rejected")
|
|
84
|
-
assert rejected.returning is False
|
|
85
|
-
|
|
86
|
-
# transition graph
|
|
87
|
-
main_g = main.transition_graph
|
|
88
|
-
main_g_edges_ = main_g.edges(data=True)
|
|
89
|
-
|
|
90
|
-
# Convert nodes those edges from blocks to addresses
|
|
91
|
-
main_g_edges = []
|
|
92
|
-
for src_node, dst_node, data in main_g_edges_:
|
|
93
|
-
main_g_edges.append((src_node.addr, dst_node.addr, data))
|
|
94
|
-
|
|
95
|
-
edges = [
|
|
96
|
-
(0x40071D, 0x400510, {"type": "call", "stmt_idx": DEFAULT_STATEMENT, "ins_addr": 0x400739}),
|
|
97
|
-
(0x40071D, 0x400510, {"type": "call", "stmt_idx": DEFAULT_STATEMENT, "ins_addr": 0x400739}),
|
|
98
|
-
(0x40071D, 0x40073E, {"type": "fake_return", "confirmed": True, "outside": False}),
|
|
99
|
-
(0x40073E, 0x400530, {"type": "call", "stmt_idx": DEFAULT_STATEMENT, "ins_addr": 0x40074F}),
|
|
100
|
-
(0x40073E, 0x400754, {"type": "fake_return", "confirmed": True, "outside": False}),
|
|
101
|
-
# rejected() does not return
|
|
102
|
-
(0x4007C9, 0x4006FD, {"type": "call", "stmt_idx": DEFAULT_STATEMENT, "ins_addr": 0x4007CE}),
|
|
103
|
-
(0x4007C9, 0x4007D3, {"type": "fake_return", "outside": False}),
|
|
104
|
-
]
|
|
105
|
-
for edge in edges:
|
|
106
|
-
assert edge in main_g_edges
|
|
107
|
-
|
|
108
|
-
# These tests fail for reasons of fastpath, probably
|
|
109
|
-
# assert main.bp_on_stack
|
|
110
|
-
# assert main.name == 'main'
|
|
111
|
-
# assert main.retaddr_on_stack
|
|
112
|
-
# assert 0x50 == main.sp_difference
|
|
113
|
-
|
|
114
|
-
# TODO: Check the result returned
|
|
115
|
-
# func_man.dbg_draw()
|
|
116
|
-
|
|
117
|
-
def test_call_to(self):
|
|
118
|
-
self.project.arch = ArchAMD64()
|
|
119
|
-
|
|
120
|
-
self.project.kb.functions._add_call_to(0x400000, 0x400410, 0x400420, 0x400414)
|
|
121
|
-
assert 0x400000 in self.project.kb.functions.keys()
|
|
122
|
-
assert 0x400420 in self.project.kb.functions.keys()
|
|
123
|
-
|
|
124
|
-
def test_query(self):
|
|
125
|
-
bin_path = os.path.join(test_location, "x86_64", "fauxware")
|
|
126
|
-
proj = angr.Project(bin_path, auto_load_libs=False)
|
|
127
|
-
proj.analyses.CFGFast(normalize=True, data_references=True)
|
|
128
|
-
|
|
129
|
-
assert proj.kb.functions["::read"].addr == 0x400530
|
|
130
|
-
assert proj.kb.functions["::0x400530::read"].addr == 0x400530
|
|
131
|
-
assert proj.kb.functions["::libc.so.0::read"].addr == 0x700010
|
|
132
|
-
with self.assertRaises(KeyError):
|
|
133
|
-
proj.kb.functions["::0x400531::read"] # pylint:disable=pointless-statement
|
|
134
|
-
with self.assertRaises(KeyError):
|
|
135
|
-
proj.kb.functions["::bad::read"] # pylint:disable=pointless-statement
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if __name__ == "__main__":
|
|
139
|
-
unittest.main()
|