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/analyses/test_slicing.py
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,no-self-use,line-too-long
|
|
3
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import logging
|
|
6
|
-
import os
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
import time
|
|
10
|
-
import angr
|
|
11
|
-
from angr.utils.constants import DEFAULT_STATEMENT
|
|
12
|
-
|
|
13
|
-
from ..common import bin_location, broken
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
log = logging.getLogger(__name__)
|
|
17
|
-
test_location = os.path.join(bin_location, "tests")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class TestSlicing(unittest.TestCase):
|
|
21
|
-
def test_find_exits(self):
|
|
22
|
-
slicing_test = angr.Project(
|
|
23
|
-
os.path.join(test_location, "x86_64", "cfg_1"),
|
|
24
|
-
use_sim_procedures=True,
|
|
25
|
-
default_analysis_mode="symbolic",
|
|
26
|
-
auto_load_libs=False,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
log.info("Unit test for BackwardSlice._find_exits()")
|
|
30
|
-
cfg = slicing_test.analyses.CFGEmulated(context_sensitivity_level=2, keep_state=True)
|
|
31
|
-
cdg = slicing_test.analyses.CDG(cfg)
|
|
32
|
-
ddg = slicing_test.analyses.DDG(cfg)
|
|
33
|
-
|
|
34
|
-
source = cfg.get_any_node(0x40059E)
|
|
35
|
-
|
|
36
|
-
# Test the conditional exit
|
|
37
|
-
target = cfg.get_any_node(0x400594)
|
|
38
|
-
bs_1 = slicing_test.analyses.BackwardSlice(cfg, cdg, ddg, targets=[(target, -1)], no_construct=True)
|
|
39
|
-
all_exits = bs_1._find_exits(source, target)
|
|
40
|
-
|
|
41
|
-
assert all_exits == {18: [0x400594], DEFAULT_STATEMENT: None}
|
|
42
|
-
|
|
43
|
-
# Test the default exit
|
|
44
|
-
target = cfg.get_any_node(0x4005A4)
|
|
45
|
-
bs_2 = slicing_test.analyses.BackwardSlice(cfg, cdg, ddg, targets=[(target, -1)], no_construct=True)
|
|
46
|
-
all_exits = bs_2._find_exits(source, target)
|
|
47
|
-
|
|
48
|
-
assert all_exits == {18: [0x400594], DEFAULT_STATEMENT: [0x4005A4]}
|
|
49
|
-
|
|
50
|
-
def test_control_flow_slicing(self):
|
|
51
|
-
slicing_test = angr.Project(
|
|
52
|
-
os.path.join(test_location, "x86_64", "cfg_1"),
|
|
53
|
-
use_sim_procedures=True,
|
|
54
|
-
default_analysis_mode="symbolic",
|
|
55
|
-
auto_load_libs=False,
|
|
56
|
-
)
|
|
57
|
-
log.info("Control Flow Slicing")
|
|
58
|
-
start = time.time()
|
|
59
|
-
cfg = slicing_test.analyses.CFGEmulated(context_sensitivity_level=2)
|
|
60
|
-
end = time.time()
|
|
61
|
-
duration = end - start
|
|
62
|
-
log.info("CFG generation is done in %f seconds.", duration)
|
|
63
|
-
|
|
64
|
-
target = cfg.get_any_node(0x400594)
|
|
65
|
-
bs = slicing_test.analyses.BackwardSlice(cfg, None, None, targets=[(target, -1)], control_flow_slice=True)
|
|
66
|
-
anno_cfg = bs.annotated_cfg()
|
|
67
|
-
assert anno_cfg.get_whitelisted_statements(0x40057C) is None
|
|
68
|
-
assert anno_cfg.get_whitelisted_statements(0x400594) is None
|
|
69
|
-
assert anno_cfg.get_whitelisted_statements(0x4005A4) == []
|
|
70
|
-
|
|
71
|
-
@broken
|
|
72
|
-
def test_backward_slice(self):
|
|
73
|
-
# TODO: Fix this test case
|
|
74
|
-
|
|
75
|
-
slicing_test = angr.Project(
|
|
76
|
-
os.path.join(test_location, "x86_64", "cfg_1"),
|
|
77
|
-
use_sim_procedures=True,
|
|
78
|
-
default_analysis_mode="symbolic",
|
|
79
|
-
auto_load_libs=False,
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
log.info("Control Flow Slicing")
|
|
83
|
-
|
|
84
|
-
cfg = slicing_test.analyses.CFGEmulated(
|
|
85
|
-
context_sensitivity_level=2, keep_state=True, state_add_options=angr.sim_options.refs
|
|
86
|
-
)
|
|
87
|
-
cdg = slicing_test.analyses.CDG(cfg=cfg)
|
|
88
|
-
ddg = slicing_test.analyses.DDG(cfg=cfg)
|
|
89
|
-
|
|
90
|
-
target = cfg.get_any_node(0x4005D3)
|
|
91
|
-
bs = slicing_test.analyses.BackwardSlice(cfg, cdg, ddg, targets=[(target, -1)], control_flow_slice=False)
|
|
92
|
-
anno_cfg = bs.annotated_cfg()
|
|
93
|
-
assert anno_cfg.get_whitelisted_statements(0x40057C) == [2, 3, 7, 20, 21]
|
|
94
|
-
assert anno_cfg.get_whitelisted_statements(0x400594) == [1, 17, 18, 19, 20]
|
|
95
|
-
assert anno_cfg.get_whitelisted_statements(0x4005A4) == []
|
|
96
|
-
assert anno_cfg.get_whitelisted_statements(0x4005CD) == [1, 2, 3, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
|
97
|
-
|
|
98
|
-
def test_last_branching_statement(self):
|
|
99
|
-
slicing_test = angr.Project(
|
|
100
|
-
os.path.join(test_location, "armel", "fauxware"),
|
|
101
|
-
use_sim_procedures=True,
|
|
102
|
-
auto_load_libs=False,
|
|
103
|
-
)
|
|
104
|
-
log.info("Testing _search_for_last_branching_statement.")
|
|
105
|
-
|
|
106
|
-
# The IRSB:
|
|
107
|
-
|
|
108
|
-
# ------ IMark(0x86dc, 4, 0) ------
|
|
109
|
-
# t1 = GET:I32(r0)
|
|
110
|
-
# PUT(pc) = 0x000086e0
|
|
111
|
-
# ------ IMark(0x86e0, 4, 0) ------
|
|
112
|
-
# t14 = GET:I32(r11)
|
|
113
|
-
# t13 = Sub32(t14,0x00000024)
|
|
114
|
-
# STle(t13) = t1
|
|
115
|
-
# PUT(pc) = 0x000086e4
|
|
116
|
-
# ------ IMark(0x86e4, 4, 0) ------
|
|
117
|
-
# t15 = t13
|
|
118
|
-
# t8 = LDle:I32(t15)
|
|
119
|
-
# PUT(r3) = t8
|
|
120
|
-
# ------ IMark(0x86e8, 4, 0) ------
|
|
121
|
-
# PUT(cc_op) = 0x00000002
|
|
122
|
-
# PUT(cc_dep1) = t8
|
|
123
|
-
# PUT(cc_dep2) = 0x00000000
|
|
124
|
-
# PUT(cc_ndep) = 0x00000000
|
|
125
|
-
# PUT(pc) = 0x000086ec
|
|
126
|
-
# ------ IMark(0x86ec, 4, 0) ------
|
|
127
|
-
# t26 = CmpEQ32(t8,0x00000000)
|
|
128
|
-
# t25 = 1Uto32(t26)
|
|
129
|
-
# t27 = 32to1(t25)
|
|
130
|
-
# if (t27) { PUT(68) = 0x86f8; Ijk_Boring }
|
|
131
|
-
|
|
132
|
-
target_state = slicing_test.factory.blank_state(addr=0x86DC)
|
|
133
|
-
simgr = slicing_test.factory.simgr(target_state)
|
|
134
|
-
simgr.step()
|
|
135
|
-
target = simgr.active[0]
|
|
136
|
-
log.debug("IRSB:")
|
|
137
|
-
for line in target.scratch.irsb._pp_str().split("\n"):
|
|
138
|
-
log.debug(line)
|
|
139
|
-
|
|
140
|
-
bs = slicing_test.analyses.BackwardSlice(None, None, None, targets=[(target, -1)], no_construct=True)
|
|
141
|
-
|
|
142
|
-
stmt_idx, tmp = bs._last_branching_statement(target.scratch.irsb.statements)
|
|
143
|
-
|
|
144
|
-
assert stmt_idx == 22
|
|
145
|
-
assert tmp == 27
|
|
146
|
-
|
|
147
|
-
def test_fauxware(self):
|
|
148
|
-
b = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
149
|
-
cfg = b.analyses.CFGEmulated(
|
|
150
|
-
keep_state=True, state_add_options=angr.sim_options.refs, context_sensitivity_level=2
|
|
151
|
-
)
|
|
152
|
-
cdg = b.analyses.CDG(cfg)
|
|
153
|
-
ddg = b.analyses.DDG(cfg)
|
|
154
|
-
target_func = cfg.kb.functions.function(name="exit")
|
|
155
|
-
target_node = cfg.get_any_node(target_func.addr)
|
|
156
|
-
|
|
157
|
-
bs = b.analyses.BackwardSlice(cfg, cdg=cdg, ddg=ddg, targets=[(target_node, -1)])
|
|
158
|
-
|
|
159
|
-
# Make sure dbg_repr() works
|
|
160
|
-
log.debug(bs.dbg_repr())
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if __name__ == "__main__":
|
|
164
|
-
unittest.main()
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,no-self-use,line-too-long
|
|
3
|
-
__package__ = __package__ or "tests.analyses" # 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
|
-
def run_tracker(track_mem, use_bp):
|
|
18
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
19
|
-
p.analyses.CFGFast()
|
|
20
|
-
main = p.kb.functions["main"]
|
|
21
|
-
sp = p.arch.sp_offset
|
|
22
|
-
regs = {sp}
|
|
23
|
-
if use_bp:
|
|
24
|
-
bp = p.arch.bp_offset
|
|
25
|
-
regs.add(bp)
|
|
26
|
-
sptracker = p.analyses.StackPointerTracker(main, regs, track_memory=track_mem)
|
|
27
|
-
sp_result = sptracker.offset_after(0x4007D4, sp)
|
|
28
|
-
if use_bp:
|
|
29
|
-
bp_result = sptracker.offset_after(0x4007D4, bp)
|
|
30
|
-
return sp_result, bp_result
|
|
31
|
-
else:
|
|
32
|
-
return sp_result
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def init_tracker(track_mem):
|
|
36
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), auto_load_libs=False)
|
|
37
|
-
p.analyses.CFGFast()
|
|
38
|
-
main = p.kb.functions["main"]
|
|
39
|
-
sp = p.arch.sp_offset
|
|
40
|
-
regs = {sp}
|
|
41
|
-
sptracker = p.analyses.StackPointerTracker(main, regs, track_memory=track_mem)
|
|
42
|
-
return sptracker, sp
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class TestStackPointerTracker(unittest.TestCase):
|
|
46
|
-
def test_stack_pointer_tracker(self):
|
|
47
|
-
sp_result, bp_result = run_tracker(track_mem=True, use_bp=True)
|
|
48
|
-
assert sp_result == 8
|
|
49
|
-
assert bp_result == 0
|
|
50
|
-
|
|
51
|
-
def test_stack_pointer_tracker_no_mem(self):
|
|
52
|
-
sp_result, bp_result = run_tracker(track_mem=False, use_bp=True)
|
|
53
|
-
assert sp_result == 8
|
|
54
|
-
assert bp_result is None
|
|
55
|
-
|
|
56
|
-
def test_stack_pointer_tracker_just_sp(self):
|
|
57
|
-
sp_result = run_tracker(track_mem=False, use_bp=False)
|
|
58
|
-
assert sp_result is None
|
|
59
|
-
|
|
60
|
-
def test_stack_pointer_tracker_offset_block(self):
|
|
61
|
-
sptracker, sp = init_tracker(track_mem=False)
|
|
62
|
-
sp_result = sptracker.offset_after_block(0x40071D, sp)
|
|
63
|
-
assert sp_result is not None
|
|
64
|
-
sp_result = sptracker.offset_after_block(0x400700, sp)
|
|
65
|
-
assert sp_result is None
|
|
66
|
-
sp_result = sptracker.offset_before_block(0x40071D, sp)
|
|
67
|
-
assert sp_result is not None
|
|
68
|
-
sp_result = sptracker.offset_before_block(0x400700, sp)
|
|
69
|
-
assert sp_result is None
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if __name__ == "__main__":
|
|
73
|
-
logging.getLogger("angr.analyses.stack_pointer_tracker").setLevel(logging.INFO)
|
|
74
|
-
unittest.main()
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,no-self-use,line-too-long
|
|
3
|
-
__package__ = __package__ or "tests.analyses" # 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 TestStaticHooker(unittest.TestCase):
|
|
17
|
-
def test_static_hooker(self):
|
|
18
|
-
test_file = os.path.join(test_location, "x86_64", "static")
|
|
19
|
-
p = angr.Project(test_file, auto_load_libs=False)
|
|
20
|
-
sh = p.analyses.StaticHooker("libc.so.6")
|
|
21
|
-
|
|
22
|
-
assert 4197616 in sh.results
|
|
23
|
-
assert type(sh.results[4197616]) is angr.SIM_PROCEDURES["glibc"]["__libc_start_main"]
|
|
24
|
-
assert type(p.hooked_by(4197616)) is angr.SIM_PROCEDURES["glibc"]["__libc_start_main"]
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if __name__ == "__main__":
|
|
28
|
-
unittest.main()
|
tests/analyses/test_typehoon.py
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint:disable=missing-class-docstring,no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.analyses" # 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 TestTypehoon(unittest.TestCase):
|
|
17
|
-
def test_smoketest(self):
|
|
18
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "linked_list"), auto_load_libs=False)
|
|
19
|
-
cfg = p.analyses.CFG(data_references=True, normalize=True)
|
|
20
|
-
|
|
21
|
-
main_func = cfg.kb.functions["sum"]
|
|
22
|
-
|
|
23
|
-
vr = p.analyses.VariableRecoveryFast(main_func)
|
|
24
|
-
p.analyses.CompleteCallingConventions()
|
|
25
|
-
|
|
26
|
-
# import pprint
|
|
27
|
-
tcons = vr.type_constraints
|
|
28
|
-
# pprint.pprint(vr._outstates[0x4005b2].typevars._typevars)
|
|
29
|
-
# pprint.pprint(tcons)
|
|
30
|
-
|
|
31
|
-
_ = p.analyses.Typehoon(tcons)
|
|
32
|
-
# pprint.pprint(t.simtypes_solution)
|
|
33
|
-
|
|
34
|
-
# convert function blocks to AIL blocks
|
|
35
|
-
# clinic = p.analyses.Clinic(main_func)
|
|
36
|
-
|
|
37
|
-
# t = p.analyses.Typehoon(main_func) #, clinic)
|
|
38
|
-
# print(t)
|
|
39
|
-
|
|
40
|
-
def test_type_inference_byte_pointer_cast(self):
|
|
41
|
-
proj = angr.Project(os.path.join(test_location, "i386", "type_inference_1"), auto_load_libs=False)
|
|
42
|
-
cfg = proj.analyses.CFG(data_references=True, normalize=True)
|
|
43
|
-
main_func = cfg.kb.functions["main"]
|
|
44
|
-
proj.analyses.VariableRecoveryFast(main_func)
|
|
45
|
-
proj.analyses.CompleteCallingConventions()
|
|
46
|
-
|
|
47
|
-
dec = proj.analyses.Decompiler(main_func)
|
|
48
|
-
assert "->field_0 = 10;" in dec.codegen.text
|
|
49
|
-
assert "->field_4 = 20;" in dec.codegen.text
|
|
50
|
-
assert "->field_8 = 808464432;" in dec.codegen.text
|
|
51
|
-
assert "->field_c = 0;" in dec.codegen.text
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if __name__ == "__main__":
|
|
55
|
-
unittest.main()
|