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/engines/vex/test_vex.py
DELETED
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,no-self-use,line-too-long
|
|
3
|
-
|
|
4
|
-
import logging
|
|
5
|
-
import unittest
|
|
6
|
-
|
|
7
|
-
import pyvex
|
|
8
|
-
import claripy
|
|
9
|
-
|
|
10
|
-
from angr import SimState, load_shellcode
|
|
11
|
-
from angr.engines import HeavyVEXMixin
|
|
12
|
-
import angr.engines.vex.claripy.ccall as s_ccall
|
|
13
|
-
|
|
14
|
-
l = logging.getLogger(__name__)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TestVex(unittest.TestCase):
|
|
18
|
-
def test_ccall(self):
|
|
19
|
-
s = SimState(arch="AMD64")
|
|
20
|
-
|
|
21
|
-
l.debug("Testing amd64_actions_ADD")
|
|
22
|
-
l.debug("(8-bit) 1 + 1...")
|
|
23
|
-
arg_l = s.solver.BVV(1, 8)
|
|
24
|
-
arg_r = s.solver.BVV(1, 8)
|
|
25
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADD(s, 8, arg_l, arg_r, 0, platform="AMD64")
|
|
26
|
-
assert s.solver.is_true(cf == 0)
|
|
27
|
-
assert s.solver.is_true(pf == 0)
|
|
28
|
-
assert s.solver.is_true(af == 0)
|
|
29
|
-
assert s.solver.is_true(zf == 0)
|
|
30
|
-
assert s.solver.is_true(sf == 0)
|
|
31
|
-
assert s.solver.is_true(of == 0)
|
|
32
|
-
|
|
33
|
-
l.debug("(32-bit) (-1) + (-2)...")
|
|
34
|
-
arg_l = s.solver.BVV(-1, 32)
|
|
35
|
-
arg_r = s.solver.BVV(-1, 32)
|
|
36
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADD(s, 32, arg_l, arg_r, 0, platform="AMD64")
|
|
37
|
-
assert s.solver.is_true(cf == 1)
|
|
38
|
-
assert s.solver.is_true(pf == 0)
|
|
39
|
-
assert s.solver.is_true(af == 1)
|
|
40
|
-
assert s.solver.is_true(zf == 0)
|
|
41
|
-
assert s.solver.is_true(sf == 1)
|
|
42
|
-
assert s.solver.is_true(of == 0)
|
|
43
|
-
|
|
44
|
-
l.debug("Testing pc_actions_SUB")
|
|
45
|
-
l.debug(
|
|
46
|
-
"(8-bit) 1 - 1...",
|
|
47
|
-
)
|
|
48
|
-
arg_l = s.solver.BVV(1, 8)
|
|
49
|
-
arg_r = s.solver.BVV(1, 8)
|
|
50
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_SUB(s, 8, arg_l, arg_r, 0, platform="AMD64")
|
|
51
|
-
assert s.solver.is_true(cf == 0)
|
|
52
|
-
assert s.solver.is_true(pf == 1)
|
|
53
|
-
assert s.solver.is_true(af == 0)
|
|
54
|
-
assert s.solver.is_true(zf == 1)
|
|
55
|
-
assert s.solver.is_true(sf == 0)
|
|
56
|
-
assert s.solver.is_true(of == 0)
|
|
57
|
-
|
|
58
|
-
l.debug("(32-bit) (-1) - (-2)...")
|
|
59
|
-
arg_l = s.solver.BVV(-1, 32)
|
|
60
|
-
arg_r = s.solver.BVV(-2, 32)
|
|
61
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_SUB(s, 32, arg_l, arg_r, 0, platform="AMD64")
|
|
62
|
-
assert s.solver.is_true(cf == 0)
|
|
63
|
-
assert s.solver.is_true(pf == 0)
|
|
64
|
-
assert s.solver.is_true(af == 0)
|
|
65
|
-
assert s.solver.is_true(zf == 0)
|
|
66
|
-
assert s.solver.is_true(sf == 0)
|
|
67
|
-
assert s.solver.is_true(of == 0)
|
|
68
|
-
|
|
69
|
-
l.debug("Testing pc_actions_ROL")
|
|
70
|
-
l.debug("(8-bit) ROL 1 1...")
|
|
71
|
-
result = s.solver.BVV(2, 8) # the result of rol(1, 1)
|
|
72
|
-
oldflags = s.solver.BVV(0, 8)
|
|
73
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROL(s, 8, result, None, oldflags, platform="AMD64")
|
|
74
|
-
assert s.solver.is_true(cf == 0)
|
|
75
|
-
assert s.solver.is_true(pf == 0)
|
|
76
|
-
assert s.solver.is_true(af == 0)
|
|
77
|
-
assert s.solver.is_true(zf == 0)
|
|
78
|
-
assert s.solver.is_true(sf == 0)
|
|
79
|
-
assert s.solver.is_true(of == 0)
|
|
80
|
-
|
|
81
|
-
l.debug("(32-bit) ROL (-1) (-2)... (shift out of range)")
|
|
82
|
-
result = s.solver.BVV(-1, 32) # the result of rol(-1, 0xfe)
|
|
83
|
-
oldflags = s.solver.BVV(0, 32)
|
|
84
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROL(s, 32, result, None, oldflags, platform="AMD64")
|
|
85
|
-
assert s.solver.is_true(cf == 1)
|
|
86
|
-
assert s.solver.is_true(pf == 0)
|
|
87
|
-
assert s.solver.is_true(af == 0)
|
|
88
|
-
assert s.solver.is_true(zf == 0)
|
|
89
|
-
assert s.solver.is_true(sf == 0)
|
|
90
|
-
assert s.solver.is_true(of == 0)
|
|
91
|
-
|
|
92
|
-
l.debug("Testing pc_actions_ROR")
|
|
93
|
-
l.debug("(32-bit) ROR 2 1...")
|
|
94
|
-
result = s.solver.BVV(1, 32) # the result of ror(2, 1)
|
|
95
|
-
oldflags = s.solver.BVV(0, 8)
|
|
96
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROR(s, 32, result, None, oldflags, platform="AMD64")
|
|
97
|
-
assert s.solver.is_true(cf == 0)
|
|
98
|
-
assert s.solver.is_true(pf == 0)
|
|
99
|
-
assert s.solver.is_true(af == 0)
|
|
100
|
-
assert s.solver.is_true(zf == 0)
|
|
101
|
-
assert s.solver.is_true(sf == 0)
|
|
102
|
-
assert s.solver.is_true(of == 0)
|
|
103
|
-
|
|
104
|
-
l.debug("Testing pc_actions_ROR")
|
|
105
|
-
l.debug("(32-bit) ROR 1 1...")
|
|
106
|
-
result = s.solver.BVV(0x80000000, 32) # the result of ror(1, 1)
|
|
107
|
-
oldflags = s.solver.BVV(0, 8)
|
|
108
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROR(s, 32, result, None, oldflags, platform="AMD64")
|
|
109
|
-
assert s.solver.is_true(cf == 1)
|
|
110
|
-
assert s.solver.is_true(pf == 0)
|
|
111
|
-
assert s.solver.is_true(af == 0)
|
|
112
|
-
assert s.solver.is_true(zf == 0)
|
|
113
|
-
assert s.solver.is_true(sf == 0)
|
|
114
|
-
assert s.solver.is_true(of == 1)
|
|
115
|
-
|
|
116
|
-
l.debug("Testing pc_actions_ROR")
|
|
117
|
-
l.debug("(32-bit) ROR -1 1...")
|
|
118
|
-
result = s.solver.BVV(-1, 32) # the result of ror(0xffffffff, 1)
|
|
119
|
-
oldflags = s.solver.BVV(0, 32)
|
|
120
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROR(s, 32, result, None, oldflags, platform="AMD64")
|
|
121
|
-
assert s.solver.is_true(cf == 1)
|
|
122
|
-
assert s.solver.is_true(pf == 0)
|
|
123
|
-
assert s.solver.is_true(af == 0)
|
|
124
|
-
assert s.solver.is_true(zf == 0)
|
|
125
|
-
assert s.solver.is_true(sf == 0)
|
|
126
|
-
assert s.solver.is_true(of == 0)
|
|
127
|
-
|
|
128
|
-
l.debug("(32-bit) ROR (-1) (-2)... (shift out of range)")
|
|
129
|
-
result = s.solver.BVV(-1, 32) # the result of ror(0xffffffff, 0xfe)
|
|
130
|
-
oldflags = s.solver.BVV(0, 32)
|
|
131
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ROR(s, 32, result, None, oldflags, platform="AMD64")
|
|
132
|
-
assert s.solver.is_true(cf == 1)
|
|
133
|
-
assert s.solver.is_true(pf == 0)
|
|
134
|
-
assert s.solver.is_true(af == 0)
|
|
135
|
-
assert s.solver.is_true(zf == 0)
|
|
136
|
-
assert s.solver.is_true(sf == 0)
|
|
137
|
-
assert s.solver.is_true(of == 0)
|
|
138
|
-
|
|
139
|
-
l.debug("Testing pc_actions_SHR")
|
|
140
|
-
l.debug("(64-bit) SHR 0xffffffffffffffff 1")
|
|
141
|
-
result = s.solver.BVV(0x7FFFFFFFFFFFFFFF, 64)
|
|
142
|
-
subshifted_result = s.solver.BVV(0xFFFFFFFFFFFFFFFF, 64)
|
|
143
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_SHR(s, 64, result, subshifted_result, None, platform="AMD64")
|
|
144
|
-
assert s.solver.is_true(cf == 1)
|
|
145
|
-
assert s.solver.is_true(pf == 1)
|
|
146
|
-
assert s.solver.is_true(af == 0)
|
|
147
|
-
assert s.solver.is_true(zf == 0)
|
|
148
|
-
assert s.solver.is_true(sf == 0)
|
|
149
|
-
assert s.solver.is_true(of == 1)
|
|
150
|
-
|
|
151
|
-
l.debug("Testing amd64_actions_ADCX")
|
|
152
|
-
|
|
153
|
-
l.debug("(ADCX, 32-bit) 0xffffffff + 1...")
|
|
154
|
-
arg_l = s.solver.BVV(0xFFFFFFFF, 32)
|
|
155
|
-
arg_r = s.solver.BVV(1, 32)
|
|
156
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADCX(
|
|
157
|
-
s, 32, arg_l, arg_r, s.solver.BVV(0, 32), True, platform="AMD64"
|
|
158
|
-
)
|
|
159
|
-
assert s.solver.is_true(cf == 1)
|
|
160
|
-
assert s.solver.is_true(of == 0)
|
|
161
|
-
|
|
162
|
-
l.debug("(ADOX, 32-bit) 0xffffffff + 1...")
|
|
163
|
-
arg_l = s.solver.BVV(0xFFFFFFFF, 32)
|
|
164
|
-
arg_r = s.solver.BVV(1, 32)
|
|
165
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADCX(
|
|
166
|
-
s, 32, arg_l, arg_r, s.solver.BVV(0, 32), False, platform="AMD64"
|
|
167
|
-
)
|
|
168
|
-
assert s.solver.is_true(cf == 0)
|
|
169
|
-
assert s.solver.is_true(of == 1)
|
|
170
|
-
|
|
171
|
-
l.debug("(ADCX, 64-bit) 0xffffffffffffffff + 1...")
|
|
172
|
-
arg_l = s.solver.BVV(0xFFFFFFFFFFFFFFFF, 64)
|
|
173
|
-
arg_r = s.solver.BVV(1, 64)
|
|
174
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADCX(
|
|
175
|
-
s, 64, arg_l, arg_r, s.solver.BVV(0, 64), True, platform="AMD64"
|
|
176
|
-
)
|
|
177
|
-
assert s.solver.is_true(cf == 1)
|
|
178
|
-
assert s.solver.is_true(of == 0)
|
|
179
|
-
|
|
180
|
-
l.debug("(ADOX, 64-bit) 0xffffffffffffffff + 1...")
|
|
181
|
-
arg_l = s.solver.BVV(0xFFFFFFFFFFFFFFFF, 64)
|
|
182
|
-
arg_r = s.solver.BVV(1, 64)
|
|
183
|
-
cf, pf, af, zf, sf, of = s_ccall.pc_actions_ADCX(
|
|
184
|
-
s, 64, arg_l, arg_r, s.solver.BVV(0, 64), False, platform="AMD64"
|
|
185
|
-
)
|
|
186
|
-
assert s.solver.is_true(cf == 0)
|
|
187
|
-
assert s.solver.is_true(of == 1)
|
|
188
|
-
|
|
189
|
-
def test_aarch64_32bit_ccalls(self):
|
|
190
|
-
# GitHub issue #1238
|
|
191
|
-
s = SimState(arch="AArch64")
|
|
192
|
-
|
|
193
|
-
x = s.solver.BVS("x", 32)
|
|
194
|
-
# A normal operation
|
|
195
|
-
flag_z = s_ccall.arm64g_calculate_flag_z(s, s_ccall.ARM64G_CC_OP_ADD32, x, s.solver.BVV(1, 32), 0)
|
|
196
|
-
assert s.satisfiable(extra_constraints=(flag_z == 0,))
|
|
197
|
-
assert s.satisfiable(extra_constraints=(flag_z == 1,))
|
|
198
|
-
# What VEX does
|
|
199
|
-
flag_z = s_ccall.arm64g_calculate_flag_z(
|
|
200
|
-
s, s_ccall.ARM64G_CC_OP_ADD32, x.zero_extend(32), s.solver.BVV(1, 64), 0
|
|
201
|
-
)
|
|
202
|
-
assert s.satisfiable(extra_constraints=(flag_z == 0,))
|
|
203
|
-
assert s.satisfiable(extra_constraints=(flag_z == 1,))
|
|
204
|
-
|
|
205
|
-
def test_some_vector_ops(self):
|
|
206
|
-
engine = HeavyVEXMixin(None)
|
|
207
|
-
s = SimState(arch="AMD64")
|
|
208
|
-
|
|
209
|
-
def translate(state, op, args): # pylint:disable=unused-argument
|
|
210
|
-
return engine._perform_vex_expr_Op(op, args)
|
|
211
|
-
|
|
212
|
-
a = s.solver.BVV(0xFFFF0000000100020003000400050006, 128)
|
|
213
|
-
b = s.solver.BVV(0x00020002000200020002000200020002, 128)
|
|
214
|
-
|
|
215
|
-
calc_result = translate(s, "Iop_Sub16x8", (a, b))
|
|
216
|
-
correct_result = s.solver.BVV(0xFFFDFFFEFFFF00000001000200030004, 128)
|
|
217
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
218
|
-
|
|
219
|
-
calc_result = translate(s, "Iop_CmpEQ16x8", (a, b))
|
|
220
|
-
correct_result = s.solver.BVV(0x000000000000FFFF0000000000000000, 128)
|
|
221
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
222
|
-
|
|
223
|
-
calc_result = translate(s, "Iop_CmpEQ8x16", (a, b))
|
|
224
|
-
correct_result = s.solver.BVV(0x0000FF00FF00FFFFFF00FF00FF00FF00, 128)
|
|
225
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
226
|
-
|
|
227
|
-
calc_result = translate(s, "Iop_CmpGT16Sx8", (a, b))
|
|
228
|
-
correct_result = s.solver.BVV(0x0000000000000000FFFFFFFFFFFFFFFF, 128)
|
|
229
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
230
|
-
|
|
231
|
-
calc_result = translate(s, "Iop_CmpGT16Ux8", (a, b))
|
|
232
|
-
correct_result = s.solver.BVV(0xFFFF000000000000FFFFFFFFFFFFFFFF, 128)
|
|
233
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
234
|
-
|
|
235
|
-
calc_result = translate(s, "Iop_InterleaveLO16x8", (a, b))
|
|
236
|
-
correct_result = s.solver.BVV(0x00030002000400020005000200060002, 128)
|
|
237
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
238
|
-
|
|
239
|
-
calc_result = translate(s, "Iop_InterleaveLO8x16", (a, b))
|
|
240
|
-
correct_result = s.solver.BVV(0x00000302000004020000050200000602, 128)
|
|
241
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
242
|
-
|
|
243
|
-
calc_result = translate(s, "Iop_Min8Ux16", (a, b))
|
|
244
|
-
correct_result = s.solver.BVV(0x00020000000100020002000200020002, 128)
|
|
245
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
246
|
-
|
|
247
|
-
calc_result = translate(s, "Iop_Min8Sx16", (a, b))
|
|
248
|
-
correct_result = s.solver.BVV(0xFFFF0000000100020002000200020002, 128)
|
|
249
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
250
|
-
|
|
251
|
-
calc_result = translate(s, "Iop_QNarrowBin16Sto8Ux16", (a, b))
|
|
252
|
-
correct_result = s.solver.BVV(0x00000102030405060202020202020202, 128)
|
|
253
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
254
|
-
|
|
255
|
-
c = s.solver.BVV(0xFF008877, 32)
|
|
256
|
-
d = s.solver.BVV(0x11111111, 32)
|
|
257
|
-
|
|
258
|
-
calc_result = translate(s, "Iop_HAdd8Sx4", (c, d))
|
|
259
|
-
correct_result = s.solver.BVV(0x0808CC44, 32)
|
|
260
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
261
|
-
|
|
262
|
-
calc_result = translate(s, "Iop_QAdd8Sx4", (c, d))
|
|
263
|
-
correct_result = s.solver.BVV(0x1011997F, 32)
|
|
264
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
265
|
-
|
|
266
|
-
calc_result = translate(s, "Iop_QAdd8Ux4", (c, d))
|
|
267
|
-
correct_result = s.solver.BVV(0xFF119988, 32)
|
|
268
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
269
|
-
|
|
270
|
-
calc_result = translate(s, "Iop_QSub8Sx4", (c, d))
|
|
271
|
-
correct_result = s.solver.BVV(0xEEEF8066, 32)
|
|
272
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
273
|
-
|
|
274
|
-
calc_result = translate(s, "Iop_QSub8Ux4", (c, d))
|
|
275
|
-
correct_result = s.solver.BVV(0xEE007766, 32)
|
|
276
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
277
|
-
|
|
278
|
-
e = s.solver.BVV(0xFF00887766554433, 64)
|
|
279
|
-
f = s.solver.BVV(0x0202000200020002, 64)
|
|
280
|
-
|
|
281
|
-
calc_result = translate(s, "Iop_QNarrowBin16Sto8Ux8", (e, f))
|
|
282
|
-
correct_result = s.solver.BVV(0x0000FFFFFF020202, 64)
|
|
283
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
284
|
-
|
|
285
|
-
gg = claripy.BVV(0x111111112222222233333333FFFFFFFF, 128)
|
|
286
|
-
h = claripy.BVV(0x1111111100000000FFFFFFFFFFFFFFFF, 128)
|
|
287
|
-
|
|
288
|
-
calc_result = translate(s, "Iop_CmpEQ32Fx4", (gg, h))
|
|
289
|
-
correct_result = claripy.BVV(0xFFFFFFFF000000000000000000000000, 128)
|
|
290
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
291
|
-
|
|
292
|
-
calc_result = translate(s, "Iop_Clz32x4", (gg,))
|
|
293
|
-
correct_result = claripy.BVV(0x00000003000000020000000200000000, 128)
|
|
294
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
295
|
-
|
|
296
|
-
i = claripy.BVV(0x1001000000001000, 64)
|
|
297
|
-
j = claripy.BVV(0x100000000000F000, 64)
|
|
298
|
-
|
|
299
|
-
calc_result = translate(s, "Iop_Mull16Sx4", (i, j))
|
|
300
|
-
correct_result = claripy.BVV(0x10010000000000000000000FF000000, 128)
|
|
301
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
302
|
-
|
|
303
|
-
calc_result = translate(s, "Iop_Mull16Ux4", (i, j))
|
|
304
|
-
correct_result = claripy.BVV(0x100100000000000000000000F000000, 128)
|
|
305
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
306
|
-
|
|
307
|
-
k = claripy.BVV(0xE7, 8)
|
|
308
|
-
ll = claripy.BVV(0x1234, 16)
|
|
309
|
-
m = claripy.BVV(0x12345678, 32)
|
|
310
|
-
|
|
311
|
-
calc_result = translate(s, "Iop_Dup8x8", (k,))
|
|
312
|
-
correct_result = claripy.BVV(0xE7E7E7E7E7E7E7E7, 64)
|
|
313
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
314
|
-
|
|
315
|
-
calc_result = translate(s, "Iop_Dup8x16", (k,))
|
|
316
|
-
correct_result = claripy.BVV(0xE7E7E7E7E7E7E7E7E7E7E7E7E7E7E7E7, 128)
|
|
317
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
318
|
-
|
|
319
|
-
calc_result = translate(s, "Iop_Dup16x4", (ll,))
|
|
320
|
-
correct_result = claripy.BVV(0x1234123412341234, 64)
|
|
321
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
322
|
-
|
|
323
|
-
calc_result = translate(s, "Iop_Dup16x8", (ll,))
|
|
324
|
-
correct_result = claripy.BVV(0x12341234123412341234123412341234, 128)
|
|
325
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
326
|
-
|
|
327
|
-
calc_result = translate(s, "Iop_Dup32x2", (m,))
|
|
328
|
-
correct_result = claripy.BVV(0x1234567812345678, 64)
|
|
329
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
330
|
-
|
|
331
|
-
calc_result = translate(s, "Iop_Dup32x4", (m,))
|
|
332
|
-
correct_result = claripy.BVV(0x12345678123456781234567812345678, 128)
|
|
333
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
334
|
-
|
|
335
|
-
n = claripy.BVV(0x0123456789ABCDEF, 64)
|
|
336
|
-
o = claripy.BVV(0xAF, 8)
|
|
337
|
-
p = claripy.BVV(0xDFEC, 16)
|
|
338
|
-
q = claripy.BVV(0xBFCFDFEF, 32)
|
|
339
|
-
r = claripy.BVV(0x0102030405060708, 64)
|
|
340
|
-
ss = claripy.BVS("index", 8)
|
|
341
|
-
|
|
342
|
-
# According to the source code of LibVex, the index is a U8 constant
|
|
343
|
-
calc_result = translate(s, "Iop_GetElem8x8", (n, claripy.BVV(0, 8)))
|
|
344
|
-
correct_result = claripy.BVV(0xEF, 8)
|
|
345
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
346
|
-
|
|
347
|
-
calc_result = translate(s, "Iop_GetElem8x8", (n, claripy.BVV(1, 8)))
|
|
348
|
-
correct_result = claripy.BVV(0xCD, 8)
|
|
349
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
350
|
-
|
|
351
|
-
calc_result = translate(s, "Iop_GetElem8x8", (n, claripy.BVV(6, 8)))
|
|
352
|
-
correct_result = claripy.BVV(0x23, 8)
|
|
353
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
354
|
-
|
|
355
|
-
calc_result = translate(s, "Iop_GetElem8x8", (n, claripy.BVV(7, 8)))
|
|
356
|
-
correct_result = claripy.BVV(0x01, 8)
|
|
357
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
358
|
-
|
|
359
|
-
calc_result = translate(s, "Iop_GetElem16x4", (n, claripy.BVV(0, 8)))
|
|
360
|
-
correct_result = claripy.BVV(0xCDEF, 16)
|
|
361
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
362
|
-
|
|
363
|
-
calc_result = translate(s, "Iop_GetElem16x4", (n, claripy.BVV(3, 8)))
|
|
364
|
-
correct_result = claripy.BVV(0x0123, 16)
|
|
365
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
366
|
-
|
|
367
|
-
calc_result = translate(s, "Iop_GetElem32x2", (n, claripy.BVV(0, 8)))
|
|
368
|
-
correct_result = claripy.BVV(0x89ABCDEF, 32)
|
|
369
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
370
|
-
|
|
371
|
-
calc_result = translate(s, "Iop_GetElem32x2", (n, claripy.BVV(1, 8)))
|
|
372
|
-
correct_result = claripy.BVV(0x01234567, 32)
|
|
373
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
374
|
-
|
|
375
|
-
calc_result = translate(s, "Iop_SetElem8x8", (n, claripy.BVV(0, 8), o))
|
|
376
|
-
correct_result = claripy.BVV(0x0123456789ABCDAF, 64)
|
|
377
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
378
|
-
|
|
379
|
-
calc_result = translate(s, "Iop_SetElem8x8", (n, claripy.BVV(1, 8), o))
|
|
380
|
-
correct_result = claripy.BVV(0x0123456789ABAFEF, 64)
|
|
381
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
382
|
-
|
|
383
|
-
calc_result = translate(s, "Iop_SetElem8x8", (n, claripy.BVV(6, 8), o))
|
|
384
|
-
correct_result = claripy.BVV(0x01AF456789ABCDEF, 64)
|
|
385
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
386
|
-
|
|
387
|
-
calc_result = translate(s, "Iop_SetElem8x8", (n, claripy.BVV(7, 8), o))
|
|
388
|
-
correct_result = claripy.BVV(0xAF23456789ABCDEF, 64)
|
|
389
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
390
|
-
|
|
391
|
-
calc_result = translate(s, "Iop_SetElem16x4", (n, claripy.BVV(0, 8), p))
|
|
392
|
-
correct_result = claripy.BVV(0x0123456789ABDFEC, 64)
|
|
393
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
394
|
-
|
|
395
|
-
calc_result = translate(s, "Iop_SetElem16x4", (n, claripy.BVV(3, 8), p))
|
|
396
|
-
correct_result = claripy.BVV(0xDFEC456789ABCDEF, 64)
|
|
397
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
398
|
-
|
|
399
|
-
calc_result = translate(s, "Iop_SetElem32x2", (n, claripy.BVV(0, 8), q))
|
|
400
|
-
correct_result = claripy.BVV(0x01234567BFCFDFEF, 64)
|
|
401
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
402
|
-
|
|
403
|
-
calc_result = translate(s, "Iop_SetElem32x2", (n, claripy.BVV(1, 8), q))
|
|
404
|
-
correct_result = claripy.BVV(0xBFCFDFEF89ABCDEF, 64)
|
|
405
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
406
|
-
|
|
407
|
-
# Symbolic indexes
|
|
408
|
-
calc_result = translate(ss, "Iop_GetElem8x8", (r, ss))
|
|
409
|
-
correct_result = claripy.If(
|
|
410
|
-
ss == 7,
|
|
411
|
-
claripy.BVV(0x01, 8),
|
|
412
|
-
claripy.If(
|
|
413
|
-
ss == 6,
|
|
414
|
-
claripy.BVV(0x02, 8),
|
|
415
|
-
claripy.If(
|
|
416
|
-
ss == 5,
|
|
417
|
-
claripy.BVV(0x03, 8),
|
|
418
|
-
claripy.If(
|
|
419
|
-
ss == 4,
|
|
420
|
-
claripy.BVV(0x04, 8),
|
|
421
|
-
claripy.If(
|
|
422
|
-
ss == 3,
|
|
423
|
-
claripy.BVV(0x05, 8),
|
|
424
|
-
claripy.If(
|
|
425
|
-
ss == 2,
|
|
426
|
-
claripy.BVV(0x06, 8),
|
|
427
|
-
claripy.If(ss == 1, claripy.BVV(0x07, 8), claripy.BVV(0x08, 8)),
|
|
428
|
-
),
|
|
429
|
-
),
|
|
430
|
-
),
|
|
431
|
-
),
|
|
432
|
-
),
|
|
433
|
-
)
|
|
434
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
435
|
-
|
|
436
|
-
calc_result = translate(s, "Iop_GetElem16x4", (r, ss))
|
|
437
|
-
correct_result = claripy.If(
|
|
438
|
-
ss == 3,
|
|
439
|
-
claripy.BVV(0x0102, 16),
|
|
440
|
-
claripy.If(
|
|
441
|
-
ss == 2,
|
|
442
|
-
claripy.BVV(0x0304, 16),
|
|
443
|
-
claripy.If(ss == 1, claripy.BVV(0x0506, 16), claripy.BVV(0x0708, 16)),
|
|
444
|
-
),
|
|
445
|
-
)
|
|
446
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
447
|
-
|
|
448
|
-
calc_result = translate(s, "Iop_GetElem32x2", (r, ss))
|
|
449
|
-
correct_result = claripy.If(ss == 1, claripy.BVV(0x01020304, 32), claripy.BVV(0x05060708, 32))
|
|
450
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
451
|
-
|
|
452
|
-
r_slices = r.chop(8)
|
|
453
|
-
calc_result = translate(s, "Iop_SetElem8x8", (r, ss, o))
|
|
454
|
-
correct_result = claripy.Concat(
|
|
455
|
-
claripy.If(ss == 7, o, r_slices[0]),
|
|
456
|
-
claripy.If(ss == 6, o, r_slices[1]),
|
|
457
|
-
claripy.If(ss == 5, o, r_slices[2]),
|
|
458
|
-
claripy.If(ss == 4, o, r_slices[3]),
|
|
459
|
-
claripy.If(ss == 3, o, r_slices[4]),
|
|
460
|
-
claripy.If(ss == 2, o, r_slices[5]),
|
|
461
|
-
claripy.If(ss == 1, o, r_slices[6]),
|
|
462
|
-
claripy.If(ss == 0, o, r_slices[7]),
|
|
463
|
-
)
|
|
464
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
465
|
-
|
|
466
|
-
r_slices = r.chop(16)
|
|
467
|
-
calc_result = translate(s, "Iop_SetElem16x4", (r, ss, p))
|
|
468
|
-
correct_result = claripy.Concat(
|
|
469
|
-
claripy.If(ss == 3, p, r_slices[0]),
|
|
470
|
-
claripy.If(ss == 2, p, r_slices[1]),
|
|
471
|
-
claripy.If(ss == 1, p, r_slices[2]),
|
|
472
|
-
claripy.If(ss == 0, p, r_slices[3]),
|
|
473
|
-
)
|
|
474
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
475
|
-
|
|
476
|
-
r_slices = r.chop(32)
|
|
477
|
-
calc_result = translate(s, "Iop_SetElem32x2", (r, ss, q))
|
|
478
|
-
correct_result = claripy.Concat(
|
|
479
|
-
claripy.If(ss == 1, q, r_slices[0]),
|
|
480
|
-
claripy.If(ss == 0, q, r_slices[1]),
|
|
481
|
-
)
|
|
482
|
-
assert s.solver.is_true(calc_result == correct_result)
|
|
483
|
-
|
|
484
|
-
def test_store_simplification(self):
|
|
485
|
-
state = SimState(arch="X86")
|
|
486
|
-
state.regs.esp = state.solver.BVS("stack_pointer", 32)
|
|
487
|
-
state.regs.ebp = state.solver.BVS("base_pointer", 32)
|
|
488
|
-
state.regs.eax = state.solver.BVS("base_eax", 32)
|
|
489
|
-
|
|
490
|
-
irsb = pyvex.IRSB(b"PT]\xc2\x10\x00", 0x4000, state.arch)
|
|
491
|
-
sim_successors = HeavyVEXMixin(None).process(state.copy(), irsb=irsb)
|
|
492
|
-
exit_state = sim_successors.all_successors[0]
|
|
493
|
-
|
|
494
|
-
assert claripy.backends.z3.is_true(exit_state.regs.ebp == state.regs.esp - 4)
|
|
495
|
-
|
|
496
|
-
def test_loadg_no_constraint_creation(self):
|
|
497
|
-
state = SimState(arch="armel", mode="symbolic")
|
|
498
|
-
engine = HeavyVEXMixin(None)
|
|
499
|
-
|
|
500
|
-
stmt = pyvex.IRStmt.LoadG(
|
|
501
|
-
"Iend_LE",
|
|
502
|
-
"ILGop_16Uto32",
|
|
503
|
-
0, # dst
|
|
504
|
-
pyvex.IRExpr.Const(pyvex.const.U32(0x2000)), # addr (src)
|
|
505
|
-
pyvex.IRExpr.Const(pyvex.const.U32(0x1337)), # alt
|
|
506
|
-
pyvex.IRExpr.RdTmp(1), # guard
|
|
507
|
-
)
|
|
508
|
-
tyenv = pyvex.IRTypeEnv(state.arch)
|
|
509
|
-
tyenv.types = ["Ity_I32", "Ity_I32"]
|
|
510
|
-
state.scratch.set_tyenv(tyenv)
|
|
511
|
-
state.scratch.temps[1] = state.solver.BVS("tmp_1", 32)
|
|
512
|
-
engine.state = state
|
|
513
|
-
engine._handle_vex_stmt(stmt)
|
|
514
|
-
|
|
515
|
-
# LOADG should not create new constraints - it is a simple conditional memory read. The conditions should only
|
|
516
|
-
# be used inside the value AST to guard the memory read.
|
|
517
|
-
assert not state.solver.constraints
|
|
518
|
-
assert state.scratch.temps[0] is not None
|
|
519
|
-
assert state.scratch.temps[0].variables.issuperset(state.scratch.temps[1].variables)
|
|
520
|
-
assert state.scratch.temps[0].op == "If"
|
|
521
|
-
|
|
522
|
-
def test_amd64_ud012_behaviors(self):
|
|
523
|
-
# Test if VEX's lifter behaves as what CFGFast expects
|
|
524
|
-
#
|
|
525
|
-
# Note: if such behaviors change in the future, you also need to fix the ud{0,1,2} handling logic in
|
|
526
|
-
# CFGFast._generate_cfgnode().
|
|
527
|
-
|
|
528
|
-
# according to VEX, ud0 is not part of the block
|
|
529
|
-
a = load_shellcode(b"\x90\x90\x0f\xff", "amd64")
|
|
530
|
-
block_0 = a.factory.block(0)
|
|
531
|
-
assert block_0.size == 2
|
|
532
|
-
|
|
533
|
-
# according to VEX, ud1 is not part of the block
|
|
534
|
-
a = load_shellcode(b"\x90\x90\x0f\xb9", "amd64")
|
|
535
|
-
block_1 = a.factory.block(0)
|
|
536
|
-
assert block_1.size == 2
|
|
537
|
-
|
|
538
|
-
# according to VEX, ud2 under AMD64 *is* part of the block
|
|
539
|
-
a = load_shellcode(b"\x90\x90\x0f\x0b", "amd64")
|
|
540
|
-
block_2 = a.factory.block(0)
|
|
541
|
-
assert block_2.size == 4
|
|
542
|
-
|
|
543
|
-
def test_x86_ud2_behaviors(self):
|
|
544
|
-
# Test if VEX's lifter behaves as what CFGFast expects
|
|
545
|
-
#
|
|
546
|
-
# Note: if such behaviors change in the future, you also need to fix the ud2 handling logic in
|
|
547
|
-
# CFGFast._generate_cfgnode().
|
|
548
|
-
|
|
549
|
-
# according to VEX, ud2 on x86 is not part of the block
|
|
550
|
-
a = load_shellcode(b"\x90\x90\x0f\x0b", "x86")
|
|
551
|
-
block_0 = a.factory.block(0)
|
|
552
|
-
assert block_0.size == 2
|
|
553
|
-
|
|
554
|
-
def test_blsr(self):
|
|
555
|
-
p = load_shellcode(bytes.fromhex("c4e2f8f3cf0f95c00fb6c0c3"), arch="amd64")
|
|
556
|
-
# compiled form of !!(x & (x - 1))
|
|
557
|
-
# 2c0: c4 e2 f8 f3 cf blsr %rdi,%rax
|
|
558
|
-
|
|
559
|
-
# 2c5: 0f 95 c0 setne %al
|
|
560
|
-
# 2c8: 0f b6 c0 movzbl %al,%eax
|
|
561
|
-
# 2cb: c3 retq
|
|
562
|
-
x = claripy.BVS("x", 64)
|
|
563
|
-
s = p.factory.call_state(0, x)
|
|
564
|
-
sm = p.factory.simulation_manager(s)
|
|
565
|
-
sm.run()
|
|
566
|
-
|
|
567
|
-
target_func = claripy.If((x & (x - 1)) == 0, claripy.BVV(0, 64), 1)
|
|
568
|
-
solver = claripy.Solver()
|
|
569
|
-
solver.add(sm.one_deadended.regs.rax != target_func)
|
|
570
|
-
assert not solver.satisfiable()
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if __name__ == "__main__":
|
|
574
|
-
unittest.main()
|
|
File without changes
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
__package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
|
|
3
|
-
|
|
4
|
-
import tempfile
|
|
5
|
-
import os
|
|
6
|
-
import logging
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
|
|
11
|
-
from ..common import bin_location, broken
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
test_location = os.path.join(bin_location, "tests")
|
|
15
|
-
l = logging.getLogger("angr_tests.managers")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# pylint: disable=missing-class-docstring
|
|
19
|
-
# pylint: disable=no-self-use
|
|
20
|
-
class TestCacher(unittest.TestCase):
|
|
21
|
-
@broken
|
|
22
|
-
def test_cacher(self):
|
|
23
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), load_options={"auto_load_libs": False})
|
|
24
|
-
|
|
25
|
-
tmp_dir = tempfile.mkdtemp(prefix="test_cacher_container")
|
|
26
|
-
container = os.path.join(tmp_dir, "%s.cache" % os.path.basename(p.filename))
|
|
27
|
-
|
|
28
|
-
pg = p.factory.simulation_manager()
|
|
29
|
-
pg.use_technique(angr.exploration_techniques.Cacher(when=0x4006EE, container=container))
|
|
30
|
-
pg.run()
|
|
31
|
-
|
|
32
|
-
pg2 = p.factory.simulation_manager()
|
|
33
|
-
pg2.use_technique(angr.exploration_techniques.Cacher(container=container))
|
|
34
|
-
assert pg2.active[0].addr == 0x4006ED
|
|
35
|
-
|
|
36
|
-
pg2.run()
|
|
37
|
-
|
|
38
|
-
assert len(pg2.deadended) == len(pg.deadended)
|
|
39
|
-
assert pg2.deadended[0].addr in [s.addr for s in pg.deadended]
|
|
40
|
-
assert pg2.deadended[1].addr in [s.addr for s in pg.deadended]
|
|
41
|
-
assert pg2.deadended[2].addr in [s.addr for s in pg.deadended]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if __name__ == "__main__":
|
|
45
|
-
unittest.main()
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# pylint: disable=missing-class-docstring,disable=no-self-use
|
|
3
|
-
__package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import logging
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
import angr
|
|
10
|
-
from angr.sim_type import SimTypePointer, SimTypeChar
|
|
11
|
-
|
|
12
|
-
from ..common import bin_location
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
test_location = os.path.join(bin_location, "tests")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class TestDirector(unittest.TestCase):
|
|
19
|
-
def test_execute_address_brancher(self):
|
|
20
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "brancher"), load_options={"auto_load_libs": False})
|
|
21
|
-
|
|
22
|
-
pg = p.factory.simulation_manager()
|
|
23
|
-
|
|
24
|
-
# initialize the exploration technique
|
|
25
|
-
dm = angr.exploration_techniques.Director(num_fallback_states=1)
|
|
26
|
-
goal = angr.exploration_techniques.ExecuteAddressGoal(0x400594)
|
|
27
|
-
dm.add_goal(goal)
|
|
28
|
-
pg.use_technique(dm)
|
|
29
|
-
|
|
30
|
-
pg.explore(find=(0x4005B4,))
|
|
31
|
-
|
|
32
|
-
assert len(pg.deprioritized) > 0
|
|
33
|
-
|
|
34
|
-
def test_call_function_brancher(self):
|
|
35
|
-
class NonLocal:
|
|
36
|
-
the_state = None
|
|
37
|
-
the_goal = None
|
|
38
|
-
|
|
39
|
-
def goal_reached_callback(goal, p, pg): # pylint:disable=unused-argument
|
|
40
|
-
NonLocal.the_state = p
|
|
41
|
-
NonLocal.the_goal = goal
|
|
42
|
-
|
|
43
|
-
p = angr.Project(os.path.join(test_location, "x86_64", "brancher"), load_options={"auto_load_libs": False})
|
|
44
|
-
|
|
45
|
-
pg = p.factory.simulation_manager()
|
|
46
|
-
|
|
47
|
-
# initialize the exploration technique
|
|
48
|
-
dm = angr.exploration_techniques.Director(
|
|
49
|
-
cfg_keep_states=True, goal_satisfied_callback=goal_reached_callback, num_fallback_states=1
|
|
50
|
-
)
|
|
51
|
-
_ = p.analyses.CFG()
|
|
52
|
-
puts_func = p.kb.functions.function(name="puts")
|
|
53
|
-
goal = angr.exploration_techniques.CallFunctionGoal(puts_func, [(SimTypePointer(SimTypeChar()), ">=20")])
|
|
54
|
-
dm.add_goal(goal)
|
|
55
|
-
pg.use_technique(dm)
|
|
56
|
-
|
|
57
|
-
pg.explore(find=(0x40059E,))
|
|
58
|
-
|
|
59
|
-
assert len(pg.deprioritized) > 0
|
|
60
|
-
assert len(pg.found) > 0
|
|
61
|
-
assert NonLocal.the_state is not None
|
|
62
|
-
assert NonLocal.the_goal is goal
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if __name__ == "__main__":
|
|
66
|
-
logging.getLogger("angr.exploration_techniques.director").setLevel(logging.DEBUG)
|
|
67
|
-
unittest.main()
|