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.

Files changed (248) hide show
  1. angr/__init__.py +4 -1
  2. angr/analyses/decompiler/clinic.py +16 -0
  3. angr/analyses/decompiler/decompiler.py +3 -0
  4. angr/analyses/decompiler/optimization_passes/__init__.py +5 -0
  5. angr/analyses/decompiler/optimization_passes/cross_jump_reverter.py +108 -0
  6. angr/analyses/decompiler/optimization_passes/optimization_pass.py +17 -4
  7. angr/analyses/decompiler/optimization_passes/return_duplicator.py +4 -32
  8. angr/analyses/decompiler/structured_codegen/c.py +12 -2
  9. angr/analyses/decompiler/utils.py +13 -0
  10. angr/analyses/typehoon/dfa.py +108 -0
  11. angr/analyses/typehoon/lifter.py +34 -2
  12. angr/analyses/typehoon/simple_solver.py +1043 -503
  13. angr/analyses/typehoon/translator.py +13 -4
  14. angr/analyses/typehoon/typeconsts.py +117 -36
  15. angr/analyses/typehoon/typehoon.py +31 -11
  16. angr/analyses/typehoon/typevars.py +88 -21
  17. angr/analyses/typehoon/variance.py +10 -0
  18. angr/analyses/variable_recovery/engine_ail.py +28 -9
  19. angr/analyses/variable_recovery/engine_base.py +50 -43
  20. angr/analyses/variable_recovery/variable_recovery_base.py +16 -3
  21. angr/analyses/variable_recovery/variable_recovery_fast.py +14 -5
  22. angr/exploration_techniques/tracer.py +2 -0
  23. angr/misc/autoimport.py +26 -0
  24. angr/procedures/definitions/__init__.py +32 -3
  25. angr/utils/constants.py +1 -0
  26. angr/utils/graph.py +20 -1
  27. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/METADATA +7 -6
  28. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/RECORD +32 -244
  29. angr-9.2.89.dist-info/top_level.txt +1 -0
  30. angr/procedures/definitions/ntdll.py +0 -12
  31. angr-9.2.87.dist-info/top_level.txt +0 -2
  32. tests/__init__.py +0 -0
  33. tests/analyses/__init__.py +0 -0
  34. tests/analyses/cfg/__init__.py +0 -0
  35. tests/analyses/cfg/test_cfg_clflush.py +0 -43
  36. tests/analyses/cfg/test_cfg_get_any_node.py +0 -34
  37. tests/analyses/cfg/test_cfg_manager.py +0 -32
  38. tests/analyses/cfg/test_cfg_model.py +0 -55
  39. tests/analyses/cfg/test_cfg_patching.py +0 -378
  40. tests/analyses/cfg/test_cfg_rust_got_resolution.py +0 -36
  41. tests/analyses/cfg/test_cfg_thumb_firmware.py +0 -50
  42. tests/analyses/cfg/test_cfg_vex_postprocessor.py +0 -27
  43. tests/analyses/cfg/test_cfgemulated.py +0 -634
  44. tests/analyses/cfg/test_cfgfast.py +0 -1123
  45. tests/analyses/cfg/test_cfgfast_soot.py +0 -38
  46. tests/analyses/cfg/test_const_resolver.py +0 -38
  47. tests/analyses/cfg/test_iat_resolver.py +0 -37
  48. tests/analyses/cfg/test_jumptables.py +0 -3008
  49. tests/analyses/cfg/test_noop_blocks.py +0 -54
  50. tests/analyses/cfg_slice_to_sink/__init__.py +0 -0
  51. tests/analyses/cfg_slice_to_sink/test_cfg_slice_to_sink.py +0 -93
  52. tests/analyses/cfg_slice_to_sink/test_graph.py +0 -114
  53. tests/analyses/cfg_slice_to_sink/test_transitions.py +0 -28
  54. tests/analyses/decompiler/__init__.py +0 -0
  55. tests/analyses/decompiler/test_baseptr_save_simplifier.py +0 -80
  56. tests/analyses/decompiler/test_decompiler.py +0 -3336
  57. tests/analyses/decompiler/test_peephole_optimizations.py +0 -48
  58. tests/analyses/decompiler/test_propagator_loops.py +0 -101
  59. tests/analyses/decompiler/test_structurer.py +0 -275
  60. tests/analyses/reaching_definitions/__init__.py +0 -0
  61. tests/analyses/reaching_definitions/test_dep_graph.py +0 -432
  62. tests/analyses/reaching_definitions/test_function_handler.py +0 -131
  63. tests/analyses/reaching_definitions/test_heap_allocator.py +0 -46
  64. tests/analyses/reaching_definitions/test_rd_state.py +0 -78
  65. tests/analyses/reaching_definitions/test_reachingdefinitions.py +0 -463
  66. tests/analyses/reaching_definitions/test_subject.py +0 -76
  67. tests/analyses/test_bindiff.py +0 -52
  68. tests/analyses/test_block_simplifier.py +0 -112
  69. tests/analyses/test_boyscout.py +0 -104
  70. tests/analyses/test_calling_convention_analysis.py +0 -352
  71. tests/analyses/test_callsite_maker.py +0 -60
  72. tests/analyses/test_cdg.py +0 -165
  73. tests/analyses/test_cfb.py +0 -37
  74. tests/analyses/test_class_identifier.py +0 -46
  75. tests/analyses/test_clinic.py +0 -30
  76. tests/analyses/test_codetagging.py +0 -32
  77. tests/analyses/test_constantpropagation.py +0 -88
  78. tests/analyses/test_ddg.py +0 -95
  79. tests/analyses/test_ddg_global_var_dependencies.py +0 -83
  80. tests/analyses/test_ddg_memvar_addresses.py +0 -40
  81. tests/analyses/test_disassembly.py +0 -121
  82. tests/analyses/test_find_objects_static.py +0 -35
  83. tests/analyses/test_flirt.py +0 -49
  84. tests/analyses/test_identifier.py +0 -33
  85. tests/analyses/test_init_finder.py +0 -38
  86. tests/analyses/test_proximitygraph.py +0 -31
  87. tests/analyses/test_reassembler.py +0 -295
  88. tests/analyses/test_regionidentifier.py +0 -27
  89. tests/analyses/test_slicing.py +0 -164
  90. tests/analyses/test_stack_pointer_tracker.py +0 -74
  91. tests/analyses/test_static_hooker.py +0 -28
  92. tests/analyses/test_typehoon.py +0 -55
  93. tests/analyses/test_variablerecovery.py +0 -464
  94. tests/analyses/test_vfg.py +0 -221
  95. tests/analyses/test_vtable.py +0 -31
  96. tests/analyses/test_xrefs.py +0 -77
  97. tests/common.py +0 -128
  98. tests/engines/__init__.py +0 -0
  99. tests/engines/light/__init__.py +0 -0
  100. tests/engines/light/test_data.py +0 -17
  101. tests/engines/pcode/__init__.py +0 -0
  102. tests/engines/pcode/test_emulate.py +0 -607
  103. tests/engines/pcode/test_pcode.py +0 -84
  104. tests/engines/test_actions.py +0 -27
  105. tests/engines/test_hook.py +0 -112
  106. tests/engines/test_java.py +0 -697
  107. tests/engines/test_unicorn.py +0 -518
  108. tests/engines/vex/__init__.py +0 -0
  109. tests/engines/vex/test_lifter.py +0 -124
  110. tests/engines/vex/test_vex.py +0 -574
  111. tests/exploration_techniques/__init__.py +0 -0
  112. tests/exploration_techniques/test_cacher.py +0 -45
  113. tests/exploration_techniques/test_director.py +0 -67
  114. tests/exploration_techniques/test_driller_core.py +0 -48
  115. tests/exploration_techniques/test_loop_seer.py +0 -158
  116. tests/exploration_techniques/test_memory_watcher.py +0 -46
  117. tests/exploration_techniques/test_oppologist.py +0 -65
  118. tests/exploration_techniques/test_spiller.py +0 -82
  119. tests/exploration_techniques/test_stochastic.py +0 -40
  120. tests/exploration_techniques/test_tech_builder.py +0 -61
  121. tests/exploration_techniques/test_tracer.py +0 -856
  122. tests/exploration_techniques/test_unique.py +0 -40
  123. tests/exploration_techniques/test_veritesting.py +0 -120
  124. tests/factory/__init__.py +0 -0
  125. tests/factory/block/__init__.py +0 -0
  126. tests/factory/block/test_block_cache.py +0 -33
  127. tests/factory/block/test_keystone.py +0 -106
  128. tests/factory/test_argc.py +0 -101
  129. tests/factory/test_argc_sym.py +0 -110
  130. tests/factory/test_argv.py +0 -158
  131. tests/factory/test_callable.py +0 -266
  132. tests/factory/test_windows_args.py +0 -36
  133. tests/knowledge_plugins/__init__.py +0 -0
  134. tests/knowledge_plugins/cfg/__init__.py +0 -0
  135. tests/knowledge_plugins/cfg/test_cfg_manager.py +0 -36
  136. tests/knowledge_plugins/functions/__init__.py +0 -0
  137. tests/knowledge_plugins/functions/test_function.py +0 -91
  138. tests/knowledge_plugins/functions/test_function2.py +0 -79
  139. tests/knowledge_plugins/functions/test_function_manager.py +0 -139
  140. tests/knowledge_plugins/functions/test_prototypes.py +0 -53
  141. tests/knowledge_plugins/key_definitions/__init__.py +0 -0
  142. tests/knowledge_plugins/key_definitions/test_atoms.py +0 -24
  143. tests/knowledge_plugins/key_definitions/test_environment.py +0 -126
  144. tests/knowledge_plugins/key_definitions/test_heap_address.py +0 -27
  145. tests/knowledge_plugins/key_definitions/test_live_definitions.py +0 -72
  146. tests/knowledge_plugins/test_dwarf_variables.py +0 -240
  147. tests/knowledge_plugins/test_kb_plugins.py +0 -91
  148. tests/knowledge_plugins/test_kb_plugins_dwarf.py +0 -36
  149. tests/knowledge_plugins/test_patches.py +0 -48
  150. tests/misc/__init__.py +0 -0
  151. tests/misc/test_hookset.py +0 -57
  152. tests/perf/__init__.py +0 -0
  153. tests/perf/perf_cfgemulated.py +0 -19
  154. tests/perf/perf_cfgfast.py +0 -18
  155. tests/perf/perf_concrete_execution.py +0 -41
  156. tests/perf/perf_siminspect_nop.py +0 -36
  157. tests/perf/perf_state_copy.py +0 -33
  158. tests/perf/perf_unicorn_0.py +0 -27
  159. tests/perf/perf_unicorn_1.py +0 -23
  160. tests/procedures/__init__.py +0 -0
  161. tests/procedures/glibc/__init__.py +0 -0
  162. tests/procedures/glibc/test_ctype_locale.py +0 -164
  163. tests/procedures/libc/__init__.py +0 -0
  164. tests/procedures/libc/test_fgets.py +0 -53
  165. tests/procedures/libc/test_scanf.py +0 -205
  166. tests/procedures/libc/test_sprintf.py +0 -44
  167. tests/procedures/libc/test_sscanf.py +0 -63
  168. tests/procedures/libc/test_strcasecmp.py +0 -37
  169. tests/procedures/libc/test_string.py +0 -1102
  170. tests/procedures/libc/test_strtol.py +0 -78
  171. tests/procedures/linux_kernel/__init__.py +0 -0
  172. tests/procedures/linux_kernel/test_lseek.py +0 -174
  173. tests/procedures/posix/__init__.py +0 -0
  174. tests/procedures/posix/test_chroot.py +0 -33
  175. tests/procedures/posix/test_getenv.py +0 -78
  176. tests/procedures/posix/test_pwrite_pread.py +0 -57
  177. tests/procedures/posix/test_sim_time.py +0 -46
  178. tests/procedures/posix/test_unlink.py +0 -46
  179. tests/procedures/test_project_resolve_simproc.py +0 -43
  180. tests/procedures/test_sim_procedure.py +0 -117
  181. tests/procedures/test_stub_procedure_args.py +0 -53
  182. tests/serialization/__init__.py +0 -0
  183. tests/serialization/test_db.py +0 -197
  184. tests/serialization/test_pickle.py +0 -95
  185. tests/serialization/test_serialization.py +0 -132
  186. tests/serialization/test_vault.py +0 -169
  187. tests/sim/__init__.py +0 -3
  188. tests/sim/exec_func/__init__.py +0 -0
  189. tests/sim/exec_func/test_mem_funcs.py +0 -55
  190. tests/sim/exec_func/test_str_funcs.py +0 -93
  191. tests/sim/exec_func/test_syscall_result.py +0 -39
  192. tests/sim/exec_insn/__init__.py +0 -0
  193. tests/sim/exec_insn/test_adc.py +0 -44
  194. tests/sim/exec_insn/test_ops.py +0 -83
  195. tests/sim/exec_insn/test_rcr.py +0 -26
  196. tests/sim/exec_insn/test_rol.py +0 -51
  197. tests/sim/exec_insn/test_signed_div.py +0 -34
  198. tests/sim/exec_insn/test_sqrt.py +0 -56
  199. tests/sim/options/__init__.py +0 -0
  200. tests/sim/options/test_0div.py +0 -54
  201. tests/sim/options/test_symbolic_fd.py +0 -59
  202. tests/sim/options/test_unsupported.py +0 -34
  203. tests/sim/test_accuracy.py +0 -137
  204. tests/sim/test_checkbyte.py +0 -53
  205. tests/sim/test_echo.py +0 -36
  206. tests/sim/test_fauxware.py +0 -202
  207. tests/sim/test_self_modifying_code.py +0 -65
  208. tests/sim/test_simple_api.py +0 -36
  209. tests/sim/test_simulation_manager.py +0 -147
  210. tests/sim/test_stack_alignment.py +0 -65
  211. tests/sim/test_state.py +0 -303
  212. tests/sim/test_state_customization.py +0 -54
  213. tests/sim/test_symbol_hooked_by.py +0 -49
  214. tests/simos/__init__.py +0 -0
  215. tests/simos/windows/__init__.py +0 -0
  216. tests/simos/windows/test_windows_stack_cookie.py +0 -58
  217. tests/state_plugins/__init__.py +0 -0
  218. tests/state_plugins/inspect/__init__.py +0 -0
  219. tests/state_plugins/inspect/test_inspect.py +0 -310
  220. tests/state_plugins/inspect/test_syscall_override.py +0 -90
  221. tests/state_plugins/posix/__init__.py +0 -0
  222. tests/state_plugins/posix/test_file_struct_funcs.py +0 -56
  223. tests/state_plugins/posix/test_files.py +0 -69
  224. tests/state_plugins/posix/test_posix.py +0 -72
  225. tests/state_plugins/solver/__init__.py +0 -0
  226. tests/state_plugins/solver/test_simsolver.py +0 -58
  227. tests/state_plugins/solver/test_symbolic.py +0 -153
  228. tests/state_plugins/solver/test_variable_registration.py +0 -46
  229. tests/state_plugins/test_callstack.py +0 -54
  230. tests/state_plugins/test_gdb_plugin.py +0 -35
  231. tests/state_plugins/test_multi_open_file.py +0 -47
  232. tests/state_plugins/test_symbolization.py +0 -38
  233. tests/storage/__init__.py +0 -0
  234. tests/storage/test_memory.py +0 -960
  235. tests/storage/test_memory_merge.py +0 -114
  236. tests/storage/test_memview.py +0 -205
  237. tests/storage/test_mmap.py +0 -26
  238. tests/storage/test_multivalues.py +0 -44
  239. tests/storage/test_permissions.py +0 -32
  240. tests/storage/test_ptmalloc.py +0 -291
  241. tests/storage/test_relro_perm.py +0 -49
  242. tests/test_calling_conventions.py +0 -86
  243. tests/test_types.py +0 -329
  244. tests/utils/__init__.py +0 -0
  245. tests/utils/test_graph.py +0 -41
  246. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/LICENSE +0 -0
  247. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/WHEEL +0 -0
  248. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/entry_points.txt +0 -0
@@ -1,137 +0,0 @@
1
- #!/usr/bin/env python3
2
- __package__ = __package__ or "tests.sim" # 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
- arch_data = { # (steps, [hit addrs], finished)
15
- "x86_64": (330, (0x1021C20, 0x1021980, 0x1021BE0, 0x4004B0, 0x400440, 0x400570), True),
16
- "i386": (
17
- 425,
18
- (0x90198E0, 0x90195C0, 0x9019630, 0x90198A0, 0x8048370, 0x80482F8, 0x8048440, 0x804846D, 0x8048518),
19
- True,
20
- ),
21
- "ppc": (381, (0x11022F50, 0x11022EB0, 0x10000340, 0x100002E8, 0x1000053C, 0x1000063C), True),
22
- "ppc64": (372, (0x11047490, 0x100003FC, 0x10000368, 0x10000654, 0x10000770), True),
23
- "mips": (363, (0x1016F20, 0x400500, 0x400470, 0x400640, 0x400750), True),
24
- "mips64": (390, (0x12103B828, 0x120000870, 0x1200007E0, 0x120000A80, 0x120000B68), True),
25
- "armel": (370, (0x10154B8, 0x1108244, 0x83A8, 0x8348, 0x84B0, 0x84E4, 0x85E8), True),
26
- "aarch64": (370, (0x1020B04, 0x400430, 0x4003B8, 0x400538, 0x400570, 0x40062C), True),
27
- }
28
-
29
-
30
- # pylint: disable=missing-class-docstring
31
- # pylint: disable=no-self-use
32
- class TestAccuracy(unittest.TestCase):
33
- def _emulate(self, arch, binary, use_sim_procs, steps, hit_addrs, finished):
34
- # auto_load_libs can't be disabled as the test takes longer time to execute
35
- p = angr.Project(
36
- os.path.join(test_location, arch, binary),
37
- use_sim_procedures=use_sim_procs,
38
- rebase_granularity=0x1000000,
39
- load_debug_info=False,
40
- auto_load_libs=True,
41
- )
42
- state = p.factory.full_init_state(
43
- args=["./test_arrays"],
44
- add_options={
45
- angr.options.STRICT_PAGE_ACCESS,
46
- angr.options.ENABLE_NX,
47
- angr.options.ZERO_FILL_UNCONSTRAINED_MEMORY,
48
- angr.options.USE_SYSTEM_TIMES,
49
- },
50
- )
51
-
52
- pg = p.factory.simulation_manager(state, resilience=True)
53
- pg2 = pg.run(until=lambda lpg: len(lpg.active) != 1)
54
-
55
- is_finished = False
56
- if len(pg2.active) > 0:
57
- state = pg2.active[0]
58
- elif len(pg2.deadended) > 0:
59
- state = pg2.deadended[0]
60
- is_finished = True
61
- elif len(pg2.errored) > 0:
62
- state = pg2.errored[0].state # ErroredState object!
63
- else:
64
- raise ValueError("The result does not contain a state we can use for this test?")
65
-
66
- assert state.history.depth >= steps
67
-
68
- # this is some wonky control flow that asserts that the items in hit_addrs appear in the state in order.
69
- trace = state.history.bbl_addrs.hardcopy
70
- reqs = list(hit_addrs)
71
- while len(reqs) > 0:
72
- req = reqs.pop(0)
73
- while True:
74
- assert len(trace) > 0
75
- trace_head = trace.pop(0)
76
- if trace_head == req:
77
- break
78
- assert trace_head not in reqs
79
-
80
- if finished:
81
- assert is_finished
82
-
83
- def test_windows(self):
84
- self._emulate(
85
- "i386", "test_arrays.exe", True, 41, [], False
86
- ) # blocked on GetLastError or possibly dynamic loading
87
-
88
- def test_x86_64(self):
89
- steps, hit_addrs, finished = arch_data["x86_64"]
90
- self._emulate("x86_64", "test_arrays", False, steps, hit_addrs, finished)
91
-
92
- def test_i386(self):
93
- steps, hit_addrs, finished = arch_data["i386"]
94
- self._emulate("i386", "test_arrays", False, steps, hit_addrs, finished)
95
-
96
- def test_ppc(self):
97
- steps, hit_addrs, finished = arch_data["ppc"]
98
- self._emulate("ppc", "test_arrays", False, steps, hit_addrs, finished)
99
-
100
- def test_ppc64(self):
101
- steps, hit_addrs, finished = arch_data["ppc64"]
102
- self._emulate("ppc64", "test_arrays", False, steps, hit_addrs, finished)
103
-
104
- def test_mips(self):
105
- steps, hit_addrs, finished = arch_data["mips"]
106
- self._emulate("mips", "test_arrays", False, steps, hit_addrs, finished)
107
-
108
- def test_mips64(self):
109
- steps, hit_addrs, finished = arch_data["mips64"]
110
- self._emulate("mips64", "test_arrays", False, steps, hit_addrs, finished)
111
-
112
- def test_armel(self):
113
- steps, hit_addrs, finished = arch_data["armel"]
114
- self._emulate("armel", "test_arrays", False, steps, hit_addrs, finished)
115
-
116
- def test_aarch64(self):
117
- steps, hit_addrs, finished = arch_data["aarch64"]
118
- self._emulate("aarch64", "test_arrays", False, steps, hit_addrs, finished)
119
-
120
- def test_locale(self):
121
- # auto_load_libs can't be disabled as the test takes longer time to execute
122
- p = angr.Project(os.path.join(test_location, "i386", "isalnum"), use_sim_procedures=False, auto_load_libs=True)
123
- state = p.factory.full_init_state(args=["./isalnum"], add_options={angr.options.STRICT_PAGE_ACCESS})
124
- pg = p.factory.simulation_manager(state)
125
- pg2 = pg.run(
126
- until=lambda lpg: len(lpg.active) != 1, step_func=lambda lpg: lpg if len(lpg.active) == 1 else lpg.prune()
127
- )
128
- assert len(pg2.active) == 0
129
- assert len(pg2.deadended) == 1
130
- assert pg2.deadended[0].history.events[-1].type == "terminate"
131
- assert pg2.deadended[0].history.events[-1].objects["exit_code"].concrete_value == 0
132
-
133
-
134
- if __name__ == "__main__":
135
- # emulate('armel', 'test_arrays', False, *arch_data['armel'])
136
- # import sys; sys.exit()
137
- unittest.main()
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env python3
2
- __package__ = __package__ or "tests.sim" # 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
- # TODO: arches += ( "armhf", )
16
-
17
-
18
- # pylint: disable=missing-class-docstring
19
- # pylint: disable=no-self-use
20
- class TestCheckbyte(unittest.TestCase):
21
- def _run_checkbyte(self, arch):
22
- p = angr.Project(os.path.join(test_location, arch, "checkbyte"), auto_load_libs=False)
23
- results = p.factory.simulation_manager().run(n=100) # , until=lambda lpg: len(lpg.active) > 1)
24
-
25
- assert len(results.deadended) == 2
26
- one = results.deadended[0].posix.dumps(1)
27
- two = results.deadended[1].posix.dumps(1)
28
- assert {one, two} == {b"First letter good\n", b"First letter bad\n"}
29
-
30
- def test_checkbyte_armel(self):
31
- self._run_checkbyte("armel")
32
-
33
- def test_checkbyte_i386(self):
34
- self._run_checkbyte("i386")
35
-
36
- def test_checkbyte_mips(self):
37
- self._run_checkbyte("mips")
38
-
39
- def test_checkbyte_mipsel(self):
40
- self._run_checkbyte("mipsel")
41
-
42
- def test_checkbyte_ppc64(self):
43
- self._run_checkbyte("ppc64")
44
-
45
- def test_checkbyte_ppc(self):
46
- self._run_checkbyte("ppc")
47
-
48
- def test_checkbyte_x86_64(self):
49
- self._run_checkbyte("x86_64")
50
-
51
-
52
- if __name__ == "__main__":
53
- unittest.main()
tests/sim/test_echo.py DELETED
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,disable=no-self-use
3
- __package__ = __package__ or "tests.sim" # 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 TestEcho(unittest.TestCase):
17
- def _run_echo_haha(self, arch):
18
- # auto_load_libs can't be disabled as the test fails
19
- p = angr.Project(os.path.join(test_location, arch, "echo"), use_sim_procedures=False)
20
- s = p.factory.full_init_state(
21
- mode="symbolic_approximating", args=["echo", "haha"], add_options={angr.options.STRICT_PAGE_ACCESS}
22
- )
23
- pg = p.factory.simulation_manager(s)
24
- pg.run(until=lambda lpg: len(lpg.active) != 1)
25
-
26
- assert len(pg.deadended) == 1
27
- assert len(pg.active) == 0
28
- # Need to dump by path because the program closes stdout
29
- assert pg.deadended[0].posix.stdout.concretize() == [b"haha\n"]
30
-
31
- def test_echo_haha(self):
32
- self._run_echo_haha("x86_64")
33
-
34
-
35
- if __name__ == "__main__":
36
- unittest.main()
@@ -1,202 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use
3
- __package__ = __package__ or "tests.sim" # pylint:disable=redefined-builtin
4
-
5
- import gc
6
- import os
7
- import pickle
8
- import unittest
9
-
10
- import angr
11
- from angr.state_plugins.history import HistoryIter
12
-
13
- from ..common import bin_location, slow_test
14
-
15
-
16
- test_location = os.path.join(bin_location, "tests")
17
-
18
- target_addrs = {
19
- "i386": [0x080485C9],
20
- "x86_64": [0x4006ED],
21
- "ppc": [0x1000060C],
22
- "armel": [0x85F0],
23
- "android/arm": [0x4004CC],
24
- "mips": [0x4009FC],
25
- }
26
-
27
- avoid_addrs = {
28
- "i386": [0x080485DD, 0x08048564],
29
- "x86_64": [0x4006AA, 0x4006FD],
30
- "ppc": [0x10000644, 0x1000059C],
31
- "armel": [0x86F8, 0x857C],
32
- "android/arm": [0x4004F0, 0x400470],
33
- "mips": [0x400A10, 0x400774],
34
- }
35
-
36
- corrupt_addrs = {
37
- "i386": [0x80486B6, b"bO\xcc", lambda s: s.memory.store(s.regs.esp, s.regs.eax)],
38
- "x86_64": [0x400742, b"\x0f\x0b\xb0[\x41", lambda s: s.registers.store("rdx", 8)],
39
- "ppc": [0x100006B8, b"\x05\xad\xc2\xea", lambda s: s.registers.store("r5", 8)],
40
- "armel": [0x8678, b"\xbdM\xec3", lambda s: s.registers.store("r2", 8)],
41
- "mips": [0x400918, b"[\xf8\x96@"[::-1], lambda s: s.registers.store("a2", 8)],
42
- }
43
-
44
- divergences = {
45
- "ppc": 0x10000588,
46
- "x86_64": 0x40068E,
47
- "i386": 0x8048559,
48
- "armel": 0x8568,
49
- "android/arm": 0x40045C,
50
- "mips": 0x40075C,
51
- }
52
-
53
-
54
- class TestFauxware(unittest.TestCase):
55
- def _run_fauxware(self, arch):
56
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), auto_load_libs=False)
57
- results = p.factory.simulation_manager().explore(find=target_addrs[arch], avoid=avoid_addrs[arch])
58
- stdin = results.found[0].posix.dumps(0)
59
- assert b"\x00\x00\x00\x00\x00\x00\x00\x00\x00SOSNEAKY\x00" == stdin
60
-
61
- # test the divergence detection
62
- ancestor = results.found[0].history.closest_common_ancestor((results.avoid + results.active)[0].history)
63
- divergent_point = list(HistoryIter(results.found[0].history, end=ancestor))[0]
64
- # p.factory.block(divergent_point.addr).pp()
65
- assert divergent_point.recent_bbl_addrs[0] == divergences[arch]
66
-
67
- def _run_pickling(self, arch):
68
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), auto_load_libs=False)
69
- pg = p.factory.simulation_manager().run(n=10)
70
- pickled = pickle.dumps(pg, pickle.HIGHEST_PROTOCOL)
71
- del p
72
- del pg
73
- gc.collect()
74
- pg = pickle.loads(pickled)
75
-
76
- pg.explore(find=target_addrs[arch], avoid=avoid_addrs[arch])
77
- stdin = pg.found[0].posix.dumps(0)
78
- assert b"\x00\x00\x00\x00\x00\x00\x00\x00\x00SOSNEAKY\x00" == stdin
79
-
80
- @slow_test
81
- def _run_fastmem(self, arch):
82
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), auto_load_libs=False)
83
- p.analyses.CongruencyCheck(throw=True).set_state_options(right_add_options={"FAST_REGISTERS"}).run()
84
-
85
- def _run_nodecode(self, arch):
86
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), auto_load_libs=False)
87
-
88
- # screw up the instructions and make sure the test fails with nodecode
89
- for i, c in enumerate(corrupt_addrs[arch][1]):
90
- p.loader.memory[corrupt_addrs[arch][0] + i] = c
91
- boned = p.factory.simulation_manager().explore(find=target_addrs[arch], avoid=avoid_addrs[arch])
92
- assert len(boned.errored) >= 1
93
- assert isinstance(boned.errored[0].error, angr.SimIRSBNoDecodeError)
94
- assert boned.errored[0].state.addr == corrupt_addrs[arch][0]
95
-
96
- # hook the instructions with the emulated stuff
97
- p.hook(
98
- corrupt_addrs[arch][0],
99
- corrupt_addrs[arch][2],
100
- length=len(corrupt_addrs[arch][1]),
101
- )
102
- results = p.factory.simulation_manager().explore(find=target_addrs[arch], avoid=avoid_addrs[arch])
103
- stdin = results.found[0].posix.dumps(0)
104
- assert b"\x00\x00\x00\x00\x00\x00\x00\x00\x00SOSNEAKY\x00" == stdin
105
-
106
- def _run_merge(self, arch):
107
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), auto_load_libs=False)
108
- pg = p.factory.simulation_manager()
109
- pg.explore()
110
-
111
- # release the unmergable data
112
- for s in pg.deadended:
113
- s.release_plugin("fs")
114
- if 3 in s.posix.fd:
115
- s.posix.close(3)
116
-
117
- pg.merge(stash="deadended", merge_key=lambda s: s.addr)
118
-
119
- path = pg.deadended[[b"Welcome" in s for s in pg.mp_deadended.posix.dumps(1).mp_items].index(True)]
120
- yes, no = path.history.merge_conditions
121
- inp = path.posix.stdin.content[2][0] # content of second packet
122
- try:
123
- assert b"SOSNEAKY" in path.solver.eval(inp, cast_to=bytes, extra_constraints=(yes,))
124
- assert b"SOSNEAKY" not in path.solver.eval(inp, cast_to=bytes, extra_constraints=(no,))
125
- except AssertionError:
126
- yes, no = no, yes
127
- assert b"SOSNEAKY" in path.solver.eval(inp, cast_to=bytes, extra_constraints=(yes,))
128
- assert b"SOSNEAKY" not in path.solver.eval(inp, cast_to=bytes, extra_constraints=(no,))
129
-
130
- def test_merge_i386(self):
131
- self._run_merge("i386")
132
-
133
- def test_merge_x86_64(self):
134
- self._run_merge("x86_64")
135
-
136
- def test_merge_ppc(self):
137
- self._run_merge("ppc")
138
-
139
- def test_merge_armel(self):
140
- self._run_merge("armel")
141
-
142
- def test_merge_android(self):
143
- self._run_merge("android/arm")
144
-
145
- def test_merge_mips(self):
146
- self._run_merge("mips")
147
-
148
- def test_fauxware_i386(self):
149
- self._run_fauxware("i386")
150
-
151
- def test_fauxware_x86_64(self):
152
- self._run_fauxware("x86_64")
153
-
154
- def test_fauxware_ppc(self):
155
- self._run_fauxware("ppc")
156
-
157
- def test_fauxware_armel(self):
158
- self._run_fauxware("armel")
159
-
160
- def test_fauxware_android(self):
161
- self._run_fauxware("android/arm")
162
-
163
- def test_fauxware_mips(self):
164
- self._run_fauxware("mips")
165
-
166
- def test_pickling_i386(self):
167
- self._run_pickling("i386")
168
-
169
- def test_pickling_x86_64(self):
170
- self._run_pickling("x86_64")
171
-
172
- def test_pickling_ppc(self):
173
- self._run_pickling("ppc")
174
-
175
- def test_pickling_armel(self):
176
- self._run_pickling("armel")
177
-
178
- def test_pickling_mips(self):
179
- self._run_pickling("mips")
180
-
181
- @slow_test
182
- def test_fastmen(self):
183
- self._run_fastmem("x86_64")
184
-
185
- def test_nodecode_i386(self):
186
- self._run_nodecode("i386")
187
-
188
- def test_nodecode_x86_64(self):
189
- self._run_nodecode("x86_64")
190
-
191
- def test_nodecode_ppc(self):
192
- self._run_nodecode("ppc")
193
-
194
- def test_nodecode_armel(self):
195
- self._run_nodecode("armel")
196
-
197
- def test_nodecode_mips(self):
198
- self._run_nodecode("mips")
199
-
200
-
201
- if __name__ == "__main__":
202
- unittest.main()
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint:disable=no-self-use,missing-class-docstring
3
- __package__ = __package__ or "tests.sim" # pylint:disable=redefined-builtin
4
-
5
- import os
6
- from unittest import TestCase, main
7
-
8
- import claripy
9
-
10
- import angr
11
- from angr import options as o
12
-
13
- from ..common import bin_location
14
-
15
-
16
- test_location = os.path.join(bin_location, "tests")
17
-
18
-
19
- class TestSelfModifyingCOde(TestCase):
20
- def test_self_modifying_code(self):
21
- p = angr.Project(os.path.join(test_location, "cgc", "stuff"), auto_load_libs=False, selfmodifying_code=True)
22
- pg = p.factory.simulation_manager(p.factory.entry_state(add_options={o.STRICT_PAGE_ACCESS}))
23
-
24
- # small issue: the program is bugged and uses illegal stack allocation patterns, bypassing the red page
25
- # hack around this here
26
- for offs in range(0, 0x6000, 0x1000):
27
- pg.one_active.memory.load(pg.one_active.regs.sp - offs, size=1)
28
-
29
- pg.run(until=lambda lpg: len(lpg.active) != 1)
30
- retval = pg.one_deadended.regs.ebx
31
- assert claripy.is_true(retval == 65)
32
-
33
- pgu = p.factory.simulation_manager(p.factory.entry_state(add_options={o.STRICT_PAGE_ACCESS} | o.unicorn))
34
- for offs in range(0, 0x6000, 0x1000):
35
- pgu.one_active.memory.load(pgu.one_active.regs.sp - offs, size=1)
36
- pgu.run(until=lambda lpg: len(lpg.active) != 1)
37
- retval = pgu.one_deadended.regs.ebx
38
- assert claripy.is_true(retval == 65)
39
-
40
- # the two histories are not the same because angr does not add relifted block addresses (caused by raising
41
- # SimReliftExceptions during execution) to the history. whether this is a good design decision or not is a
42
- # question for another day. for now, we resort to a weaker check.
43
- #
44
- # assert pg.one_deadended.history.bbl_addrs.hardcopy == pgu.one_deadended.history.bbl_addrs.hardcopy
45
- i, j = 0, 0
46
- pg_bbl_addrs = pg.one_deadended.history.bbl_addrs.hardcopy
47
- u_bbl_addrs = pgu.one_deadended.history.bbl_addrs.hardcopy
48
- while i < len(pg_bbl_addrs) and j < len(u_bbl_addrs):
49
- if pg_bbl_addrs[i] == u_bbl_addrs[j]:
50
- i += 1
51
- j += 1
52
- elif pg_bbl_addrs[i] != u_bbl_addrs[j] and pg_bbl_addrs[i - 1] < u_bbl_addrs[j] < pg_bbl_addrs[i]:
53
- # this is the missing relifted block address in angr's history. skip it
54
- j += 1
55
- else:
56
- raise Exception("History mismatch")
57
- assert i == len(pg_bbl_addrs)
58
- assert j == len(u_bbl_addrs)
59
-
60
- # also ensure that block.pp() does not raise any exceptions
61
- p.factory.block(0xBAAA7B42, backup_state=pg.one_deadended).pp()
62
-
63
-
64
- if __name__ == "__main__":
65
- main()
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use,line-too-long
3
- __package__ = __package__ or "tests.sim" # 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
- def _bin(*s):
14
- return os.path.join(bin_location, "tests", *s)
15
-
16
-
17
- class TestSimpleApi(unittest.TestCase):
18
- def test_fauxware(self):
19
- project = angr.Project(_bin("i386", "fauxware"), auto_load_libs=False)
20
-
21
- result = [0, 0]
22
-
23
- @project.hook(0x80485DB)
24
- def check_backdoor(state): # pylint:disable=unused-variable
25
- result[0] += 1
26
- if b"SOSNEAKY" in state.posix.dumps(0):
27
- result[1] = True
28
- project.terminate_execution()
29
-
30
- pg = project.execute()
31
- assert len(pg.deadended) != 3 # should terminate early
32
- assert result[1]
33
-
34
-
35
- if __name__ == "__main__":
36
- unittest.main()
@@ -1,147 +0,0 @@
1
- #!/usr/bin/env python3
2
- __package__ = __package__ or "tests.sim" # 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
- addresses_fauxware = {
15
- "armel": 0x8524,
16
- "armhf": 0x104C9, # addr+1 to force thumb
17
- #'i386': 0x8048524, # commenting out because of the freaking stack check
18
- "mips": 0x400710,
19
- "mipsel": 0x4006D0,
20
- "ppc": 0x1000054C,
21
- "ppc64": 0x10000698,
22
- "x86_64": 0x400664,
23
- }
24
-
25
-
26
- class TestSimulationManager(unittest.TestCase):
27
- def _run_fauxware(self, arch, threads):
28
- p = angr.Project(os.path.join(test_location, arch, "fauxware"), load_options={"auto_load_libs": False})
29
-
30
- pg = p.factory.simulation_manager(threads=threads)
31
- assert len(pg.active) == 1
32
- assert pg.active[0].history.depth == 0
33
-
34
- # step until the backdoor split occurs
35
- pg2 = pg.step(until=lambda lpg: len(lpg.active) > 1, step_func=lambda lpg: lpg.prune())
36
- assert len(pg2.active) == 2
37
- assert any(b"SOSNEAKY" in s for s in pg2.mp_active.posix.dumps(0).mp_items)
38
- assert not all(b"SOSNEAKY" in s for s in pg2.mp_active.posix.dumps(0).mp_items)
39
-
40
- # separate out the backdoor and normal paths
41
- pg3 = pg2.stash(lambda path: b"SOSNEAKY" in path.posix.dumps(0), to_stash="backdoor").move("active", "auth")
42
- assert len(pg3.active) == 0
43
- assert len(pg3.backdoor) == 1
44
- assert len(pg3.auth) == 1
45
-
46
- # step the backdoor path until it returns to main
47
- pg4 = pg3.step(until=lambda lpg: lpg.backdoor[0].history.jumpkinds[-1] == "Ijk_Ret", stash="backdoor")
48
- main_addr = pg4.backdoor[0].addr
49
-
50
- assert len(pg4.active) == 0
51
- assert len(pg4.backdoor) == 1
52
- assert len(pg4.auth) == 1
53
-
54
- # now step the real path until the real authentication paths return to the same place
55
- pg5 = pg4.explore(find=main_addr, num_find=2, stash="auth").move("found", "auth")
56
-
57
- assert len(pg5.active) == 0
58
- assert len(pg5.backdoor) == 1
59
- assert len(pg5.auth) == 2
60
-
61
- # now unstash everything
62
- pg6 = pg5.unstash(from_stash="backdoor").unstash(from_stash="auth")
63
- assert len(pg6.active) == 3
64
- assert len(pg6.backdoor) == 0
65
- assert len(pg6.auth) == 0
66
-
67
- assert len(set(pg6.mp_active.addr.mp_items)) == 1
68
-
69
- # now merge them!
70
- pg7 = pg6.merge()
71
- assert len(pg7.active) == 2
72
- assert len(pg7.backdoor) == 0
73
- assert len(pg7.auth) == 0
74
-
75
- # test selecting paths to step
76
- pg8 = p.factory.simulation_manager()
77
- pg8.step(until=lambda lpg: len(lpg.active) > 1, step_func=lambda lpg: lpg.prune().drop(stash="pruned"))
78
- st1, st2 = pg8.active
79
- pg8.step(selector_func=lambda p: p is st1, step_func=lambda lpg: lpg.prune().drop(stash="pruned"))
80
- assert st2 is pg8.active[1]
81
- assert st1 is not pg8.active[0]
82
-
83
- total_active = len(pg8.active)
84
-
85
- # test special stashes
86
- assert len(pg8.stashes["stashed"]) == 0
87
- pg8.stash(filter_func=lambda p: p is pg8.active[1], to_stash="asdf")
88
- assert len(pg8.stashes["stashed"]) == 0
89
- assert len(pg8.asdf) == 1
90
- assert len(pg8.active) == total_active - 1
91
- pg8.stash(from_stash=pg8.ALL, to_stash="fdsa")
92
- assert len(pg8.asdf) == 0
93
- assert len(pg8.active) == 0
94
- assert len(pg8.fdsa) == total_active
95
- pg8.stash(from_stash=pg8.ALL, to_stash=pg8.DROP)
96
- assert all(len(s) == 0 for s in pg8.stashes.values())
97
-
98
- def test_fauxware_armel(self):
99
- self._run_fauxware("armel", None)
100
-
101
- def test_fauxware_armhf(self):
102
- self._run_fauxware("armhf", None)
103
-
104
- def test_fauxware_mips(self):
105
- self._run_fauxware("mips", None)
106
-
107
- def test_fauxware_mipsel(self):
108
- self._run_fauxware("mipsel", None)
109
-
110
- def test_fauxware_ppc(self):
111
- self._run_fauxware("ppc", None)
112
-
113
- def test_fauxware_ppc64(self):
114
- self._run_fauxware("ppc64", None)
115
-
116
- def test_fauxware_x86_64(self):
117
- self._run_fauxware("x86_64", None)
118
-
119
- def test_find_to_middle(self):
120
- # Test the ability of PathGroup to execute until an instruction in the middle of a basic block
121
- p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), load_options={"auto_load_libs": False})
122
-
123
- pg = p.factory.simulation_manager()
124
- pg.explore(find=(0x4006EE,))
125
-
126
- assert len(pg.found) == 1
127
- assert pg.found[0].addr == 0x4006EE
128
-
129
- def test_explore_with_cfg(self):
130
- p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), load_options={"auto_load_libs": False})
131
-
132
- cfg = p.analyses.CFGEmulated()
133
-
134
- pg = p.factory.simulation_manager()
135
- pg.use_technique(angr.exploration_techniques.Explorer(find=0x4006ED, cfg=cfg, num_find=3))
136
- pg.run()
137
-
138
- assert len(pg.active) == 0
139
- assert len(pg.avoid) == 1
140
- assert len(pg.found) == 2
141
- assert pg.found[0].addr == 0x4006ED
142
- assert pg.found[1].addr == 0x4006ED
143
- assert pg.avoid[0].addr == 0x4007C9
144
-
145
-
146
- if __name__ == "__main__":
147
- unittest.main()