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
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import logging
|
|
5
|
-
import unittest
|
|
6
|
-
import os
|
|
7
|
-
from itertools import count
|
|
8
|
-
|
|
9
|
-
import archinfo
|
|
10
|
-
import ailment
|
|
11
|
-
|
|
12
|
-
import angr
|
|
13
|
-
|
|
14
|
-
from ..common import bin_location
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
test_location = os.path.join(bin_location, "tests")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def block_simplify(block):
|
|
21
|
-
p = angr.Project(
|
|
22
|
-
os.path.join(test_location, "x86_64", "fauxware"),
|
|
23
|
-
auto_load_libs=False,
|
|
24
|
-
)
|
|
25
|
-
bsimp = p.analyses.AILBlockSimplifier(block, 0x1337)
|
|
26
|
-
return bsimp.result_block
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# pylint: disable=missing-class-docstring
|
|
30
|
-
# pylint: disable=no-self-use
|
|
31
|
-
class TestBlockSimplifier(unittest.TestCase):
|
|
32
|
-
def test_simplify_pointless_assign(self):
|
|
33
|
-
arch = archinfo.arch_from_id("AMD64")
|
|
34
|
-
block = ailment.Block(0x1337, 10)
|
|
35
|
-
block.statements.append(
|
|
36
|
-
ailment.Assignment(
|
|
37
|
-
0,
|
|
38
|
-
ailment.Register(1, None, arch.registers["rax"][0], 64),
|
|
39
|
-
ailment.Register(2, None, arch.registers["rax"][0], 64),
|
|
40
|
-
ins_addr=0x1337,
|
|
41
|
-
)
|
|
42
|
-
)
|
|
43
|
-
block.statements.append(
|
|
44
|
-
ailment.Assignment(
|
|
45
|
-
3,
|
|
46
|
-
ailment.Register(4, None, arch.registers["rbx"][0], 64),
|
|
47
|
-
ailment.Register(5, None, arch.registers["rcx"][0], 64),
|
|
48
|
-
ins_addr=0x1338,
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
b = block_simplify(block)
|
|
53
|
-
assert len(b.statements) == 1
|
|
54
|
-
assert b.statements[0].idx == 3
|
|
55
|
-
|
|
56
|
-
def test_simplify_dead_assign_0(self):
|
|
57
|
-
block = ailment.Block(0x1337, 10)
|
|
58
|
-
n = count()
|
|
59
|
-
important = 0x999
|
|
60
|
-
block.statements.extend(
|
|
61
|
-
[
|
|
62
|
-
ailment.Assignment(
|
|
63
|
-
next(n),
|
|
64
|
-
ailment.Register(next(n), None, 1, 64),
|
|
65
|
-
ailment.Const(next(n), None, 100, 64),
|
|
66
|
-
ins_addr=0x1337,
|
|
67
|
-
),
|
|
68
|
-
ailment.Assignment(
|
|
69
|
-
important,
|
|
70
|
-
ailment.Register(next(n), None, 1, 64),
|
|
71
|
-
ailment.Const(next(n), None, 101, 64),
|
|
72
|
-
ins_addr=0x1338,
|
|
73
|
-
),
|
|
74
|
-
ailment.Stmt.Jump(next(n), ailment.Expr.Const(None, None, 0x3333, 64), ins_addr=0x1338),
|
|
75
|
-
]
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
b = block_simplify(block)
|
|
79
|
-
assert len(b.statements) == 2
|
|
80
|
-
assert b.statements[0].idx == important
|
|
81
|
-
|
|
82
|
-
def test_simplify_dead_assign_1(self):
|
|
83
|
-
# if a register is used ever, it should not be simplified away
|
|
84
|
-
arch = archinfo.arch_from_id("AMD64")
|
|
85
|
-
block = ailment.Block(0x1337, 10)
|
|
86
|
-
n = count(start=1)
|
|
87
|
-
important = 0x999
|
|
88
|
-
block.statements.extend(
|
|
89
|
-
[
|
|
90
|
-
ailment.Assignment(
|
|
91
|
-
next(n),
|
|
92
|
-
ailment.Register(next(n), None, arch.registers["rdi"][0], 64),
|
|
93
|
-
ailment.Const(next(n), None, 0x13371337, 64),
|
|
94
|
-
ins_addr=0x1337,
|
|
95
|
-
), # rdi = 0x13371337
|
|
96
|
-
ailment.Stmt.Call(
|
|
97
|
-
important,
|
|
98
|
-
ailment.Const(next(n), None, 0x400080, 64),
|
|
99
|
-
ins_addr=0x1338,
|
|
100
|
-
), # Call(0x400080), which uses rdi but also overwrites rdi (since it is a caller-saved argument)
|
|
101
|
-
]
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
b = block_simplify(block)
|
|
105
|
-
assert len(b.statements) == 2
|
|
106
|
-
assert b.statements[0].idx == 1
|
|
107
|
-
assert b.statements[1].idx == important
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if __name__ == "__main__":
|
|
111
|
-
logging.getLogger("angr.analyses.decompiler.block_simplifier").setLevel(logging.DEBUG)
|
|
112
|
-
unittest.main()
|
tests/analyses/test_boyscout.py
DELETED
|
@@ -1,104 +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 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
|
-
l = logging.getLogger("angr.test_boyscout")
|
|
16
|
-
|
|
17
|
-
entries = [
|
|
18
|
-
("i386/all", "X86", "Iend_LE"),
|
|
19
|
-
("i386/fauxware", "X86", "Iend_LE"),
|
|
20
|
-
("x86_64/all", "AMD64", "Iend_LE"),
|
|
21
|
-
("x86_64/basic_buffer_overflows", "AMD64", "Iend_LE"),
|
|
22
|
-
("x86_64/cfg_0", "AMD64", "Iend_LE"),
|
|
23
|
-
("x86_64/cfg_1", "AMD64", "Iend_LE"),
|
|
24
|
-
("armel/fauxware", "ARM", "Iend_LE"),
|
|
25
|
-
("armel/test_division", "ARM", "Iend_LE"),
|
|
26
|
-
("armhf/fauxware", "ARM", "Iend_LE"),
|
|
27
|
-
("mips/allcmps", "MIPS32", "Iend_BE"),
|
|
28
|
-
("mips/manysum", "MIPS32", "Iend_BE"),
|
|
29
|
-
("mipsel/busybox", "MIPS32", "Iend_LE"),
|
|
30
|
-
("mipsel/fauxware", "MIPS32", "Iend_LE"),
|
|
31
|
-
# TODO: PPC tests are commented out for now. They will be uncommented when Amat's branch is
|
|
32
|
-
# TODO: merged back in
|
|
33
|
-
# ("ppc/fauxware", "PPC", "Iend_BE"),
|
|
34
|
-
# ("ppc64/fauxware", "PPC64", "Iend_BE"),
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class TestBoyScout(unittest.TestCase):
|
|
39
|
-
def test_i386_all(self):
|
|
40
|
-
self._main("i386/all", "X86", "Iend_LE")
|
|
41
|
-
|
|
42
|
-
def test_i386_fauxware(self):
|
|
43
|
-
self._main("i386/fauxware", "X86", "Iend_LE")
|
|
44
|
-
|
|
45
|
-
def test_x86_64_all(self):
|
|
46
|
-
self._main("x86_64/all", "AMD64", "Iend_LE")
|
|
47
|
-
|
|
48
|
-
def test_x86_64_basic_buffer_overflows(self):
|
|
49
|
-
self._main("x86_64/basic_buffer_overflows", "AMD64", "Iend_LE")
|
|
50
|
-
|
|
51
|
-
def test_x86_64_cfg_0(self):
|
|
52
|
-
self._main("x86_64/cfg_0", "AMD64", "Iend_LE")
|
|
53
|
-
|
|
54
|
-
def test_x86_64_cfg_1(self):
|
|
55
|
-
self._main("x86_64/cfg_1", "AMD64", "Iend_LE")
|
|
56
|
-
|
|
57
|
-
def test_armel_fauxware(self):
|
|
58
|
-
self._main("armel/fauxware", "ARM", "Iend_LE")
|
|
59
|
-
|
|
60
|
-
def test_armel_test_division(self):
|
|
61
|
-
self._main("armel/test_division", "ARM", "Iend_LE")
|
|
62
|
-
|
|
63
|
-
def test_armhf_fauxware(self):
|
|
64
|
-
self._main("armhf/fauxware", "ARM", "Iend_LE")
|
|
65
|
-
|
|
66
|
-
def test_mips_allcmps(self):
|
|
67
|
-
self._main("mips/allcmps", "MIPS32", "Iend_BE")
|
|
68
|
-
|
|
69
|
-
def test_mips_manysum(self):
|
|
70
|
-
self._main("mips/manysum", "MIPS32", "Iend_BE")
|
|
71
|
-
|
|
72
|
-
def test_mipsel_busybox(self):
|
|
73
|
-
self._main("mipsel/busybox", "MIPS32", "Iend_LE")
|
|
74
|
-
|
|
75
|
-
def test_mipsel_fauxware(self):
|
|
76
|
-
self._main("mipsel/fauxware", "MIPS32", "Iend_LE")
|
|
77
|
-
|
|
78
|
-
def _main(self, file_path, arch, endianness):
|
|
79
|
-
f = os.path.join(test_location, file_path)
|
|
80
|
-
l.debug("Processing %s", f)
|
|
81
|
-
|
|
82
|
-
p = angr.Project(
|
|
83
|
-
f,
|
|
84
|
-
load_options={
|
|
85
|
-
"main_opts": {
|
|
86
|
-
"backend": "blob",
|
|
87
|
-
"base_addr": 0x10000,
|
|
88
|
-
"entry_point": 0x10000,
|
|
89
|
-
"arch": "ARM",
|
|
90
|
-
"offset": 0,
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
auto_load_libs=False,
|
|
94
|
-
)
|
|
95
|
-
# Call Scout
|
|
96
|
-
# p.analyses.Scout(start=0x16353c)
|
|
97
|
-
bs = p.analyses.BoyScout()
|
|
98
|
-
|
|
99
|
-
assert arch in bs.arch
|
|
100
|
-
assert bs.endianness == endianness
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if __name__ == "__main__":
|
|
104
|
-
unittest.main()
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import logging
|
|
5
|
-
import os
|
|
6
|
-
import unittest
|
|
7
|
-
|
|
8
|
-
import archinfo
|
|
9
|
-
|
|
10
|
-
import angr
|
|
11
|
-
from angr.calling_conventions import (
|
|
12
|
-
SimStackArg,
|
|
13
|
-
SimRegArg,
|
|
14
|
-
SimCCCdecl,
|
|
15
|
-
SimCCSystemVAMD64,
|
|
16
|
-
)
|
|
17
|
-
from angr.sim_type import SimTypeFunction, SimTypeInt, SimTypeLongLong, SimTypeBottom
|
|
18
|
-
|
|
19
|
-
from ..common import bin_location, requires_binaries_private
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
test_location = os.path.join(bin_location, "tests")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# pylint: disable=missing-class-docstring
|
|
26
|
-
# pylint: disable=no-self-use
|
|
27
|
-
class TestCallingConventionAnalysis(unittest.TestCase):
|
|
28
|
-
def _run_fauxware(self, arch, function_and_cc_list):
|
|
29
|
-
binary_path = os.path.join(test_location, arch, "fauxware")
|
|
30
|
-
fauxware = angr.Project(binary_path, auto_load_libs=False)
|
|
31
|
-
|
|
32
|
-
cfg = fauxware.analyses.CFG()
|
|
33
|
-
|
|
34
|
-
for func_name, expected_cc in function_and_cc_list:
|
|
35
|
-
authenticate = cfg.functions[func_name]
|
|
36
|
-
_ = fauxware.analyses.VariableRecoveryFast(authenticate)
|
|
37
|
-
|
|
38
|
-
cc_analysis = fauxware.analyses.CallingConvention(authenticate, cfg=cfg, analyze_callsites=True)
|
|
39
|
-
cc = cc_analysis.cc
|
|
40
|
-
|
|
41
|
-
assert cc == expected_cc
|
|
42
|
-
|
|
43
|
-
def _run_cgc(self, binary_name):
|
|
44
|
-
pass
|
|
45
|
-
# binary_path = os.path.join(bin_location, '..', 'binaries-private', 'cgc_qualifier_event', 'cgc', binary_name)
|
|
46
|
-
# project = angr.Project(binary_path, auto_load_libs=False)
|
|
47
|
-
#
|
|
48
|
-
# categorization = project.analyses.FunctionCategorizationAnalysis()
|
|
49
|
-
|
|
50
|
-
# tag_manager = categorization.function_tag_manager
|
|
51
|
-
# print "INPUT:", map(hex, tag_manager.input_functions())
|
|
52
|
-
# print "OUTPUT:", map(hex, tag_manager.output_functions())
|
|
53
|
-
|
|
54
|
-
def test_fauxware_i386(self):
|
|
55
|
-
self._run_fauxware("i386", [("authenticate", SimCCCdecl(archinfo.arch_from_id("i386")))])
|
|
56
|
-
|
|
57
|
-
def test_fauxware_x86_64(self):
|
|
58
|
-
amd64 = archinfo.arch_from_id("amd64")
|
|
59
|
-
self._run_fauxware(
|
|
60
|
-
"x86_64",
|
|
61
|
-
[
|
|
62
|
-
(
|
|
63
|
-
"authenticate",
|
|
64
|
-
SimCCSystemVAMD64(
|
|
65
|
-
amd64,
|
|
66
|
-
),
|
|
67
|
-
),
|
|
68
|
-
],
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
@requires_binaries_private
|
|
72
|
-
def test_cgc_binary1(self):
|
|
73
|
-
self._run_cgc("002ba801_01")
|
|
74
|
-
|
|
75
|
-
@requires_binaries_private
|
|
76
|
-
def test_cgc_binary2(self):
|
|
77
|
-
self._run_cgc("01cf6c01_01")
|
|
78
|
-
|
|
79
|
-
#
|
|
80
|
-
# Full-binary calling convention analysis
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
def check_arg(self, arg, expected_str):
|
|
84
|
-
if isinstance(arg, SimRegArg):
|
|
85
|
-
arg_str = "r_%s" % (arg.reg_name)
|
|
86
|
-
else:
|
|
87
|
-
raise TypeError("Unsupported argument type %s." % type(arg))
|
|
88
|
-
return arg_str == expected_str
|
|
89
|
-
|
|
90
|
-
def check_args(self, func_name, args, expected_arg_strs):
|
|
91
|
-
assert len(args) == len(expected_arg_strs), "Wrong number of arguments for function %s. Got %d, expect %d." % (
|
|
92
|
-
func_name,
|
|
93
|
-
len(args),
|
|
94
|
-
len(expected_arg_strs),
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
for idx, (arg, expected_arg_str) in enumerate(zip(args, expected_arg_strs)):
|
|
98
|
-
r = self.check_arg(arg, expected_arg_str)
|
|
99
|
-
assert r, "Incorrect argument %d for function %s. Got %s, expect %s." % (
|
|
100
|
-
idx,
|
|
101
|
-
func_name,
|
|
102
|
-
arg,
|
|
103
|
-
expected_arg_str,
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
def _a(self, funcs, func_name):
|
|
107
|
-
func = funcs[func_name]
|
|
108
|
-
return func.calling_convention.arg_locs(func.prototype)
|
|
109
|
-
|
|
110
|
-
def test_x8664_dir_gcc_O0(self):
|
|
111
|
-
binary_path = os.path.join(test_location, "x86_64", "dir_gcc_-O0")
|
|
112
|
-
proj = angr.Project(binary_path, auto_load_libs=False, load_debug_info=False)
|
|
113
|
-
|
|
114
|
-
cfg = proj.analyses.CFG() # fill in the default kb
|
|
115
|
-
|
|
116
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
117
|
-
|
|
118
|
-
funcs = cfg.kb.functions
|
|
119
|
-
|
|
120
|
-
# check args
|
|
121
|
-
expected_args = {
|
|
122
|
-
"c_ispunct": ["r_rdi"],
|
|
123
|
-
"file_failure": ["r_rdi", "r_rsi", "r_rdx"],
|
|
124
|
-
"to_uchar": ["r_rdi"],
|
|
125
|
-
"dot_or_dotdot": ["r_rdi"],
|
|
126
|
-
"emit_mandatory_arg_note": [],
|
|
127
|
-
"emit_size_note": [],
|
|
128
|
-
"emit_ancillary_info": ["r_rdi"],
|
|
129
|
-
"emit_try_help": [],
|
|
130
|
-
"dev_ino_push": ["r_rdi", "r_rsi"],
|
|
131
|
-
"main": ["r_rdi", "r_rsi"],
|
|
132
|
-
"queue_directory": ["r_rdi", "r_rsi", "r_rdx"],
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for func_name, args in expected_args.items():
|
|
136
|
-
self.check_args(func_name, self._a(funcs, func_name), args)
|
|
137
|
-
|
|
138
|
-
def test_armel_fauxware(self):
|
|
139
|
-
binary_path = os.path.join(test_location, "armel", "fauxware")
|
|
140
|
-
proj = angr.Project(binary_path, auto_load_libs=False, load_debug_info=False)
|
|
141
|
-
|
|
142
|
-
cfg = proj.analyses.CFG() # fill in the default kb
|
|
143
|
-
|
|
144
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
145
|
-
|
|
146
|
-
funcs = cfg.kb.functions
|
|
147
|
-
|
|
148
|
-
# check args
|
|
149
|
-
expected_args = {
|
|
150
|
-
"main": ["r_r0", "r_r1"],
|
|
151
|
-
"accepted": ["r_r0", "r_r1", "r_r2", "r_r3"],
|
|
152
|
-
"rejected": [],
|
|
153
|
-
"authenticate": ["r_r0", "r_r1", "r_r2"], # TECHNICALLY WRONG but what are you gonna do about it
|
|
154
|
-
# details: open(3) can take either 2 or 3 args. we use the 2 arg version but we have the 3 arg version
|
|
155
|
-
# hardcoded in angr. the third arg is still "live" from the function start.
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
for func_name, args in expected_args.items():
|
|
159
|
-
self.check_args(func_name, self._a(funcs, func_name), args)
|
|
160
|
-
|
|
161
|
-
def test_x8664_void(self):
|
|
162
|
-
binary_path = os.path.join(test_location, "x86_64", "types", "void")
|
|
163
|
-
proj = angr.Project(binary_path, auto_load_libs=False, load_debug_info=False)
|
|
164
|
-
|
|
165
|
-
cfg = proj.analyses.CFG()
|
|
166
|
-
|
|
167
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True, cfg=cfg.model, analyze_callsites=True)
|
|
168
|
-
|
|
169
|
-
funcs = cfg.kb.functions
|
|
170
|
-
|
|
171
|
-
groundtruth = {
|
|
172
|
-
"func_1": None,
|
|
173
|
-
"func_2": None,
|
|
174
|
-
"func_3": "rax",
|
|
175
|
-
"func_4": None,
|
|
176
|
-
"func_5": None,
|
|
177
|
-
"func_6": "rax",
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
for func in funcs.values():
|
|
181
|
-
if func.is_simprocedure or func.alignment:
|
|
182
|
-
continue
|
|
183
|
-
if func.calling_convention is None:
|
|
184
|
-
continue
|
|
185
|
-
if func.name in groundtruth:
|
|
186
|
-
r = groundtruth[func.name]
|
|
187
|
-
if r is None:
|
|
188
|
-
assert isinstance(func.prototype.returnty, SimTypeBottom)
|
|
189
|
-
else:
|
|
190
|
-
ret_val = func.calling_convention.return_val(func.prototype.returnty)
|
|
191
|
-
assert isinstance(ret_val, SimRegArg)
|
|
192
|
-
assert ret_val.reg_name == r
|
|
193
|
-
|
|
194
|
-
def test_x86_saved_regs(self):
|
|
195
|
-
# Calling convention analysis should be able to determine calling convention of functions with registers
|
|
196
|
-
# saved on the stack.
|
|
197
|
-
binary_path = os.path.join(test_location, "cgc", "NRFIN_00036")
|
|
198
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
199
|
-
|
|
200
|
-
cfg = proj.analyses.CFG()
|
|
201
|
-
func = cfg.functions[0x80494F0] # int2str
|
|
202
|
-
|
|
203
|
-
proj.analyses.VariableRecoveryFast(func)
|
|
204
|
-
cca = proj.analyses.CallingConvention(func)
|
|
205
|
-
cc = cca.cc
|
|
206
|
-
prototype = cca.prototype
|
|
207
|
-
|
|
208
|
-
assert cc is not None, (
|
|
209
|
-
"Calling convention analysis failed to determine the calling convention of function " "0x80494f0."
|
|
210
|
-
)
|
|
211
|
-
assert isinstance(cc, SimCCCdecl)
|
|
212
|
-
assert len(prototype.args) == 3
|
|
213
|
-
arg_locs = cc.arg_locs(prototype)
|
|
214
|
-
assert arg_locs[0] == SimStackArg(4, 4)
|
|
215
|
-
assert arg_locs[1] == SimStackArg(8, 4)
|
|
216
|
-
assert arg_locs[2] == SimStackArg(12, 4)
|
|
217
|
-
|
|
218
|
-
func_exit = cfg.functions[0x804A1A9] # exit
|
|
219
|
-
|
|
220
|
-
proj.analyses.VariableRecoveryFast(func_exit)
|
|
221
|
-
cca = proj.analyses.CallingConvention(func_exit)
|
|
222
|
-
cc = cca.cc
|
|
223
|
-
prototype = cca.prototype
|
|
224
|
-
|
|
225
|
-
assert func_exit.returning is False
|
|
226
|
-
assert cc is not None, (
|
|
227
|
-
"Calling convention analysis failed to determine the calling convention of function " "0x804a1a9."
|
|
228
|
-
)
|
|
229
|
-
assert isinstance(cc, SimCCCdecl)
|
|
230
|
-
assert len(prototype.args) == 1
|
|
231
|
-
assert cc.arg_locs(prototype)[0] == SimStackArg(4, 4)
|
|
232
|
-
|
|
233
|
-
def test_callsite_inference_amd64(self):
|
|
234
|
-
# Calling convention analysis should be able to determine calling convention of a library function by
|
|
235
|
-
# analyzing its callsites.
|
|
236
|
-
binary_path = os.path.join(test_location, "x86_64", "decompiler", "morton")
|
|
237
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
238
|
-
cfg = proj.analyses.CFG(data_references=True, normalize=True)
|
|
239
|
-
|
|
240
|
-
func = cfg.functions.function(name="mosquitto_publish", plt=True)
|
|
241
|
-
proj.analyses.VariableRecoveryFast(func)
|
|
242
|
-
cca = proj.analyses.CallingConvention(func, analyze_callsites=True)
|
|
243
|
-
assert len(cca.prototype.args) == 6
|
|
244
|
-
|
|
245
|
-
def test_x64_return_value_used(self):
|
|
246
|
-
binary_path = os.path.join(test_location, "x86_64", "cwebp-0.3.1-feh-original")
|
|
247
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
248
|
-
cfg = proj.analyses.CFGFast(normalize=True, data_references=True, force_complete_scan=False)
|
|
249
|
-
func = proj.kb.functions.get_by_addr(0x4046E0)
|
|
250
|
-
proj.analyses.VariableRecoveryFast(func)
|
|
251
|
-
cca = proj.analyses.CallingConvention(func=func, cfg=cfg, analyze_callsites=True)
|
|
252
|
-
|
|
253
|
-
assert cca.prototype is not None
|
|
254
|
-
assert cca.prototype.returnty is not None
|
|
255
|
-
|
|
256
|
-
def test_armhf_thumb_movcc(self):
|
|
257
|
-
binary_path = os.path.join(test_location, "armhf", "amp_challenge_07.gcc")
|
|
258
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
259
|
-
_ = proj.analyses.CFGFast(normalize=True, data_references=True, regions=[(0xFEC94, 0xFEF60)])
|
|
260
|
-
f = proj.kb.functions[0xFEC95]
|
|
261
|
-
proj.analyses.VariableRecoveryFast(f)
|
|
262
|
-
cca = proj.analyses.CallingConvention(f)
|
|
263
|
-
|
|
264
|
-
assert cca.prototype is not None
|
|
265
|
-
assert cca.cc is not None
|
|
266
|
-
assert isinstance(cca.prototype, SimTypeFunction)
|
|
267
|
-
assert len(cca.prototype.args) == 2
|
|
268
|
-
|
|
269
|
-
def manual_test_workers(self):
|
|
270
|
-
binary_path = os.path.join(test_location, "x86_64", "1after909")
|
|
271
|
-
proj = angr.Project(binary_path, auto_load_libs=False, load_debug_info=False)
|
|
272
|
-
|
|
273
|
-
cfg = proj.analyses.CFG(normalize=True) # fill in the default kb
|
|
274
|
-
|
|
275
|
-
_ = proj.analyses.CompleteCallingConventions(
|
|
276
|
-
cfg=cfg.model, recover_variables=True, workers=4, show_progressbar=True
|
|
277
|
-
)
|
|
278
|
-
|
|
279
|
-
for func in cfg.functions.values():
|
|
280
|
-
assert func.is_prototype_guessed is True
|
|
281
|
-
|
|
282
|
-
def test_tail_calls(self):
|
|
283
|
-
for opt_level in (1, 2):
|
|
284
|
-
binary_path = os.path.join(test_location, "x86_64", "tailcall-O%d" % opt_level)
|
|
285
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
286
|
-
|
|
287
|
-
proj.analyses.CFG(normalize=True)
|
|
288
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
289
|
-
|
|
290
|
-
for func in ["target", "direct", "plt"]:
|
|
291
|
-
# expected prototype: (int) -> long long
|
|
292
|
-
# technically should be (int) -> int, but the compiler loads all 64 bits and then truncates
|
|
293
|
-
proto = proj.kb.functions[func].prototype
|
|
294
|
-
assert len(proto.args) == 1
|
|
295
|
-
assert isinstance(proto.args[0], SimTypeInt)
|
|
296
|
-
assert isinstance(proto.returnty, SimTypeLongLong)
|
|
297
|
-
|
|
298
|
-
def test_ls_gcc_O0_timespec_cmp(self):
|
|
299
|
-
binary_path = os.path.join(test_location, "x86_64", "decompiler", "ls_gcc_O0")
|
|
300
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
301
|
-
|
|
302
|
-
proj.analyses.CFG(normalize=True)
|
|
303
|
-
proj.analyses.VariableRecoveryFast(proj.kb.functions["timespec_cmp"])
|
|
304
|
-
cca = proj.analyses.CallingConvention(proj.kb.functions["timespec_cmp"])
|
|
305
|
-
|
|
306
|
-
assert len(cca.prototype.args) == 4
|
|
307
|
-
|
|
308
|
-
def test_run_multiple_times(self):
|
|
309
|
-
binary_path = os.path.join(test_location, "x86_64", "fauxware")
|
|
310
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
311
|
-
|
|
312
|
-
proj.analyses.CFG(normalize=True)
|
|
313
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
314
|
-
|
|
315
|
-
expected_prototype = proj.kb.functions["main"].prototype
|
|
316
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
317
|
-
assert proj.kb.functions["main"].prototype == expected_prototype
|
|
318
|
-
|
|
319
|
-
proj.analyses.CFG(normalize=True)
|
|
320
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
321
|
-
assert proj.kb.functions["main"].prototype == expected_prototype
|
|
322
|
-
|
|
323
|
-
def test_test_three_arguments(self):
|
|
324
|
-
binary_path = os.path.join(test_location, "x86_64", "test.o")
|
|
325
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
326
|
-
|
|
327
|
-
cfg = proj.analyses.CFG(normalize=True)
|
|
328
|
-
# the node 0x401226 must be in its own function
|
|
329
|
-
assert cfg.model.get_any_node(0x401226).function_address == 0x401226
|
|
330
|
-
|
|
331
|
-
proj.analyses.CompleteCallingConventions(recover_variables=True)
|
|
332
|
-
|
|
333
|
-
assert proj.kb.functions["test_syntax_error"].prototype.variadic is True
|
|
334
|
-
assert len(proj.kb.functions["expr"].prototype.args) == 0
|
|
335
|
-
|
|
336
|
-
def test_windows_partial_input_variable_overwrite(self):
|
|
337
|
-
binary_path = os.path.join(test_location, "x86_64", "netfilter_b64.sys")
|
|
338
|
-
proj = angr.Project(binary_path, auto_load_libs=False)
|
|
339
|
-
|
|
340
|
-
cfg = proj.analyses.CFG(normalize=True)
|
|
341
|
-
proj.analyses.VariableRecoveryFast(proj.kb.functions[0x140001A90])
|
|
342
|
-
cc = proj.analyses.CallingConvention(cfg.kb.functions[0x140001A90])
|
|
343
|
-
assert cc.cc is not None
|
|
344
|
-
assert cc.prototype is not None
|
|
345
|
-
print(cc.prototype.args)
|
|
346
|
-
assert len(cc.prototype.args) == 3
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if __name__ == "__main__":
|
|
350
|
-
# logging.getLogger("angr.analyses.variable_recovery.variable_recovery_fast").setLevel(logging.DEBUG)
|
|
351
|
-
logging.getLogger("angr.analyses.calling_convention").setLevel(logging.INFO)
|
|
352
|
-
unittest.main()
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import unittest
|
|
6
|
-
|
|
7
|
-
import ailment
|
|
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
|
-
# pylint: disable=missing-class-docstring
|
|
18
|
-
# pylint: disable=no-self-use
|
|
19
|
-
class TestCallsiteMaker(unittest.TestCase):
|
|
20
|
-
def test_callsite_maker(self):
|
|
21
|
-
project = angr.Project(
|
|
22
|
-
os.path.join(test_location, "x86_64", "all"),
|
|
23
|
-
auto_load_libs=False,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
manager = ailment.Manager(arch=project.arch)
|
|
27
|
-
|
|
28
|
-
# Generate a CFG
|
|
29
|
-
cfg = project.analyses.CFG()
|
|
30
|
-
|
|
31
|
-
new_cc_found = True
|
|
32
|
-
while new_cc_found:
|
|
33
|
-
new_cc_found = False
|
|
34
|
-
for func in cfg.kb.functions.values():
|
|
35
|
-
if func.calling_convention is None:
|
|
36
|
-
# determine the calling convention of each function
|
|
37
|
-
project.analyses.VariableRecoveryFast(func)
|
|
38
|
-
cc_analysis = project.analyses.CallingConvention(func)
|
|
39
|
-
if cc_analysis.cc is not None:
|
|
40
|
-
func.calling_convention = cc_analysis.cc
|
|
41
|
-
func.prototype = cc_analysis.prototype
|
|
42
|
-
new_cc_found = True
|
|
43
|
-
|
|
44
|
-
main_func = cfg.kb.functions["main"]
|
|
45
|
-
|
|
46
|
-
for block in sorted(main_func.blocks, key=lambda x: x.addr):
|
|
47
|
-
print(block.vex.pp())
|
|
48
|
-
ail_block = ailment.IRSBConverter.convert(block.vex, manager)
|
|
49
|
-
simp = project.analyses.AILBlockSimplifier(ail_block, main_func.addr)
|
|
50
|
-
|
|
51
|
-
csm = project.analyses.AILCallSiteMaker(simp.result_block)
|
|
52
|
-
if csm.result_block:
|
|
53
|
-
ail_block = csm.result_block
|
|
54
|
-
simp = project.analyses.AILBlockSimplifier(ail_block, main_func.addr)
|
|
55
|
-
|
|
56
|
-
print(simp.result_block)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if __name__ == "__main__":
|
|
60
|
-
unittest.main()
|