angr 9.2.87__py3-none-win_amd64.whl → 9.2.89__py3-none-win_amd64.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 (249) 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/lib/angr_native.dll +0 -0
  24. angr/misc/autoimport.py +26 -0
  25. angr/procedures/definitions/__init__.py +32 -3
  26. angr/utils/constants.py +1 -0
  27. angr/utils/graph.py +20 -1
  28. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/METADATA +7 -6
  29. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/RECORD +33 -245
  30. angr-9.2.89.dist-info/top_level.txt +1 -0
  31. angr/procedures/definitions/ntdll.py +0 -12
  32. angr-9.2.87.dist-info/top_level.txt +0 -2
  33. tests/__init__.py +0 -0
  34. tests/analyses/__init__.py +0 -0
  35. tests/analyses/cfg/__init__.py +0 -0
  36. tests/analyses/cfg/test_cfg_clflush.py +0 -43
  37. tests/analyses/cfg/test_cfg_get_any_node.py +0 -34
  38. tests/analyses/cfg/test_cfg_manager.py +0 -32
  39. tests/analyses/cfg/test_cfg_model.py +0 -55
  40. tests/analyses/cfg/test_cfg_patching.py +0 -378
  41. tests/analyses/cfg/test_cfg_rust_got_resolution.py +0 -36
  42. tests/analyses/cfg/test_cfg_thumb_firmware.py +0 -50
  43. tests/analyses/cfg/test_cfg_vex_postprocessor.py +0 -27
  44. tests/analyses/cfg/test_cfgemulated.py +0 -634
  45. tests/analyses/cfg/test_cfgfast.py +0 -1123
  46. tests/analyses/cfg/test_cfgfast_soot.py +0 -38
  47. tests/analyses/cfg/test_const_resolver.py +0 -38
  48. tests/analyses/cfg/test_iat_resolver.py +0 -37
  49. tests/analyses/cfg/test_jumptables.py +0 -3008
  50. tests/analyses/cfg/test_noop_blocks.py +0 -54
  51. tests/analyses/cfg_slice_to_sink/__init__.py +0 -0
  52. tests/analyses/cfg_slice_to_sink/test_cfg_slice_to_sink.py +0 -93
  53. tests/analyses/cfg_slice_to_sink/test_graph.py +0 -114
  54. tests/analyses/cfg_slice_to_sink/test_transitions.py +0 -28
  55. tests/analyses/decompiler/__init__.py +0 -0
  56. tests/analyses/decompiler/test_baseptr_save_simplifier.py +0 -80
  57. tests/analyses/decompiler/test_decompiler.py +0 -3336
  58. tests/analyses/decompiler/test_peephole_optimizations.py +0 -48
  59. tests/analyses/decompiler/test_propagator_loops.py +0 -101
  60. tests/analyses/decompiler/test_structurer.py +0 -275
  61. tests/analyses/reaching_definitions/__init__.py +0 -0
  62. tests/analyses/reaching_definitions/test_dep_graph.py +0 -432
  63. tests/analyses/reaching_definitions/test_function_handler.py +0 -131
  64. tests/analyses/reaching_definitions/test_heap_allocator.py +0 -46
  65. tests/analyses/reaching_definitions/test_rd_state.py +0 -78
  66. tests/analyses/reaching_definitions/test_reachingdefinitions.py +0 -463
  67. tests/analyses/reaching_definitions/test_subject.py +0 -76
  68. tests/analyses/test_bindiff.py +0 -52
  69. tests/analyses/test_block_simplifier.py +0 -112
  70. tests/analyses/test_boyscout.py +0 -104
  71. tests/analyses/test_calling_convention_analysis.py +0 -352
  72. tests/analyses/test_callsite_maker.py +0 -60
  73. tests/analyses/test_cdg.py +0 -165
  74. tests/analyses/test_cfb.py +0 -37
  75. tests/analyses/test_class_identifier.py +0 -46
  76. tests/analyses/test_clinic.py +0 -30
  77. tests/analyses/test_codetagging.py +0 -32
  78. tests/analyses/test_constantpropagation.py +0 -88
  79. tests/analyses/test_ddg.py +0 -95
  80. tests/analyses/test_ddg_global_var_dependencies.py +0 -83
  81. tests/analyses/test_ddg_memvar_addresses.py +0 -40
  82. tests/analyses/test_disassembly.py +0 -121
  83. tests/analyses/test_find_objects_static.py +0 -35
  84. tests/analyses/test_flirt.py +0 -49
  85. tests/analyses/test_identifier.py +0 -33
  86. tests/analyses/test_init_finder.py +0 -38
  87. tests/analyses/test_proximitygraph.py +0 -31
  88. tests/analyses/test_reassembler.py +0 -295
  89. tests/analyses/test_regionidentifier.py +0 -27
  90. tests/analyses/test_slicing.py +0 -164
  91. tests/analyses/test_stack_pointer_tracker.py +0 -74
  92. tests/analyses/test_static_hooker.py +0 -28
  93. tests/analyses/test_typehoon.py +0 -55
  94. tests/analyses/test_variablerecovery.py +0 -464
  95. tests/analyses/test_vfg.py +0 -221
  96. tests/analyses/test_vtable.py +0 -31
  97. tests/analyses/test_xrefs.py +0 -77
  98. tests/common.py +0 -128
  99. tests/engines/__init__.py +0 -0
  100. tests/engines/light/__init__.py +0 -0
  101. tests/engines/light/test_data.py +0 -17
  102. tests/engines/pcode/__init__.py +0 -0
  103. tests/engines/pcode/test_emulate.py +0 -607
  104. tests/engines/pcode/test_pcode.py +0 -84
  105. tests/engines/test_actions.py +0 -27
  106. tests/engines/test_hook.py +0 -112
  107. tests/engines/test_java.py +0 -697
  108. tests/engines/test_unicorn.py +0 -518
  109. tests/engines/vex/__init__.py +0 -0
  110. tests/engines/vex/test_lifter.py +0 -124
  111. tests/engines/vex/test_vex.py +0 -574
  112. tests/exploration_techniques/__init__.py +0 -0
  113. tests/exploration_techniques/test_cacher.py +0 -45
  114. tests/exploration_techniques/test_director.py +0 -67
  115. tests/exploration_techniques/test_driller_core.py +0 -48
  116. tests/exploration_techniques/test_loop_seer.py +0 -158
  117. tests/exploration_techniques/test_memory_watcher.py +0 -46
  118. tests/exploration_techniques/test_oppologist.py +0 -65
  119. tests/exploration_techniques/test_spiller.py +0 -82
  120. tests/exploration_techniques/test_stochastic.py +0 -40
  121. tests/exploration_techniques/test_tech_builder.py +0 -61
  122. tests/exploration_techniques/test_tracer.py +0 -856
  123. tests/exploration_techniques/test_unique.py +0 -40
  124. tests/exploration_techniques/test_veritesting.py +0 -120
  125. tests/factory/__init__.py +0 -0
  126. tests/factory/block/__init__.py +0 -0
  127. tests/factory/block/test_block_cache.py +0 -33
  128. tests/factory/block/test_keystone.py +0 -106
  129. tests/factory/test_argc.py +0 -101
  130. tests/factory/test_argc_sym.py +0 -110
  131. tests/factory/test_argv.py +0 -158
  132. tests/factory/test_callable.py +0 -266
  133. tests/factory/test_windows_args.py +0 -36
  134. tests/knowledge_plugins/__init__.py +0 -0
  135. tests/knowledge_plugins/cfg/__init__.py +0 -0
  136. tests/knowledge_plugins/cfg/test_cfg_manager.py +0 -36
  137. tests/knowledge_plugins/functions/__init__.py +0 -0
  138. tests/knowledge_plugins/functions/test_function.py +0 -91
  139. tests/knowledge_plugins/functions/test_function2.py +0 -79
  140. tests/knowledge_plugins/functions/test_function_manager.py +0 -139
  141. tests/knowledge_plugins/functions/test_prototypes.py +0 -53
  142. tests/knowledge_plugins/key_definitions/__init__.py +0 -0
  143. tests/knowledge_plugins/key_definitions/test_atoms.py +0 -24
  144. tests/knowledge_plugins/key_definitions/test_environment.py +0 -126
  145. tests/knowledge_plugins/key_definitions/test_heap_address.py +0 -27
  146. tests/knowledge_plugins/key_definitions/test_live_definitions.py +0 -72
  147. tests/knowledge_plugins/test_dwarf_variables.py +0 -240
  148. tests/knowledge_plugins/test_kb_plugins.py +0 -91
  149. tests/knowledge_plugins/test_kb_plugins_dwarf.py +0 -36
  150. tests/knowledge_plugins/test_patches.py +0 -48
  151. tests/misc/__init__.py +0 -0
  152. tests/misc/test_hookset.py +0 -57
  153. tests/perf/__init__.py +0 -0
  154. tests/perf/perf_cfgemulated.py +0 -19
  155. tests/perf/perf_cfgfast.py +0 -18
  156. tests/perf/perf_concrete_execution.py +0 -41
  157. tests/perf/perf_siminspect_nop.py +0 -36
  158. tests/perf/perf_state_copy.py +0 -33
  159. tests/perf/perf_unicorn_0.py +0 -27
  160. tests/perf/perf_unicorn_1.py +0 -23
  161. tests/procedures/__init__.py +0 -0
  162. tests/procedures/glibc/__init__.py +0 -0
  163. tests/procedures/glibc/test_ctype_locale.py +0 -164
  164. tests/procedures/libc/__init__.py +0 -0
  165. tests/procedures/libc/test_fgets.py +0 -53
  166. tests/procedures/libc/test_scanf.py +0 -205
  167. tests/procedures/libc/test_sprintf.py +0 -44
  168. tests/procedures/libc/test_sscanf.py +0 -63
  169. tests/procedures/libc/test_strcasecmp.py +0 -37
  170. tests/procedures/libc/test_string.py +0 -1102
  171. tests/procedures/libc/test_strtol.py +0 -78
  172. tests/procedures/linux_kernel/__init__.py +0 -0
  173. tests/procedures/linux_kernel/test_lseek.py +0 -174
  174. tests/procedures/posix/__init__.py +0 -0
  175. tests/procedures/posix/test_chroot.py +0 -33
  176. tests/procedures/posix/test_getenv.py +0 -78
  177. tests/procedures/posix/test_pwrite_pread.py +0 -57
  178. tests/procedures/posix/test_sim_time.py +0 -46
  179. tests/procedures/posix/test_unlink.py +0 -46
  180. tests/procedures/test_project_resolve_simproc.py +0 -43
  181. tests/procedures/test_sim_procedure.py +0 -117
  182. tests/procedures/test_stub_procedure_args.py +0 -53
  183. tests/serialization/__init__.py +0 -0
  184. tests/serialization/test_db.py +0 -197
  185. tests/serialization/test_pickle.py +0 -95
  186. tests/serialization/test_serialization.py +0 -132
  187. tests/serialization/test_vault.py +0 -169
  188. tests/sim/__init__.py +0 -3
  189. tests/sim/exec_func/__init__.py +0 -0
  190. tests/sim/exec_func/test_mem_funcs.py +0 -55
  191. tests/sim/exec_func/test_str_funcs.py +0 -93
  192. tests/sim/exec_func/test_syscall_result.py +0 -39
  193. tests/sim/exec_insn/__init__.py +0 -0
  194. tests/sim/exec_insn/test_adc.py +0 -44
  195. tests/sim/exec_insn/test_ops.py +0 -83
  196. tests/sim/exec_insn/test_rcr.py +0 -26
  197. tests/sim/exec_insn/test_rol.py +0 -51
  198. tests/sim/exec_insn/test_signed_div.py +0 -34
  199. tests/sim/exec_insn/test_sqrt.py +0 -56
  200. tests/sim/options/__init__.py +0 -0
  201. tests/sim/options/test_0div.py +0 -54
  202. tests/sim/options/test_symbolic_fd.py +0 -59
  203. tests/sim/options/test_unsupported.py +0 -34
  204. tests/sim/test_accuracy.py +0 -137
  205. tests/sim/test_checkbyte.py +0 -53
  206. tests/sim/test_echo.py +0 -36
  207. tests/sim/test_fauxware.py +0 -202
  208. tests/sim/test_self_modifying_code.py +0 -65
  209. tests/sim/test_simple_api.py +0 -36
  210. tests/sim/test_simulation_manager.py +0 -147
  211. tests/sim/test_stack_alignment.py +0 -65
  212. tests/sim/test_state.py +0 -303
  213. tests/sim/test_state_customization.py +0 -54
  214. tests/sim/test_symbol_hooked_by.py +0 -49
  215. tests/simos/__init__.py +0 -0
  216. tests/simos/windows/__init__.py +0 -0
  217. tests/simos/windows/test_windows_stack_cookie.py +0 -58
  218. tests/state_plugins/__init__.py +0 -0
  219. tests/state_plugins/inspect/__init__.py +0 -0
  220. tests/state_plugins/inspect/test_inspect.py +0 -310
  221. tests/state_plugins/inspect/test_syscall_override.py +0 -90
  222. tests/state_plugins/posix/__init__.py +0 -0
  223. tests/state_plugins/posix/test_file_struct_funcs.py +0 -56
  224. tests/state_plugins/posix/test_files.py +0 -69
  225. tests/state_plugins/posix/test_posix.py +0 -72
  226. tests/state_plugins/solver/__init__.py +0 -0
  227. tests/state_plugins/solver/test_simsolver.py +0 -58
  228. tests/state_plugins/solver/test_symbolic.py +0 -153
  229. tests/state_plugins/solver/test_variable_registration.py +0 -46
  230. tests/state_plugins/test_callstack.py +0 -54
  231. tests/state_plugins/test_gdb_plugin.py +0 -35
  232. tests/state_plugins/test_multi_open_file.py +0 -47
  233. tests/state_plugins/test_symbolization.py +0 -38
  234. tests/storage/__init__.py +0 -0
  235. tests/storage/test_memory.py +0 -960
  236. tests/storage/test_memory_merge.py +0 -114
  237. tests/storage/test_memview.py +0 -205
  238. tests/storage/test_mmap.py +0 -26
  239. tests/storage/test_multivalues.py +0 -44
  240. tests/storage/test_permissions.py +0 -32
  241. tests/storage/test_ptmalloc.py +0 -291
  242. tests/storage/test_relro_perm.py +0 -49
  243. tests/test_calling_conventions.py +0 -86
  244. tests/test_types.py +0 -329
  245. tests/utils/__init__.py +0 -0
  246. tests/utils/test_graph.py +0 -41
  247. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/LICENSE +0 -0
  248. {angr-9.2.87.dist-info → angr-9.2.89.dist-info}/WHEEL +0 -0
  249. {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=missing-class-docstring,disable=no-self-use
3
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
4
-
5
- import os
6
- import platform
7
- import sys
8
- import unittest
9
-
10
- import angr
11
-
12
- from .test_tracer import tracer_cgc
13
- from ..common import bin_location
14
-
15
-
16
- test_location = os.path.join(bin_location, "tests")
17
-
18
-
19
- @unittest.skipIf(platform.system() == "Darwin" and platform.machine() == "arm64", "Broken on apple silicon")
20
- class TestDrillerCore(unittest.TestCase):
21
- @unittest.skipIf(sys.platform == "win32", "broken on windows")
22
- def test_cgc(self):
23
- binary = os.path.join(test_location, "cgc", "sc1_0b32aa01_01")
24
- simgr, tracer = tracer_cgc(binary, "driller_core_cgc", b"AAAA", copy_states=True, follow_unsat=True)
25
- simgr.use_technique(angr.exploration_techniques.DrillerCore(tracer._trace))
26
- simgr.run()
27
-
28
- assert "diverted" in simgr.stashes
29
- assert len(simgr.diverted) == 3
30
-
31
- def test_simprocs(self):
32
- binary = os.path.join(test_location, "i386", "driller_simproc")
33
- memcmp = angr.SIM_PROCEDURES["libc"]["memcmp"]()
34
-
35
- simgr, tracer = tracer_cgc(binary, "driller_core_simprocs", b"A" * 128, copy_states=True, follow_unsat=True)
36
- p = simgr._project
37
- p.hook(0x8048200, memcmp)
38
-
39
- d = angr.exploration_techniques.DrillerCore(tracer._trace)
40
- simgr.use_technique(d)
41
-
42
- simgr.run()
43
- assert "diverted" in simgr.stashes
44
- assert len(simgr.diverted) > 0
45
-
46
-
47
- if __name__ == "__main__":
48
- unittest.main()
@@ -1,158 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use,line-too-long
3
- __package__ = __package__ or "tests.exploration_techniques" # 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 TestLoopSeer(unittest.TestCase):
17
- def test_various_loops(self):
18
- p = angr.Project(os.path.join(test_location, "x86_64", "various_loops"), auto_load_libs=False)
19
-
20
- cfg = p.analyses.CFGFast(normalize=True)
21
-
22
- state = p.factory.entry_state()
23
- state.register_plugin("loop_data", angr.state_plugins.SimStateLoopData())
24
-
25
- dummy = p.loader.main_object.get_symbol("dummy")
26
- bvs = state.solver.BVS(dummy.name, 8 * dummy.size)
27
- state.memory.store(dummy.rebased_addr, bvs, endness="Iend_LE")
28
-
29
- simgr = p.factory.simulation_manager(state)
30
-
31
- simgr.use_technique(angr.exploration_techniques.LoopSeer(cfg=cfg, functions=None, bound=None))
32
-
33
- simgr.run()
34
-
35
- assert len(simgr.deadended) == 10
36
- assert len(simgr.deadended[0].loop_data.back_edge_trip_counts) == 14
37
-
38
- for i, d in enumerate(simgr.deadended):
39
- f = p.kb.functions.function(name="symbolic_loop")
40
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
41
- assert d.loop_data.back_edge_trip_counts[l.entry.addr][0] == i
42
-
43
- f = p.kb.functions.function(name="for_loop")
44
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
45
- assert d.loop_data.back_edge_trip_counts[l.entry.addr][0] == 9
46
-
47
- f = p.kb.functions.function(name="while_loop")
48
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
49
- assert d.loop_data.back_edge_trip_counts[l.entry.addr][0] == 9
50
-
51
- f = p.kb.functions.function(name="do_while_loop")
52
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
53
- assert d.loop_data.header_trip_counts[l.entry.addr][0] == 9
54
-
55
- f = p.kb.functions.function(name="nullify")
56
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
57
- assert len(d.loop_data.back_edge_trip_counts[l.entry.addr]) == 8
58
- assert d.loop_data.back_edge_trip_counts[l.entry.addr][0] == 9
59
-
60
- f = p.kb.functions.function(name="nested_for_loop")
61
- ol = p.analyses.LoopFinder(functions=[f]).loops[0]
62
- il = ol.subloops[0]
63
- assert d.loop_data.back_edge_trip_counts[ol.entry.addr][0] == 3
64
- assert len(d.loop_data.back_edge_trip_counts[il.entry.addr]) == 3
65
- assert all(s == 3 for s in d.loop_data.back_edge_trip_counts[il.entry.addr])
66
-
67
- f = p.kb.functions.function(name="nested_while_loop")
68
- ol = p.analyses.LoopFinder(functions=[f]).loops[0]
69
- il = ol.subloops[0]
70
- assert d.loop_data.back_edge_trip_counts[ol.entry.addr][0] == 3
71
- assert len(d.loop_data.back_edge_trip_counts[il.entry.addr]) == 3
72
- assert all(s == 3 for s in d.loop_data.back_edge_trip_counts[il.entry.addr])
73
-
74
- f = p.kb.functions.function(name="nested_do_while_loop")
75
- ol = p.analyses.LoopFinder(functions=[f]).loops[0]
76
- il = ol.subloops[0]
77
- assert d.loop_data.header_trip_counts[ol.entry.addr][0] == 3
78
- assert len(d.loop_data.header_trip_counts[il.entry.addr]) == 3
79
- assert all(s == 3 for s in d.loop_data.header_trip_counts[il.entry.addr])
80
-
81
- f = p.kb.functions.function(name="break_for_loop")
82
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
83
- assert d.loop_data.back_edge_trip_counts[l.entry.addr][0] == 9
84
-
85
- f = p.kb.functions.function(name="break_do_while_loop")
86
- l = p.analyses.LoopFinder(functions=[f]).loops[0]
87
- assert d.loop_data.header_trip_counts[l.entry.addr][0] == 9
88
-
89
- def test_loops_with_invalid_parameter(self):
90
- p = angr.Project(os.path.join(test_location, "x86_64", "test_loops"), auto_load_libs=False)
91
-
92
- state = p.factory.entry_state()
93
- state.register_plugin("loop_data", angr.state_plugins.SimStateLoopData())
94
- simgr = p.factory.simulation_manager(state)
95
-
96
- simgr.use_technique(angr.exploration_techniques.LoopSeer(functions=["main", 0x1234], bound=None))
97
-
98
- simgr.run()
99
-
100
- assert len(simgr.deadended[0].loop_data.back_edge_trip_counts) == 3
101
- assert simgr.deadended[0].loop_data.back_edge_trip_counts[0x400665][0] == 10
102
- assert len(simgr.deadended[0].loop_data.back_edge_trip_counts[0x400665]) == 10
103
- assert simgr.deadended[0].loop_data.back_edge_trip_counts[0x400675][0] == 10
104
- assert simgr.deadended[0].loop_data.back_edge_trip_counts[0x4006B2][0] == 100
105
-
106
- def test_arrays(self):
107
- p = angr.Project(os.path.join(test_location, "x86_64", "test_arrays"), auto_load_libs=False)
108
-
109
- cfg = p.analyses.CFGFast(normalize=True)
110
-
111
- state = p.factory.entry_state()
112
- state.register_plugin("loop_data", angr.state_plugins.SimStateLoopData())
113
- simgr = p.factory.simulation_manager(state)
114
-
115
- simgr.use_technique(angr.exploration_techniques.LoopSeer(cfg=cfg, functions="main", bound=None))
116
-
117
- simgr.run()
118
-
119
- assert len(simgr.deadended[0].loop_data.back_edge_trip_counts) == 2
120
- assert simgr.deadended[0].loop_data.back_edge_trip_counts[0x400636][0] == 26
121
- assert simgr.deadended[0].loop_data.back_edge_trip_counts[0x4005FD][0] == 26
122
-
123
- def test_loop_limiter(self):
124
- p = angr.Project(os.path.join(test_location, "x86_64", "test_arrays"), auto_load_libs=False)
125
-
126
- cfg = p.analyses.CFGFast(normalize=True)
127
-
128
- state = p.factory.entry_state()
129
- state.register_plugin("loop_data", angr.state_plugins.SimStateLoopData())
130
- simgr = p.factory.simulation_manager(state)
131
-
132
- simgr.use_technique(angr.exploration_techniques.LoopSeer(cfg=cfg, functions="main", bound=5))
133
-
134
- simgr.run()
135
-
136
- assert "spinning" in simgr.stashes
137
- assert simgr.spinning[0].loop_data.back_edge_trip_counts[0x4005FD][0] == 6
138
-
139
- def test_loop_limiter_constant_loop(self):
140
- p = angr.Project(os.path.join(test_location, "x86_64", "constant_loopseer"), auto_load_libs=False)
141
-
142
- cfg = p.analyses.CFGFast(normalize=True)
143
-
144
- state = p.factory.entry_state()
145
- simgr = p.factory.simulation_manager(state)
146
-
147
- simgr.use_technique(
148
- angr.exploration_techniques.LoopSeer(cfg=cfg, functions="main", bound=5, limit_concrete_loops=False)
149
- )
150
-
151
- simgr.run()
152
- assert simgr.deadended[0].regs.eax.concrete
153
- val = simgr.deadended[0].solver.eval_one(simgr.deadended[0].regs.eax)
154
- assert val == 420
155
-
156
-
157
- if __name__ == "__main__":
158
- unittest.main()
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use
3
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
4
-
5
- import os
6
- import unittest
7
-
8
- import angr
9
- import psutil
10
-
11
- from ..common import bin_location
12
-
13
-
14
- test_location = os.path.join(bin_location, "tests")
15
-
16
-
17
- class TestMemoryWatcher(unittest.TestCase):
18
- def test_memory_watcher(self):
19
- binary = os.path.join(test_location, "x86_64", "veritesting_a")
20
- proj = angr.Project(binary, auto_load_libs=False)
21
- simgr = proj.factory.simulation_manager()
22
-
23
- memory_watcher = angr.exploration_techniques.MemoryWatcher()
24
- simgr.use_technique(memory_watcher)
25
-
26
- # Initially build some paths
27
- while len(simgr.active) < 32 and simgr.active != []:
28
- simgr.step()
29
-
30
- # Something else went wrong..
31
- assert simgr.active != []
32
-
33
- # Set fake that memory watcher believes we're too low on memory
34
- memory_watcher.min_memory = psutil.virtual_memory().total
35
-
36
- previous_active = len(simgr.active)
37
-
38
- # Step once to move things over
39
- simgr.step()
40
-
41
- assert simgr.active == []
42
- assert len(getattr(simgr, memory_watcher.memory_stash)) == previous_active
43
-
44
-
45
- if __name__ == "__main__":
46
- unittest.main()
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use,line-too-long
3
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
4
-
5
- import unittest
6
- import os
7
- import sys
8
-
9
- import angr
10
-
11
- from ..common import bin_location
12
-
13
-
14
- test_location = os.path.join(bin_location, "tests")
15
-
16
-
17
- def _ultra_oppologist(p, s):
18
- old_ops = dict(angr.engines.vex.claripy.irop.operations)
19
- try:
20
- angr.engines.vex.claripy.irop.operations.clear()
21
- angr.engines.vex.claripy.irop.operations["Iop_Add32"] = old_ops["Iop_Add32"]
22
-
23
- pg = p.factory.simulation_manager(s)
24
- pg.use_technique(angr.exploration_techniques.Oppologist())
25
- pg.explore()
26
-
27
- return pg
28
- finally:
29
- angr.engines.vex.claripy.irop.operations.update(old_ops)
30
-
31
-
32
- @unittest.skipIf(sys.platform == "win32", "broken on windows")
33
- class TestOppologist(unittest.TestCase):
34
- def test_fauxware_oppologist(self):
35
- p = angr.Project(os.path.join(test_location, "i386", "fauxware"))
36
- s = p.factory.full_init_state(remove_options={angr.options.LAZY_SOLVES, angr.options.EXTENDED_IROP_SUPPORT})
37
-
38
- pg = _ultra_oppologist(p, s)
39
- assert len(pg.deadended) == 1
40
- assert len(pg.deadended[0].posix.dumps(0)) == 18
41
- stdout = pg.deadended[0].posix.dumps(1)
42
- if b"trusted user" in stdout:
43
- assert stdout.count(b"\n") == 3
44
- else:
45
- assert stdout.count(b"\n") == 2
46
-
47
- def test_cromu_70(self):
48
- p = angr.Project(os.path.join(test_location, "cgc", "CROMU_00070"))
49
- inp = bytes.fromhex(
50
- "030e000001000001001200010000586d616ce000000600030000040dd0000000000600000606000006030e000001000001003200010000586d616ce0030000000000030e000001000001003200010000586d616ce003000000000006000006030e000001000001003200010000586d616ce0030000df020000"
51
- )
52
- s = p.factory.full_init_state(
53
- add_options={angr.options.UNICORN},
54
- remove_options={angr.options.LAZY_SOLVES, angr.options.SUPPORT_FLOATING_POINT},
55
- stdin=inp,
56
- )
57
-
58
- pg = p.factory.simulation_manager(s)
59
- pg.use_technique(angr.exploration_techniques.Oppologist())
60
- pg.run(n=50)
61
- assert pg.one_active.history.block_count > 1500
62
-
63
-
64
- if __name__ == "__main__":
65
- unittest.main()
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env python3
2
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
3
-
4
- import os
5
- import gc
6
- import unittest
7
-
8
- import claripy
9
-
10
- from angr.exploration_techniques.spiller import Spiller
11
- import angr
12
-
13
- from ..common import bin_location
14
-
15
-
16
- test_location = os.path.join(bin_location, "tests")
17
-
18
-
19
- def _bin(*s):
20
- return os.path.join(test_location, *s)
21
-
22
-
23
- def pickle_callback(state):
24
- state.globals["pickled"] = True
25
-
26
-
27
- def unpickle_callback(sid, state): # pylint:disable=unused-argument
28
- state.globals["unpickled"] = True
29
-
30
-
31
- def priority_key(state):
32
- return state.addr * state.history.depth # to help ensure determinism
33
-
34
-
35
- class TestSpiller(unittest.TestCase):
36
- @classmethod
37
- def setUp(self):
38
- # clean up AST cache in claripy, because a cached AST might believe it
39
- # has been stored in ana after we clean up the ana storage
40
-
41
- claripy.ast.bv._bvv_cache.clear()
42
- claripy.ast.bv.BV._hash_cache.clear()
43
-
44
- def test_basic(self):
45
- project = angr.Project(_bin("cgc", "sc2_0b32aa01_01"), auto_load_libs=False)
46
- state = project.factory.entry_state()
47
- spiller = Spiller(pickle_callback=pickle_callback, unpickle_callback=unpickle_callback)
48
- spiller._pickle([state])
49
-
50
- del state
51
- gc.collect()
52
- state = spiller._unpickle(1)[0]
53
-
54
- assert state.globals["pickled"]
55
- assert state.globals["unpickled"]
56
-
57
- def test_palindrome2(self):
58
- project = angr.Project(_bin("cgc", "sc2_0b32aa01_01"), auto_load_libs=False)
59
- pg = project.factory.simulation_manager()
60
- limiter = angr.exploration_techniques.LengthLimiter(max_length=250)
61
- pg.use_technique(limiter)
62
-
63
- spiller = Spiller(
64
- pickle_callback=pickle_callback, unpickle_callback=unpickle_callback, priority_key=priority_key
65
- )
66
- pg.use_technique(spiller)
67
- # pg.step(until=lambda lpg: len(lpg.active) == 10)
68
- # pg.step(until=lambda lpg: len(lpg.spill_stage) > 15)
69
- # pg.step(until=lambda lpg: spiller._pickled_paths)
70
- pg.run()
71
-
72
- assert spiller._ever_pickled > 0
73
- assert spiller._ever_unpickled == spiller._ever_pickled
74
- assert all(
75
- ("pickled" not in state.globals and "unpickled" not in state.globals)
76
- or (state.globals["pickled"] and state.globals["unpickled"])
77
- for state in pg.cut
78
- )
79
-
80
-
81
- if __name__ == "__main__":
82
- unittest.main()
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env python3
2
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
3
-
4
- import os
5
- import unittest
6
-
7
- import angr
8
-
9
- from ..common import bin_location
10
-
11
- test_location = os.path.join(bin_location, "tests")
12
-
13
- find = {"veritesting_a": {"x86_64": 0x40066A}}
14
-
15
- criteria = {"veritesting_a": lambda input_found: input_found.count(b"B") == 10}
16
-
17
-
18
- class TestRun(unittest.TestCase):
19
- def _run_stochastic(self, binary, arch):
20
- proj = angr.Project(os.path.join(test_location, arch, binary), auto_load_libs=False)
21
- simgr = proj.factory.simulation_manager()
22
- start_state = simgr.active[0]
23
- technique = angr.exploration_techniques.StochasticSearch(start_state)
24
- simgr.use_technique(technique)
25
-
26
- def found(simgr):
27
- return simgr.active[0].addr == find[binary][arch]
28
-
29
- simgr.run(until=found)
30
- assert simgr.active[0].addr == find[binary][arch]
31
-
32
- input_found = simgr.active[0].posix.dumps(0)
33
- assert criteria[binary](input_found)
34
-
35
- def test_stochastic(self):
36
- self._run_stochastic("veritesting_a", "x86_64")
37
-
38
-
39
- if __name__ == "__main__":
40
- unittest.main()
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env python3
2
- # pylint: disable=missing-class-docstring,no-self-use,line-too-long
3
- __package__ = __package__ or "tests.exploration_techniques" # pylint:disable=redefined-builtin
4
-
5
- import logging
6
- import os
7
- import unittest
8
-
9
- import angr
10
-
11
- from ..common import bin_location
12
-
13
-
14
- test_location = os.path.join(bin_location, "tests")
15
- log = logging.getLogger("angr_tests.test_proxy")
16
-
17
-
18
- class TestTechBuilder(unittest.TestCase):
19
- def test_tech_builder(self):
20
- # pylint:disable=unused-argument
21
- class Foo:
22
- @staticmethod
23
- def setup(*args, **kwargs):
24
- log.debug("setup() triggered!")
25
-
26
- @staticmethod
27
- def step_state(*args, **kwargs):
28
- log.debug("step_state() triggered!")
29
-
30
- @staticmethod
31
- def step(simgr, stash, *args, **kwargs):
32
- log.debug("step() triggered!")
33
- return simgr.step(stash=stash, **kwargs)
34
-
35
- @staticmethod
36
- def filter(*args, **kwargs):
37
- log.debug("filter() triggered!")
38
-
39
- @staticmethod
40
- def complete(*args, **kwargs):
41
- log.debug("complete() triggered!")
42
- return True
43
-
44
- p = angr.Project(os.path.join(test_location, "x86_64", "fauxware"), load_options={"auto_load_libs": False})
45
-
46
- foo = Foo()
47
- proxy_tech = angr.exploration_techniques.TechniqueBuilder(
48
- setup=foo.setup,
49
- step_state=foo.step_state,
50
- step=foo.step,
51
- filter=foo.filter,
52
- complete=foo.complete,
53
- )
54
-
55
- pg = p.factory.simulation_manager()
56
- pg.use_technique(proxy_tech)
57
- pg.run()
58
-
59
-
60
- if __name__ == "__main__":
61
- unittest.main()