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,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint:disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.knowledge_plugins" # 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 PatchTests(unittest.TestCase):
|
|
17
|
-
"""
|
|
18
|
-
Basic PatchManager tests
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
def test_patch_vulnerable_fauxware_amd64(self):
|
|
22
|
-
binpath = os.path.join(test_location, "x86_64", "vulns", "vulnerable_fauxware")
|
|
23
|
-
proj = angr.Project(binpath, auto_load_libs=False)
|
|
24
|
-
|
|
25
|
-
proj.kb.patches.add_patch(0x40094C, b"\x0a")
|
|
26
|
-
patched = proj.kb.patches.apply_patches_to_binary()
|
|
27
|
-
|
|
28
|
-
# manual patch
|
|
29
|
-
with open(binpath, "rb") as f:
|
|
30
|
-
binary_data = f.read()
|
|
31
|
-
binary_data = binary_data[:0x94C] + b"\x0a" + binary_data[0x94D:]
|
|
32
|
-
|
|
33
|
-
assert patched == binary_data
|
|
34
|
-
|
|
35
|
-
def test_block_factory_returns_patched_bytes(self):
|
|
36
|
-
binpath = os.path.join(test_location, "x86_64", "fauxware")
|
|
37
|
-
proj = angr.Project(binpath, auto_load_libs=False)
|
|
38
|
-
|
|
39
|
-
addr = 0x4007D3
|
|
40
|
-
patch_bytes = proj.arch.keystone.asm("inc rax; leave; ret", addr, as_bytes=True)[0]
|
|
41
|
-
proj.kb.patches.add_patch(addr, patch_bytes)
|
|
42
|
-
|
|
43
|
-
b = proj.factory.block(addr)
|
|
44
|
-
assert b.bytes == patch_bytes
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if __name__ == "__main__":
|
|
48
|
-
unittest.main()
|
tests/misc/__init__.py
DELETED
|
File without changes
|
tests/misc/test_hookset.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
import unittest
|
|
4
|
-
|
|
5
|
-
import angr
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TestHookSet(unittest.TestCase):
|
|
9
|
-
def test_hookset(self):
|
|
10
|
-
class Foo:
|
|
11
|
-
def run(self):
|
|
12
|
-
return self.blah()
|
|
13
|
-
|
|
14
|
-
def blah(self): # pylint:disable=no-self-use
|
|
15
|
-
return ["foo"]
|
|
16
|
-
|
|
17
|
-
def install_hooks(self, tech):
|
|
18
|
-
angr.misc.HookSet.install_hooks(self, blah=tech.blah)
|
|
19
|
-
|
|
20
|
-
def remove_hooks(self, tech):
|
|
21
|
-
angr.misc.HookSet.remove_hooks(self, blah=tech.blah)
|
|
22
|
-
|
|
23
|
-
class Bar:
|
|
24
|
-
def blah(self, foo): # pylint:disable=no-self-use
|
|
25
|
-
return ["bar"] + foo.blah()
|
|
26
|
-
|
|
27
|
-
class Baz:
|
|
28
|
-
def blah(self, foo): # pylint:disable=no-self-use
|
|
29
|
-
return ["baz"] + foo.blah()
|
|
30
|
-
|
|
31
|
-
class Coward:
|
|
32
|
-
def blah(self, foo): # pylint:disable=no-self-use,unused-argument
|
|
33
|
-
return ["coward"]
|
|
34
|
-
|
|
35
|
-
foo = Foo()
|
|
36
|
-
assert foo.run() == ["foo"]
|
|
37
|
-
|
|
38
|
-
bar = Bar()
|
|
39
|
-
baz = Baz()
|
|
40
|
-
foo.install_hooks(bar)
|
|
41
|
-
foo.install_hooks(baz)
|
|
42
|
-
assert foo.run() == ["baz", "bar", "foo"]
|
|
43
|
-
|
|
44
|
-
foo.remove_hooks(bar)
|
|
45
|
-
foo.remove_hooks(baz)
|
|
46
|
-
assert foo.run() == ["foo"]
|
|
47
|
-
|
|
48
|
-
coward = Coward()
|
|
49
|
-
foo.install_hooks(coward)
|
|
50
|
-
assert foo.run() == ["coward"]
|
|
51
|
-
|
|
52
|
-
foo.remove_hooks(coward)
|
|
53
|
-
assert foo.run() == ["foo"]
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if __name__ == "__main__":
|
|
57
|
-
unittest.main()
|
tests/perf/__init__.py
DELETED
|
File without changes
|
tests/perf/perf_cfgemulated.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import angr
|
|
5
|
-
|
|
6
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
7
|
-
p = angr.Project(os.path.join(test_location, "tests", "x86_64", "true"), auto_load_libs=False)
|
|
8
|
-
funcs = list(p.analyses.CFGFast().functions.keys())
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def main():
|
|
12
|
-
p.analyses.CFGEmulated(starts=funcs, call_depth=0)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if __name__ == "__main__":
|
|
16
|
-
tstart = time.time()
|
|
17
|
-
main()
|
|
18
|
-
tend = time.time()
|
|
19
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
tests/perf/perf_cfgfast.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import angr
|
|
5
|
-
|
|
6
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
7
|
-
p = angr.Project(os.path.join(test_location, "tests", "x86_64", "libc.so.6"), auto_load_libs=False)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def main():
|
|
11
|
-
p.analyses.CFGFast()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if __name__ == "__main__":
|
|
15
|
-
tstart = time.time()
|
|
16
|
-
main()
|
|
17
|
-
tend = time.time()
|
|
18
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Performance tests on concrete code execution without invoking Unicorn engine
|
|
2
|
-
# uses a stripped-down SimEngine to only test the essential pieces
|
|
3
|
-
# TODO also use a stripped-down memory
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import time
|
|
7
|
-
|
|
8
|
-
import angr
|
|
9
|
-
import claripy
|
|
10
|
-
|
|
11
|
-
# attempt to turn off claripy debug mode
|
|
12
|
-
if hasattr(claripy, "set_debug"):
|
|
13
|
-
claripy.set_debug(False)
|
|
14
|
-
|
|
15
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class SkinnyEngine(
|
|
19
|
-
angr.engines.SimEngineFailure, angr.engines.SimEngineSyscall, angr.engines.HooksMixin, angr.engines.HeavyVEXMixin
|
|
20
|
-
):
|
|
21
|
-
pass
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
arch = "x86_64"
|
|
25
|
-
b = angr.Project(os.path.join(test_location, "tests", arch, "perf_tight_loops"), auto_load_libs=False)
|
|
26
|
-
state = b.factory.full_init_state(
|
|
27
|
-
plugins={"registers": angr.state_plugins.SimLightRegisters()}, remove_options={angr.sim_options.COPY_STATES}
|
|
28
|
-
)
|
|
29
|
-
engine = SkinnyEngine(b)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def main():
|
|
33
|
-
simgr = b.factory.simgr(state)
|
|
34
|
-
simgr.explore(engine=engine)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if __name__ == "__main__":
|
|
38
|
-
tstart = time.time()
|
|
39
|
-
main()
|
|
40
|
-
tend = time.time()
|
|
41
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import angr
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class InspectorEngine(
|
|
8
|
-
angr.engines.SimEngineFailure,
|
|
9
|
-
angr.engines.SimEngineSyscall,
|
|
10
|
-
angr.engines.HooksMixin,
|
|
11
|
-
angr.engines.SimInspectMixin,
|
|
12
|
-
angr.engines.HeavyVEXMixin,
|
|
13
|
-
):
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
arch = "x86_64"
|
|
18
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
19
|
-
b = angr.Project(os.path.join(test_location, "tests", arch, "perf_tight_loops"), auto_load_libs=False)
|
|
20
|
-
state = b.factory.full_init_state(
|
|
21
|
-
plugins={"registers": angr.state_plugins.SimLightRegisters()}, remove_options={angr.sim_options.COPY_STATES}
|
|
22
|
-
)
|
|
23
|
-
state.supports_inspect = True # force enable inspect without adding any breakpoints
|
|
24
|
-
engine = InspectorEngine(b)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def main():
|
|
28
|
-
simgr = b.factory.simgr(state)
|
|
29
|
-
simgr.explore(engine=engine)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if __name__ == "__main__":
|
|
33
|
-
tstart = time.time()
|
|
34
|
-
main()
|
|
35
|
-
tend = time.time()
|
|
36
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
tests/perf/perf_state_copy.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import time
|
|
5
|
-
|
|
6
|
-
import angr
|
|
7
|
-
import claripy
|
|
8
|
-
|
|
9
|
-
bvs = claripy.BVS("foo", 8)
|
|
10
|
-
|
|
11
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
12
|
-
state = angr.Project(
|
|
13
|
-
os.path.join(test_location, "tests", "x86_64", "fauxware"), main_opts={"base_addr": 0x400000}, auto_load_libs=True
|
|
14
|
-
).factory.full_init_state(add_options={angr.options.REVERSE_MEMORY_NAME_MAP})
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def cycle(s):
|
|
18
|
-
s = s.copy()
|
|
19
|
-
s.memory.store(0x400000, bvs)
|
|
20
|
-
return s
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def main():
|
|
24
|
-
s = cycle(state)
|
|
25
|
-
for _ in range(20000):
|
|
26
|
-
s = cycle(s)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if __name__ == "__main__":
|
|
30
|
-
tstart = time.time()
|
|
31
|
-
main()
|
|
32
|
-
tend = time.time()
|
|
33
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
tests/perf/perf_unicorn_0.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import angr
|
|
5
|
-
from angr import options as so
|
|
6
|
-
|
|
7
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
8
|
-
p = angr.Project(os.path.join(test_location, "tests", "x86_64", "perf_unicorn_0"))
|
|
9
|
-
s_unicorn = p.factory.entry_state(
|
|
10
|
-
add_options=so.unicorn | {so.STRICT_PAGE_ACCESS}, remove_options={so.LAZY_SOLVES}
|
|
11
|
-
) # unicorn
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def main():
|
|
15
|
-
sm_unicorn = p.factory.simulation_manager(s_unicorn)
|
|
16
|
-
sm_unicorn.run()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if __name__ == "__main__":
|
|
20
|
-
import logging
|
|
21
|
-
|
|
22
|
-
logging.getLogger("angr.state_plugins.unicorn_engine").setLevel("DEBUG")
|
|
23
|
-
logging.getLogger("angr.engines.unicorn").setLevel("DEBUG")
|
|
24
|
-
tstart = time.time()
|
|
25
|
-
main()
|
|
26
|
-
tend = time.time()
|
|
27
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
tests/perf/perf_unicorn_1.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import angr
|
|
5
|
-
from angr import options as so
|
|
6
|
-
|
|
7
|
-
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../binaries")
|
|
8
|
-
p = angr.Project(os.path.join(test_location, "tests", "x86_64", "perf_unicorn_1"))
|
|
9
|
-
s_unicorn = p.factory.entry_state(
|
|
10
|
-
add_options=so.unicorn | {so.STRICT_PAGE_ACCESS}, remove_options={so.LAZY_SOLVES}
|
|
11
|
-
) # unicorn
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def main():
|
|
15
|
-
sm_unicorn = p.factory.simulation_manager(s_unicorn)
|
|
16
|
-
sm_unicorn.run()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if __name__ == "__main__":
|
|
20
|
-
tstart = time.time()
|
|
21
|
-
main()
|
|
22
|
-
tend = time.time()
|
|
23
|
-
print("Elapsed: %f sec" % (tend - tstart))
|
tests/procedures/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.procedures.glibc" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import subprocess
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
|
|
11
|
-
from ...common import bin_location, skip_if_not_linux
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test_location = os.path.join(bin_location, "tests")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestCtypeLocale(unittest.TestCase):
|
|
18
|
-
@skip_if_not_linux
|
|
19
|
-
def test_ctype_b_loc(self):
|
|
20
|
-
"""
|
|
21
|
-
test_ctype_locale.test_ctype_b_loc
|
|
22
|
-
|
|
23
|
-
const unsigned short * * __ctype_b_loc (void);
|
|
24
|
-
|
|
25
|
-
Description
|
|
26
|
-
|
|
27
|
-
The __ctype_b_loc() function shall return a pointer into an array of
|
|
28
|
-
characters in the current locale that contains characteristics for each
|
|
29
|
-
character in the current character set. The array shall contain a total
|
|
30
|
-
of 384 characters, and can be indexed with any signed or unsigned char
|
|
31
|
-
(i.e. with an index value between -128 and 255). If the application is
|
|
32
|
-
multithreaded, the array shall be local to the current thread.
|
|
33
|
-
|
|
34
|
-
This interface is not in the source standard; it is only in the binary
|
|
35
|
-
standard.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
# Just load a binary so that we can do the initialization steps from
|
|
39
|
-
# libc_start_main
|
|
40
|
-
bin_path = os.path.join(test_location, "x86_64", "ctype_b_loc")
|
|
41
|
-
|
|
42
|
-
def ctype_b_loc(state, arguments):
|
|
43
|
-
return angr.SIM_PROCEDURES["glibc"]["__ctype_b_loc"]().execute(state, arguments=arguments)
|
|
44
|
-
|
|
45
|
-
b = angr.Project(bin_path, auto_load_libs=False)
|
|
46
|
-
p = b.factory.full_init_state()
|
|
47
|
-
pg = b.factory.simulation_manager(p)
|
|
48
|
-
|
|
49
|
-
# Find main located at 0x400596 to let libc_start_main do its thing
|
|
50
|
-
main = pg.explore(find=0x400596)
|
|
51
|
-
|
|
52
|
-
state = main.found[0]
|
|
53
|
-
b_loc_array_ptr = ctype_b_loc(state, []).ret_expr
|
|
54
|
-
table_ptr = state.memory.load(b_loc_array_ptr, state.arch.bytes, endness=state.arch.memory_endness)
|
|
55
|
-
|
|
56
|
-
result = b""
|
|
57
|
-
for i in range(-128, 256):
|
|
58
|
-
result += b"%d->0x%x\n" % (i, state.mem[table_ptr + i * 2].short.unsigned.concrete)
|
|
59
|
-
|
|
60
|
-
# Check output of compiled C program that uses ctype_b_loc()
|
|
61
|
-
output = subprocess.check_output(bin_path, shell=True)
|
|
62
|
-
assert result == output
|
|
63
|
-
|
|
64
|
-
@skip_if_not_linux
|
|
65
|
-
def test_ctype_tolower_loc(self):
|
|
66
|
-
"""
|
|
67
|
-
test_ctype_locale.test_ctype_tolower_loc
|
|
68
|
-
|
|
69
|
-
int32_t * * __ctype_tolower_loc(void);
|
|
70
|
-
|
|
71
|
-
Description:
|
|
72
|
-
The __ctype_tolower_loc() function shall return a pointer into an array of
|
|
73
|
-
characters in the current locale that contains lower case equivalents for
|
|
74
|
-
each character in the current character set. The array shall contain a total
|
|
75
|
-
of 384 characters, and can be indexed with any signed or unsigned char (i.e.
|
|
76
|
-
with an index value between -128 and 255). If the application is
|
|
77
|
-
multithreaded, the array shall be local to the current thread.
|
|
78
|
-
|
|
79
|
-
This interface is not in the source standard; it is only in the binary
|
|
80
|
-
standard.
|
|
81
|
-
|
|
82
|
-
Return Value:
|
|
83
|
-
The __ctype_tolower_loc() function shall return a pointer to the array of
|
|
84
|
-
characters to be used for the ctype() family of functions (see <ctype.h>).
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
# Just load a binary so that we can do the initialization steps from
|
|
88
|
-
# libc_start_main
|
|
89
|
-
bin_path = os.path.join(test_location, "x86_64", "ctype_tolower_loc")
|
|
90
|
-
|
|
91
|
-
def ctype_tolower_loc(state, arguments):
|
|
92
|
-
return angr.SIM_PROCEDURES["glibc"]["__ctype_tolower_loc"]().execute(state, arguments=arguments)
|
|
93
|
-
|
|
94
|
-
b = angr.Project(bin_path, auto_load_libs=False)
|
|
95
|
-
p = b.factory.full_init_state()
|
|
96
|
-
pg = b.factory.simulation_manager(p)
|
|
97
|
-
|
|
98
|
-
# Find main located at 0x400596 to let libc_start_main do its thing
|
|
99
|
-
main = pg.explore(find=0x400596)
|
|
100
|
-
|
|
101
|
-
state = main.found[0]
|
|
102
|
-
tolower_loc_array_ptr = ctype_tolower_loc(state, []).ret_expr
|
|
103
|
-
table_ptr = state.memory.load(tolower_loc_array_ptr, state.arch.bytes, endness=state.arch.memory_endness)
|
|
104
|
-
|
|
105
|
-
result = b""
|
|
106
|
-
for i in range(-128, 256):
|
|
107
|
-
result += b"%d->0x%x\n" % (i, state.mem[table_ptr + i * 4].int.unsigned.concrete)
|
|
108
|
-
|
|
109
|
-
# Check output of compiled C program that uses ctype_tolower_loc()
|
|
110
|
-
output = subprocess.check_output(bin_path, shell=True)
|
|
111
|
-
assert result == output
|
|
112
|
-
|
|
113
|
-
@skip_if_not_linux
|
|
114
|
-
def test_ctype_toupper_loc(self):
|
|
115
|
-
"""
|
|
116
|
-
test_ctype_locale.test_ctype_toupper_loc
|
|
117
|
-
|
|
118
|
-
int32_t * * __ctype_toupper_loc(void);
|
|
119
|
-
|
|
120
|
-
Description:
|
|
121
|
-
The __ctype_toupper_loc() function shall return a pointer into an array of
|
|
122
|
-
characters in the current locale that contains upper case equivalents for
|
|
123
|
-
each character in the current character set. The array shall contain a total
|
|
124
|
-
of 384 characters, and can be indexed with any signed or unsigned char (i.e.
|
|
125
|
-
with an index value between -128 and 255). If the application is
|
|
126
|
-
multithreaded, the array shall be local to the current thread.
|
|
127
|
-
|
|
128
|
-
This interface is not in the source standard; it is only in the binary
|
|
129
|
-
standard.
|
|
130
|
-
|
|
131
|
-
Return Value:
|
|
132
|
-
The __ctype_toupper_loc() function shall return a pointer to the array of
|
|
133
|
-
characters to be used for the ctype() family of functions (see <ctype.h>).
|
|
134
|
-
"""
|
|
135
|
-
|
|
136
|
-
# Just load a binary so that we can do the initialization steps from
|
|
137
|
-
# libc_start_main
|
|
138
|
-
bin_path = os.path.join(test_location, "x86_64", "ctype_toupper_loc")
|
|
139
|
-
|
|
140
|
-
def ctype_toupper_loc(state, arguments):
|
|
141
|
-
return angr.SIM_PROCEDURES["glibc"]["__ctype_toupper_loc"]().execute(state, arguments=arguments)
|
|
142
|
-
|
|
143
|
-
b = angr.Project(bin_path, auto_load_libs=False)
|
|
144
|
-
p = b.factory.full_init_state()
|
|
145
|
-
pg = b.factory.simulation_manager(p)
|
|
146
|
-
|
|
147
|
-
# Find main located at 0x400596 to let libc_start_main do its thing
|
|
148
|
-
main = pg.explore(find=0x400596)
|
|
149
|
-
|
|
150
|
-
state = main.found[0]
|
|
151
|
-
toupper_loc_array_ptr = ctype_toupper_loc(state, []).ret_expr
|
|
152
|
-
table_ptr = state.memory.load(toupper_loc_array_ptr, state.arch.bytes, endness=state.arch.memory_endness)
|
|
153
|
-
|
|
154
|
-
result = b""
|
|
155
|
-
for i in range(-128, 256):
|
|
156
|
-
result += b"%d->0x%x\n" % (i, state.mem[table_ptr + i * 4].int.unsigned.concrete)
|
|
157
|
-
|
|
158
|
-
# Check output of compiled C program that uses ctype_toupper_loc()
|
|
159
|
-
output = subprocess.check_output(bin_path, shell=True)
|
|
160
|
-
assert result == output
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if __name__ == "__main__":
|
|
164
|
-
unittest.main()
|
|
File without changes
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.procedures.libc" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import unittest
|
|
7
|
-
|
|
8
|
-
import angr
|
|
9
|
-
|
|
10
|
-
from ...common import bin_location
|
|
11
|
-
|
|
12
|
-
TARGET_APP = os.path.join(bin_location, "tests", "x86_64", "fgets")
|
|
13
|
-
|
|
14
|
-
p = angr.Project(TARGET_APP, auto_load_libs=False)
|
|
15
|
-
|
|
16
|
-
find_normal = p.loader.find_symbol("find_normal").rebased_addr
|
|
17
|
-
find_exact = p.loader.find_symbol("find_exact").rebased_addr
|
|
18
|
-
find_eof = p.loader.find_symbol("find_eof").rebased_addr
|
|
19
|
-
find_impossible = p.loader.find_symbol("find_impossible").rebased_addr
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class TestFgets(unittest.TestCase):
|
|
23
|
-
def _testfind(self, addr, failmsg):
|
|
24
|
-
e = p.factory.entry_state()
|
|
25
|
-
e.options.add(angr.sim_options.SHORT_READS)
|
|
26
|
-
e.options.add(angr.sim_options.SYMBOL_FILL_UNCONSTRAINED_MEMORY)
|
|
27
|
-
s = p.factory.simgr(e)
|
|
28
|
-
r = s.explore(find=addr)
|
|
29
|
-
assert len(r.found) > 0, failmsg
|
|
30
|
-
return r.found[0].posix.dumps(0)
|
|
31
|
-
|
|
32
|
-
def _testnotfind(self, addr, failmsg):
|
|
33
|
-
e = p.factory.entry_state()
|
|
34
|
-
e.options.add(angr.sim_options.SHORT_READS)
|
|
35
|
-
e.options.add(angr.sim_options.SYMBOL_FILL_UNCONSTRAINED_MEMORY)
|
|
36
|
-
s = p.factory.simgr(e)
|
|
37
|
-
r = s.explore(find=addr)
|
|
38
|
-
assert len(r.found) == 0, failmsg
|
|
39
|
-
|
|
40
|
-
def test_normal(self):
|
|
41
|
-
answer = self._testfind(find_normal, "Normal Failure!")
|
|
42
|
-
assert answer == b"normal\n"
|
|
43
|
-
|
|
44
|
-
def test_exact(self):
|
|
45
|
-
answer = self._testfind(find_exact, "Exact Failure!")
|
|
46
|
-
assert answer.endswith(b"0123456789")
|
|
47
|
-
|
|
48
|
-
def test_impossible(self):
|
|
49
|
-
self._testnotfind(find_impossible, "Impossible Failure!")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if __name__ == "__main__":
|
|
53
|
-
unittest.main()
|