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_cdg.py
DELETED
|
@@ -1,165 +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 networkx
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
from angr.analyses.cdg import TemporaryNode
|
|
11
|
-
from angr.utils.graph import compute_dominance_frontier
|
|
12
|
-
|
|
13
|
-
from ..common import bin_location
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
test_location = os.path.join(bin_location, "tests")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# pylint: disable=missing-class-docstring
|
|
20
|
-
# pylint: disable=no-self-use
|
|
21
|
-
class TestCdg(unittest.TestCase):
|
|
22
|
-
def test_graph_0(self):
|
|
23
|
-
# This graph comes from Fig.1 of paper An Efficient Method of Computing Static Single Assignment Form by Ron
|
|
24
|
-
# Cytron, etc.
|
|
25
|
-
|
|
26
|
-
# Create a project with a random binary - it will not be used anyways
|
|
27
|
-
p = angr.Project(
|
|
28
|
-
os.path.join(test_location, "x86_64", "datadep_test"),
|
|
29
|
-
load_options={"auto_load_libs": False},
|
|
30
|
-
use_sim_procedures=True,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
# Create the CDG analysis
|
|
34
|
-
cfg = p.analyses.CFGEmulated(no_construct=True)
|
|
35
|
-
|
|
36
|
-
# Create our mock control flow graph
|
|
37
|
-
g = networkx.DiGraph()
|
|
38
|
-
edges = [
|
|
39
|
-
("Entry", 1),
|
|
40
|
-
(1, 2),
|
|
41
|
-
(2, 3),
|
|
42
|
-
(2, 7),
|
|
43
|
-
(3, 4),
|
|
44
|
-
(3, 5),
|
|
45
|
-
(4, 6),
|
|
46
|
-
(5, 6),
|
|
47
|
-
(6, 8),
|
|
48
|
-
(7, 8),
|
|
49
|
-
(8, 9),
|
|
50
|
-
(9, 10),
|
|
51
|
-
(9, 11),
|
|
52
|
-
(11, 9),
|
|
53
|
-
(10, 11),
|
|
54
|
-
(11, 12),
|
|
55
|
-
(12, 2),
|
|
56
|
-
(12, "Exit"),
|
|
57
|
-
("Entry", "Exit"),
|
|
58
|
-
]
|
|
59
|
-
|
|
60
|
-
for src, dst in edges:
|
|
61
|
-
# Create a TemporaryNode for each node
|
|
62
|
-
n1 = TemporaryNode(src)
|
|
63
|
-
n2 = TemporaryNode(dst)
|
|
64
|
-
g.add_edge(n1, n2)
|
|
65
|
-
|
|
66
|
-
# Manually set the CFG
|
|
67
|
-
cfg.model.graph = g
|
|
68
|
-
cfg.model._nodes = {}
|
|
69
|
-
cfg._edge_map = {}
|
|
70
|
-
cfg._loop_back_edges = []
|
|
71
|
-
cfg._overlapped_loop_headers = []
|
|
72
|
-
|
|
73
|
-
# Call _construct()
|
|
74
|
-
cdg = p.analyses.CDG(cfg=cfg, no_construct=True)
|
|
75
|
-
cdg._entry = TemporaryNode("Entry")
|
|
76
|
-
cdg._construct()
|
|
77
|
-
|
|
78
|
-
standard_result = {
|
|
79
|
-
"Entry": {1, 2, 8, 9, 11, 12},
|
|
80
|
-
1: set(),
|
|
81
|
-
2: {3, 6, 7},
|
|
82
|
-
3: {4, 5},
|
|
83
|
-
4: set(),
|
|
84
|
-
5: set(),
|
|
85
|
-
6: set(),
|
|
86
|
-
7: set(),
|
|
87
|
-
8: set(),
|
|
88
|
-
9: {10},
|
|
89
|
-
10: set(),
|
|
90
|
-
11: {9, 11},
|
|
91
|
-
12: {2, 8, 9, 11, 12},
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for node, cd_nodes in standard_result.items():
|
|
95
|
-
# Each node in set `cd_nodes` is control dependent on `node`
|
|
96
|
-
for n in cd_nodes:
|
|
97
|
-
assert cdg.graph.has_edge(TemporaryNode(node), TemporaryNode(n))
|
|
98
|
-
assert len(cdg.graph.out_edges(TemporaryNode(node))) == len(cd_nodes)
|
|
99
|
-
|
|
100
|
-
def test_dominance_frontiers(self):
|
|
101
|
-
# This graph comes from Fig.1 of paper An Efficient Method of Computing Static Single Assignment Form by Ron
|
|
102
|
-
# Cytron, etc.
|
|
103
|
-
|
|
104
|
-
# Create our mock control flow graph
|
|
105
|
-
g = networkx.DiGraph()
|
|
106
|
-
g.add_edge("Entry", 1)
|
|
107
|
-
g.add_edge(1, 2)
|
|
108
|
-
g.add_edge(2, 3)
|
|
109
|
-
g.add_edge(2, 7)
|
|
110
|
-
g.add_edge(3, 4)
|
|
111
|
-
g.add_edge(3, 5)
|
|
112
|
-
g.add_edge(4, 6)
|
|
113
|
-
g.add_edge(5, 6)
|
|
114
|
-
g.add_edge(6, 8)
|
|
115
|
-
g.add_edge(7, 8)
|
|
116
|
-
g.add_edge(8, 9)
|
|
117
|
-
g.add_edge(9, 10)
|
|
118
|
-
g.add_edge(9, 11)
|
|
119
|
-
g.add_edge(11, 9)
|
|
120
|
-
g.add_edge(10, 11)
|
|
121
|
-
g.add_edge(11, 12)
|
|
122
|
-
g.add_edge(12, 2)
|
|
123
|
-
g.add_edge(12, "Exit")
|
|
124
|
-
g.add_edge("Entry", "Exit")
|
|
125
|
-
|
|
126
|
-
# Create the mock post-dom graph
|
|
127
|
-
postdom = networkx.DiGraph()
|
|
128
|
-
postdom.add_edge("Entry", 1)
|
|
129
|
-
postdom.add_edge(1, 2)
|
|
130
|
-
postdom.add_edge(2, 3)
|
|
131
|
-
postdom.add_edge(3, 4)
|
|
132
|
-
postdom.add_edge(3, 5)
|
|
133
|
-
postdom.add_edge(3, 6)
|
|
134
|
-
postdom.add_edge(2, 7)
|
|
135
|
-
postdom.add_edge(2, 8)
|
|
136
|
-
postdom.add_edge(8, 9)
|
|
137
|
-
postdom.add_edge(9, 10)
|
|
138
|
-
postdom.add_edge(9, 11)
|
|
139
|
-
postdom.add_edge(11, 12)
|
|
140
|
-
postdom.add_edge("Entry", "Exit")
|
|
141
|
-
|
|
142
|
-
# Call df_construct()
|
|
143
|
-
df = compute_dominance_frontier(g, postdom)
|
|
144
|
-
|
|
145
|
-
standard_df = {
|
|
146
|
-
1: {"Exit"},
|
|
147
|
-
2: {"Exit", 2},
|
|
148
|
-
3: {8},
|
|
149
|
-
4: {6},
|
|
150
|
-
5: {6},
|
|
151
|
-
6: {8},
|
|
152
|
-
7: {8},
|
|
153
|
-
8: {"Exit", 2},
|
|
154
|
-
9: {"Exit", 2, 9},
|
|
155
|
-
10: {11},
|
|
156
|
-
11: {"Exit", 2, 9},
|
|
157
|
-
12: {"Exit", 2},
|
|
158
|
-
"Entry": set(),
|
|
159
|
-
"Exit": set(),
|
|
160
|
-
}
|
|
161
|
-
assert df == standard_df
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if __name__ == "__main__":
|
|
165
|
-
unittest.main()
|
tests/analyses/test_cfb.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
from unittest import TestCase, main
|
|
5
|
-
import os.path
|
|
6
|
-
|
|
7
|
-
import angr
|
|
8
|
-
|
|
9
|
-
from ..common import bin_location
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
test_location = os.path.join(bin_location, "tests")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# pylint: disable=no-self-use
|
|
16
|
-
class CFBlanketTests(TestCase):
|
|
17
|
-
"""
|
|
18
|
-
Test CFBlanket analysis
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
def test_on_object_added_callback(self):
|
|
22
|
-
my_callback_artifacts = {}
|
|
23
|
-
|
|
24
|
-
def my_callback(addr, obj):
|
|
25
|
-
my_callback_artifacts[addr] = obj
|
|
26
|
-
|
|
27
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), load_options={"auto_load_libs": False})
|
|
28
|
-
cfb = p.analyses.CFB(on_object_added=my_callback)
|
|
29
|
-
|
|
30
|
-
addr = 0x1_00000000
|
|
31
|
-
obj = "my object"
|
|
32
|
-
cfb.add_obj(addr, obj)
|
|
33
|
-
assert addr in my_callback_artifacts and my_callback_artifacts[addr] == obj
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if __name__ == "__main__":
|
|
37
|
-
main()
|
|
@@ -1,46 +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 angr
|
|
8
|
-
|
|
9
|
-
from ..common import bin_location
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
test_location = os.path.join(bin_location, "tests")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# pylint: disable=missing-class-docstring
|
|
16
|
-
# pylint: disable=no-self-use
|
|
17
|
-
class TestClassIdentifier(unittest.TestCase):
|
|
18
|
-
def test_class_identification_x86_64(self):
|
|
19
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "cpp_classes"), auto_load_libs=False)
|
|
20
|
-
class_identifier_analysis = p.analyses.ClassIdentifier()
|
|
21
|
-
classes_found = class_identifier_analysis.classes
|
|
22
|
-
class_labels = []
|
|
23
|
-
vtable_ptr_c = [0x403CB0, 0x403CD8]
|
|
24
|
-
|
|
25
|
-
for class_str in classes_found:
|
|
26
|
-
class_labels.append(class_str)
|
|
27
|
-
|
|
28
|
-
assert "A" in class_labels
|
|
29
|
-
assert "B" in class_labels
|
|
30
|
-
assert "C" in class_labels
|
|
31
|
-
|
|
32
|
-
for vtable_ptr in classes_found["C"].vtable_ptrs:
|
|
33
|
-
assert vtable_ptr in vtable_ptr_c
|
|
34
|
-
|
|
35
|
-
for func_addr in classes_found["C"].function_members:
|
|
36
|
-
assert func_addr in [0x401262, 0x401490, 0x4014CB, 0x401512]
|
|
37
|
-
|
|
38
|
-
for func_addr in classes_found["B"].function_members:
|
|
39
|
-
assert func_addr in [0x4011EA, 0x401226, 0x4014D6]
|
|
40
|
-
|
|
41
|
-
for func_addr in classes_found["A"].function_members:
|
|
42
|
-
assert func_addr in [0x401418, 0x401454, 0x4014F4]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if __name__ == "__main__":
|
|
46
|
-
unittest.main()
|
tests/analyses/test_clinic.py
DELETED
|
@@ -1,30 +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 angr
|
|
8
|
-
import angr.analyses.decompiler
|
|
9
|
-
|
|
10
|
-
from ..common import bin_location
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
test_location = os.path.join(bin_location, "tests")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# pylint: disable=missing-class-docstring
|
|
17
|
-
# pylint: disable=no-self-use
|
|
18
|
-
class TestClinic(unittest.TestCase):
|
|
19
|
-
def test_smoketest(self):
|
|
20
|
-
binary_path = os.path.join(test_location, "x86_64", "all")
|
|
21
|
-
proj = angr.Project(binary_path, auto_load_libs=False, load_debug_info=True)
|
|
22
|
-
|
|
23
|
-
cfg = proj.analyses.CFG(normalize=True)
|
|
24
|
-
main_func = cfg.kb.functions["main"]
|
|
25
|
-
|
|
26
|
-
proj.analyses.Clinic(main_func)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if __name__ == "__main__":
|
|
30
|
-
unittest.main()
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=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
|
-
from angr.analyses.code_tagging import CodeTags
|
|
10
|
-
|
|
11
|
-
from ..common import bin_location
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test_location = os.path.join(bin_location, "tests")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestCodetagging(unittest.TestCase):
|
|
18
|
-
def test_hasxor(self):
|
|
19
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "HashTest"), auto_load_libs=False)
|
|
20
|
-
cfg = p.analyses.CFG()
|
|
21
|
-
|
|
22
|
-
ct_rshash = p.analyses.CodeTagging(cfg.kb.functions["RSHash"])
|
|
23
|
-
assert CodeTags.HAS_XOR not in ct_rshash.tags
|
|
24
|
-
ct_jshash = p.analyses.CodeTagging(cfg.kb.functions["JSHash"])
|
|
25
|
-
assert CodeTags.HAS_XOR in ct_jshash.tags
|
|
26
|
-
assert CodeTags.HAS_BITSHIFTS in ct_jshash.tags
|
|
27
|
-
ct_elfhash = p.analyses.CodeTagging(cfg.kb.functions["ELFHash"])
|
|
28
|
-
assert CodeTags.HAS_BITSHIFTS in ct_elfhash.tags
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if __name__ == "__main__":
|
|
32
|
-
unittest.main()
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=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
|
-
from angr.analyses.propagator.vex_vars import VEXReg
|
|
10
|
-
|
|
11
|
-
from ..common import bin_location
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test_location = os.path.join(bin_location, "tests")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestConstantpropagation(unittest.TestCase):
|
|
18
|
-
def test_libc_x86(self):
|
|
19
|
-
# disabling auto_load_libs increases the execution time.
|
|
20
|
-
p = angr.Project(os.path.join(test_location, "i386", "libc-2.27-3ubuntu1.so.6"), auto_load_libs=True)
|
|
21
|
-
dl_addr = p.loader.find_symbol("_dl_addr").rebased_addr
|
|
22
|
-
cfg = p.analyses.CFGFast(regions=[(dl_addr, dl_addr + 4096)])
|
|
23
|
-
func = cfg.functions["_dl_addr"]
|
|
24
|
-
|
|
25
|
-
rtld_global_sym = p.loader.find_symbol("_rtld_global")
|
|
26
|
-
assert rtld_global_sym is not None
|
|
27
|
-
_rtld_global_addr = rtld_global_sym.rebased_addr
|
|
28
|
-
|
|
29
|
-
base_addr = 0x998F000
|
|
30
|
-
state = p.factory.blank_state()
|
|
31
|
-
for addr in range(0, 0 + 0x1000, p.arch.bytes):
|
|
32
|
-
state.memory.store(
|
|
33
|
-
_rtld_global_addr + addr, base_addr + addr, size=p.arch.bytes, endness=p.arch.memory_endness
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
prop = p.analyses.Propagator(func=func, base_state=state)
|
|
37
|
-
# import pprint
|
|
38
|
-
# pprint.pprint(prop.replacements)
|
|
39
|
-
assert len(prop.replacements) > 0
|
|
40
|
-
|
|
41
|
-
def test_lwip_udpecho_bm(self):
|
|
42
|
-
bin_path = os.path.join(test_location, "armel", "lwip_udpecho_bm.elf")
|
|
43
|
-
p = angr.Project(bin_path, auto_load_libs=False)
|
|
44
|
-
cfg = p.analyses.CFG(data_references=True)
|
|
45
|
-
|
|
46
|
-
func = cfg.functions[0x23C9]
|
|
47
|
-
state = p.factory.blank_state()
|
|
48
|
-
prop = p.analyses.Propagator(func=func, base_state=state)
|
|
49
|
-
|
|
50
|
-
assert len(prop.replacements) > 0
|
|
51
|
-
|
|
52
|
-
def test_register_propagation_across_calls(self):
|
|
53
|
-
call_targets = [
|
|
54
|
-
"syscall",
|
|
55
|
-
"call _0", # Resolved
|
|
56
|
-
"call rdi", # TOP
|
|
57
|
-
"call qword ptr [0xBAD]", # Unresolved
|
|
58
|
-
]
|
|
59
|
-
|
|
60
|
-
for target in call_targets:
|
|
61
|
-
p = angr.load_shellcode(
|
|
62
|
-
f"""
|
|
63
|
-
_0:
|
|
64
|
-
mov rcx, 0x12345678
|
|
65
|
-
mov rbp, 0xFEDCBA90
|
|
66
|
-
_11:
|
|
67
|
-
{target}
|
|
68
|
-
mov rax, rcx
|
|
69
|
-
mov rdi, rbp
|
|
70
|
-
ret
|
|
71
|
-
""",
|
|
72
|
-
"AMD64",
|
|
73
|
-
)
|
|
74
|
-
cfg = p.analyses.CFG()
|
|
75
|
-
prop = p.analyses.Propagator(func=cfg.functions[0], only_consts=True)
|
|
76
|
-
regs_replaced = {
|
|
77
|
-
p.arch.register_names[var.offset]: val
|
|
78
|
-
for codeloc, replacements in prop.replacements.items()
|
|
79
|
-
if codeloc.block_addr >= 0x11
|
|
80
|
-
for var, val in replacements.items()
|
|
81
|
-
if isinstance(var, VEXReg)
|
|
82
|
-
}
|
|
83
|
-
assert "rax" not in regs_replaced # caller saved
|
|
84
|
-
assert regs_replaced["rdi"].concrete_value == 0xFEDCBA90 # callee saved
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if __name__ == "__main__":
|
|
88
|
-
unittest.main()
|
tests/analyses/test_ddg.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.analyses" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import logging
|
|
7
|
-
import time
|
|
8
|
-
import unittest
|
|
9
|
-
|
|
10
|
-
import angr
|
|
11
|
-
from angr.code_location import CodeLocation
|
|
12
|
-
from angr.sim_variable import SimRegisterVariable
|
|
13
|
-
|
|
14
|
-
from ..common import bin_location
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
l = logging.getLogger("angr.tests.test_ddg")
|
|
18
|
-
test_location = os.path.join(bin_location, "tests")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class TestDDG(unittest.TestCase):
|
|
22
|
-
def perform_one(self, binary_path):
|
|
23
|
-
proj = angr.Project(
|
|
24
|
-
binary_path,
|
|
25
|
-
load_options={"auto_load_libs": False},
|
|
26
|
-
use_sim_procedures=True,
|
|
27
|
-
default_analysis_mode="symbolic",
|
|
28
|
-
)
|
|
29
|
-
start = time.time()
|
|
30
|
-
cfg = proj.analyses.CFGEmulated(
|
|
31
|
-
context_sensitivity_level=2,
|
|
32
|
-
keep_state=True,
|
|
33
|
-
state_add_options=angr.sim_options.refs, # refs are necessary for DDG to work
|
|
34
|
-
)
|
|
35
|
-
end = time.time()
|
|
36
|
-
duration = end - start
|
|
37
|
-
l.info("CFG generated in %f seconds.", duration)
|
|
38
|
-
|
|
39
|
-
ddg = proj.analyses.DDG(cfg, start=cfg.functions["main"].addr)
|
|
40
|
-
# There should be at least 400 nodes
|
|
41
|
-
assert len(ddg.graph) >= 400
|
|
42
|
-
|
|
43
|
-
# Memory dependency 1
|
|
44
|
-
|
|
45
|
-
"""
|
|
46
|
-
00 | ------ IMark(0x400667, 3, 0) ------
|
|
47
|
-
01 | t15 = GET:I64(rbp)
|
|
48
|
-
02 | t14 = Add64(t15,0xfffffffffffffffc)
|
|
49
|
-
03 | t17 = LDle:I32(t14)
|
|
50
|
-
04 | t45 = 32Uto64(t17)
|
|
51
|
-
05 | t16 = t45
|
|
52
|
-
06 | PUT(rip) = 0x000000000040066a
|
|
53
|
-
...
|
|
54
|
-
15 | ------ IMark(0x40066d, 4, 0) ------
|
|
55
|
-
16 | t24 = Add64(t15,0xfffffffffffffffc)
|
|
56
|
-
17 | t7 = LDle:I32(t24)
|
|
57
|
-
18 | t5 = Add32(t7,0x00000001)
|
|
58
|
-
19 | STle(t24) = t5
|
|
59
|
-
20 | PUT(rip) = 0x0000000000400671
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
cl1 = CodeLocation(0x400667, ins_addr=0x400667, stmt_idx=3)
|
|
63
|
-
in_edges = ddg.graph.in_edges([cl1], data=True)
|
|
64
|
-
# Where the memory address comes from
|
|
65
|
-
memaddr_src = CodeLocation(0x400667, ins_addr=0x400667, stmt_idx=2)
|
|
66
|
-
# Where the data comes from
|
|
67
|
-
data_src_0 = CodeLocation(0x40064C, ins_addr=0x40065E, stmt_idx=26)
|
|
68
|
-
data_src_1 = CodeLocation(0x400667, ins_addr=0x40066D, stmt_idx=19)
|
|
69
|
-
assert len(in_edges) == 3
|
|
70
|
-
assert (data_src_0, cl1) in [(src, dst) for src, dst, _ in in_edges]
|
|
71
|
-
assert (data_src_1, cl1) in [(src, dst) for src, dst, _ in in_edges]
|
|
72
|
-
assert (
|
|
73
|
-
memaddr_src,
|
|
74
|
-
cl1,
|
|
75
|
-
{"data": 14, "type": "tmp", "subtype": ("mem_addr",)},
|
|
76
|
-
) in in_edges
|
|
77
|
-
|
|
78
|
-
instr_view = ddg.view[0x400721]
|
|
79
|
-
assert instr_view is not None
|
|
80
|
-
definitions: list = instr_view.definitions
|
|
81
|
-
var = None
|
|
82
|
-
for definition in definitions:
|
|
83
|
-
if isinstance(definition._variable.variable, SimRegisterVariable):
|
|
84
|
-
var = definition._variable.variable
|
|
85
|
-
break
|
|
86
|
-
assert var is not None
|
|
87
|
-
assert var.reg == 56
|
|
88
|
-
|
|
89
|
-
def test_ddg_0(self):
|
|
90
|
-
binary_path = os.path.join(test_location, "x86_64", "datadep_test")
|
|
91
|
-
self.perform_one(binary_path)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if __name__ == "__main__":
|
|
95
|
-
unittest.main()
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=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
|
-
arches = {"x86_64"}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestDdgGlobalVarDependencies(unittest.TestCase):
|
|
18
|
-
def test_ddg_global_var_dependencies(self):
|
|
19
|
-
for arch in arches:
|
|
20
|
-
self.run_ddg_global_var_dependencies(arch)
|
|
21
|
-
|
|
22
|
-
def run_ddg_global_var_dependencies(self, arch):
|
|
23
|
-
test_file = os.path.join(test_location, arch, "ddg_global_var_dependencies")
|
|
24
|
-
proj = angr.Project(test_file, auto_load_libs=False)
|
|
25
|
-
cfg = proj.analyses.CFGEmulated(
|
|
26
|
-
context_sensitivity_level=2,
|
|
27
|
-
keep_state=True,
|
|
28
|
-
state_add_options=angr.sim_options.refs,
|
|
29
|
-
)
|
|
30
|
-
ddg = proj.analyses.DDG(cfg)
|
|
31
|
-
main_func = cfg.functions.function(name="main")
|
|
32
|
-
|
|
33
|
-
target_block_addr = main_func.ret_sites[0].addr
|
|
34
|
-
target_block = proj.factory.block(addr=target_block_addr)
|
|
35
|
-
tgt_stmt_idx, tgt_stmt = self.get_target_stmt(proj, target_block)
|
|
36
|
-
assert tgt_stmt_idx is not None
|
|
37
|
-
buf_addr = tgt_stmt.data.addr.con.value
|
|
38
|
-
tgt_ddg_node = self.get_ddg_node(ddg, target_block_addr, tgt_stmt_idx)
|
|
39
|
-
assert tgt_ddg_node is not None
|
|
40
|
-
|
|
41
|
-
# Whether the target depends on the statement assigning 'b' to the global variable
|
|
42
|
-
has_correct_dependency = False
|
|
43
|
-
for pred in ddg.get_predecessors(tgt_ddg_node):
|
|
44
|
-
pred_block = proj.factory.block(addr=pred.block_addr)
|
|
45
|
-
stmt = pred_block.vex.statements[pred.stmt_idx]
|
|
46
|
-
has_correct_dependency |= self.check_dependency(stmt, buf_addr, ord("b"))
|
|
47
|
-
|
|
48
|
-
# If the target depends on the statement assigning 'a' to the global variable, it is underconstrained (
|
|
49
|
-
# this assignment should be overwritten by the 'b' assignment)
|
|
50
|
-
assert not self.check_dependency(
|
|
51
|
-
stmt, buf_addr, ord("a")
|
|
52
|
-
), "Target statement has incorrect dependency (DDG is underconstrained)"
|
|
53
|
-
assert has_correct_dependency, "Target statement does not have correct dependency (DDG is overconstrained)"
|
|
54
|
-
|
|
55
|
-
def check_dependency(self, stmt, addr, const):
|
|
56
|
-
# Check if we are storing a constant to a variable with constant address
|
|
57
|
-
if stmt.tag == "Ist_Store" and stmt.addr.tag == "Iex_Const" and stmt.data.tag == "Iex_Const":
|
|
58
|
-
# Check if we are storing the specified constant to the specified variable address
|
|
59
|
-
if stmt.addr.con.value == addr and stmt.data.con.value == const:
|
|
60
|
-
return True
|
|
61
|
-
|
|
62
|
-
return False
|
|
63
|
-
|
|
64
|
-
def get_ddg_node(self, ddg, block_addr, stmt_idx):
|
|
65
|
-
for node in ddg.graph.nodes:
|
|
66
|
-
if node.block_addr == block_addr and node.stmt_idx == stmt_idx:
|
|
67
|
-
return node
|
|
68
|
-
return None
|
|
69
|
-
|
|
70
|
-
def get_target_stmt(self, proj, block):
|
|
71
|
-
for i, stmt in enumerate(block.vex.statements):
|
|
72
|
-
# We're looking for the instruction that loads a constant memory address into a temporary variable
|
|
73
|
-
if stmt.tag == "Ist_WrTmp" and stmt.data.tag == "Iex_Load" and stmt.data.addr.tag == "Iex_Const":
|
|
74
|
-
addr = stmt.data.addr.con.value
|
|
75
|
-
section = proj.loader.main_object.find_section_containing(addr)
|
|
76
|
-
# Confirm the memory address is in the uninitialized data section
|
|
77
|
-
if section.name == ".bss":
|
|
78
|
-
return i, stmt
|
|
79
|
-
return None, None
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if __name__ == "__main__":
|
|
83
|
-
unittest.main()
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=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
|
-
arches = {"i386", "x86_64"}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestDdgMemvarAddresses(unittest.TestCase):
|
|
18
|
-
def test_ddg_memvar_addresses(self):
|
|
19
|
-
for arch in arches:
|
|
20
|
-
self.run_ddg_memvar_addresses(arch)
|
|
21
|
-
|
|
22
|
-
def run_ddg_memvar_addresses(self, arch):
|
|
23
|
-
test_file = os.path.join(test_location, arch, "simple_data_dependence")
|
|
24
|
-
proj = angr.Project(test_file, auto_load_libs=False)
|
|
25
|
-
cfg = proj.analyses.CFGEmulated(
|
|
26
|
-
context_sensitivity_level=2,
|
|
27
|
-
keep_state=True,
|
|
28
|
-
state_add_options=angr.sim_options.refs,
|
|
29
|
-
)
|
|
30
|
-
ddg = proj.analyses.DDG(cfg)
|
|
31
|
-
|
|
32
|
-
for node in ddg._data_graph.nodes():
|
|
33
|
-
if isinstance(node.variable, angr.sim_variable.SimMemoryVariable):
|
|
34
|
-
assert (
|
|
35
|
-
0 <= node.variable.addr < (1 << proj.arch.bits)
|
|
36
|
-
), f"Program variable {node.variable} has an invalid address: {node.variable.addr}"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if __name__ == "__main__":
|
|
40
|
-
unittest.main()
|