angr 9.2.131__py3-none-manylinux2014_aarch64.whl → 9.2.133__py3-none-manylinux2014_aarch64.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 (264) hide show
  1. angr/__init__.py +128 -128
  2. angr/analyses/__init__.py +38 -38
  3. angr/analyses/analysis.py +6 -2
  4. angr/analyses/backward_slice.py +3 -4
  5. angr/analyses/binary_optimizer.py +5 -12
  6. angr/analyses/bindiff.py +3 -6
  7. angr/analyses/calling_convention.py +3 -4
  8. angr/analyses/cfg/__init__.py +3 -3
  9. angr/analyses/cfg/cfg_base.py +1 -1
  10. angr/analyses/cfg/cfg_emulated.py +5 -5
  11. angr/analyses/cfg/cfg_fast.py +19 -17
  12. angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
  13. angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
  14. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +148 -101
  15. angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
  16. angr/analyses/data_dep/__init__.py +4 -4
  17. angr/analyses/datagraph_meta.py +1 -1
  18. angr/analyses/ddg.py +16 -17
  19. angr/analyses/decompiler/__init__.py +12 -12
  20. angr/analyses/decompiler/ail_simplifier.py +24 -12
  21. angr/analyses/decompiler/block_similarity.py +2 -4
  22. angr/analyses/decompiler/block_simplifier.py +10 -21
  23. angr/analyses/decompiler/callsite_maker.py +1 -1
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
  25. angr/analyses/decompiler/clinic.py +122 -41
  26. angr/analyses/decompiler/condition_processor.py +57 -39
  27. angr/analyses/decompiler/counters/__init__.py +3 -3
  28. angr/analyses/decompiler/decompilation_cache.py +7 -7
  29. angr/analyses/decompiler/dephication/__init__.py +1 -1
  30. angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
  31. angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
  32. angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
  33. angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
  34. angr/analyses/decompiler/expression_narrower.py +1 -1
  35. angr/analyses/decompiler/graph_region.py +8 -8
  36. angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
  37. angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
  38. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
  39. angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
  40. angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
  41. angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
  42. angr/analyses/decompiler/optimization_passes/engine_base.py +262 -84
  43. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +175 -39
  44. angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
  45. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
  46. angr/analyses/decompiler/optimization_passes/mod_simplifier.py +12 -3
  47. angr/analyses/decompiler/optimization_passes/optimization_pass.py +42 -19
  48. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
  49. angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
  50. angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
  51. angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +2 -0
  52. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
  53. angr/analyses/decompiler/presets/__init__.py +1 -1
  54. angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
  55. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
  56. angr/analyses/decompiler/ssailification/rewriting.py +1 -2
  57. angr/analyses/decompiler/ssailification/rewriting_engine.py +139 -56
  58. angr/analyses/decompiler/ssailification/ssailification.py +2 -1
  59. angr/analyses/decompiler/ssailification/traversal.py +4 -6
  60. angr/analyses/decompiler/ssailification/traversal_engine.py +125 -42
  61. angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
  62. angr/analyses/decompiler/structured_codegen/base.py +3 -3
  63. angr/analyses/decompiler/structured_codegen/c.py +39 -40
  64. angr/analyses/decompiler/structuring/__init__.py +3 -3
  65. angr/analyses/decompiler/structuring/phoenix.py +45 -29
  66. angr/analyses/decompiler/structuring/structurer_base.py +2 -2
  67. angr/analyses/decompiler/structuring/structurer_nodes.py +23 -14
  68. angr/analyses/deobfuscator/__init__.py +3 -3
  69. angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
  70. angr/analyses/deobfuscator/string_obf_finder.py +2 -2
  71. angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
  72. angr/analyses/disassembly.py +4 -4
  73. angr/analyses/forward_analysis/__init__.py +1 -1
  74. angr/analyses/forward_analysis/visitors/graph.py +6 -6
  75. angr/analyses/init_finder.py +47 -22
  76. angr/analyses/loop_analysis.py +1 -1
  77. angr/analyses/loopfinder.py +1 -1
  78. angr/analyses/propagator/engine_base.py +21 -14
  79. angr/analyses/propagator/engine_vex.py +149 -179
  80. angr/analyses/propagator/outdated_definition_walker.py +12 -6
  81. angr/analyses/propagator/propagator.py +10 -28
  82. angr/analyses/propagator/top_checker_mixin.py +211 -5
  83. angr/analyses/propagator/vex_vars.py +4 -4
  84. angr/analyses/reaching_definitions/__init__.py +9 -9
  85. angr/analyses/reaching_definitions/call_trace.py +2 -2
  86. angr/analyses/reaching_definitions/dep_graph.py +1 -1
  87. angr/analyses/reaching_definitions/engine_ail.py +304 -329
  88. angr/analyses/reaching_definitions/engine_vex.py +243 -229
  89. angr/analyses/reaching_definitions/function_handler.py +3 -3
  90. angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
  91. angr/analyses/reaching_definitions/rd_state.py +47 -42
  92. angr/analyses/reassembler.py +26 -31
  93. angr/analyses/s_liveness.py +8 -0
  94. angr/analyses/s_propagator.py +18 -3
  95. angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
  96. angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
  97. angr/analyses/stack_pointer_tracker.py +4 -4
  98. angr/analyses/typehoon/simple_solver.py +14 -14
  99. angr/analyses/typehoon/translator.py +10 -2
  100. angr/analyses/typehoon/typeconsts.py +11 -3
  101. angr/analyses/typehoon/typevars.py +26 -26
  102. angr/analyses/unpacker/__init__.py +1 -1
  103. angr/analyses/variable_recovery/engine_ail.py +299 -259
  104. angr/analyses/variable_recovery/engine_base.py +138 -121
  105. angr/analyses/variable_recovery/engine_vex.py +175 -185
  106. angr/analyses/variable_recovery/irsb_scanner.py +49 -38
  107. angr/analyses/variable_recovery/variable_recovery.py +28 -5
  108. angr/analyses/variable_recovery/variable_recovery_base.py +33 -34
  109. angr/analyses/variable_recovery/variable_recovery_fast.py +4 -8
  110. angr/analyses/veritesting.py +2 -2
  111. angr/analyses/vfg.py +5 -5
  112. angr/analyses/xrefs.py +46 -19
  113. angr/angrdb/serializers/__init__.py +1 -1
  114. angr/annocfg.py +20 -15
  115. angr/blade.py +2 -2
  116. angr/block.py +20 -25
  117. angr/calling_conventions.py +12 -14
  118. angr/code_location.py +6 -10
  119. angr/codenode.py +3 -3
  120. angr/engines/__init__.py +12 -14
  121. angr/engines/engine.py +24 -61
  122. angr/engines/light/__init__.py +13 -5
  123. angr/engines/light/data.py +1 -1
  124. angr/engines/light/engine.py +1003 -1185
  125. angr/engines/pcode/__init__.py +1 -1
  126. angr/engines/pcode/behavior.py +1 -1
  127. angr/engines/pcode/cc.py +2 -0
  128. angr/engines/pcode/lifter.py +13 -15
  129. angr/engines/soot/expressions/__init__.py +12 -12
  130. angr/engines/soot/statements/__init__.py +6 -6
  131. angr/engines/soot/values/__init__.py +6 -6
  132. angr/engines/soot/values/arrayref.py +2 -2
  133. angr/engines/soot/values/constants.py +1 -1
  134. angr/engines/soot/values/instancefieldref.py +1 -1
  135. angr/engines/soot/values/paramref.py +1 -1
  136. angr/engines/soot/values/staticfieldref.py +1 -1
  137. angr/engines/successors.py +15 -14
  138. angr/engines/vex/__init__.py +5 -5
  139. angr/engines/vex/claripy/ccall.py +2 -2
  140. angr/engines/vex/claripy/datalayer.py +1 -1
  141. angr/engines/vex/claripy/irop.py +19 -19
  142. angr/engines/vex/heavy/__init__.py +2 -2
  143. angr/engines/vex/heavy/actions.py +1 -3
  144. angr/engines/vex/heavy/heavy.py +4 -6
  145. angr/engines/vex/lifter.py +2 -4
  146. angr/engines/vex/light/light.py +0 -2
  147. angr/engines/vex/light/slicing.py +5 -5
  148. angr/exploration_techniques/__init__.py +19 -142
  149. angr/exploration_techniques/base.py +126 -0
  150. angr/exploration_techniques/bucketizer.py +1 -1
  151. angr/exploration_techniques/dfs.py +3 -1
  152. angr/exploration_techniques/director.py +2 -3
  153. angr/exploration_techniques/driller_core.py +1 -1
  154. angr/exploration_techniques/explorer.py +4 -2
  155. angr/exploration_techniques/lengthlimiter.py +2 -1
  156. angr/exploration_techniques/local_loop_seer.py +2 -1
  157. angr/exploration_techniques/loop_seer.py +5 -5
  158. angr/exploration_techniques/manual_mergepoint.py +2 -1
  159. angr/exploration_techniques/memory_watcher.py +3 -1
  160. angr/exploration_techniques/oppologist.py +4 -5
  161. angr/exploration_techniques/slicecutor.py +4 -2
  162. angr/exploration_techniques/spiller.py +1 -1
  163. angr/exploration_techniques/stochastic.py +2 -1
  164. angr/exploration_techniques/stub_stasher.py +2 -1
  165. angr/exploration_techniques/suggestions.py +3 -1
  166. angr/exploration_techniques/symbion.py +3 -1
  167. angr/exploration_techniques/tech_builder.py +2 -1
  168. angr/exploration_techniques/threading.py +2 -11
  169. angr/exploration_techniques/timeout.py +4 -2
  170. angr/exploration_techniques/tracer.py +4 -3
  171. angr/exploration_techniques/unique.py +3 -2
  172. angr/exploration_techniques/veritesting.py +1 -1
  173. angr/factory.py +36 -6
  174. angr/keyed_region.py +4 -4
  175. angr/knowledge_base.py +1 -1
  176. angr/knowledge_plugins/__init__.py +11 -11
  177. angr/knowledge_plugins/cfg/__init__.py +5 -5
  178. angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
  179. angr/knowledge_plugins/cfg/cfg_model.py +8 -8
  180. angr/knowledge_plugins/cfg/cfg_node.py +19 -19
  181. angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
  182. angr/knowledge_plugins/cfg/memory_data.py +5 -7
  183. angr/knowledge_plugins/functions/function.py +48 -52
  184. angr/knowledge_plugins/functions/function_parser.py +4 -4
  185. angr/knowledge_plugins/key_definitions/__init__.py +3 -3
  186. angr/knowledge_plugins/key_definitions/atoms.py +8 -8
  187. angr/knowledge_plugins/key_definitions/definition.py +1 -1
  188. angr/knowledge_plugins/key_definitions/live_definitions.py +30 -27
  189. angr/knowledge_plugins/labels.py +1 -1
  190. angr/knowledge_plugins/propagations/__init__.py +1 -1
  191. angr/knowledge_plugins/propagations/prop_value.py +2 -2
  192. angr/knowledge_plugins/propagations/propagation_model.py +7 -8
  193. angr/knowledge_plugins/propagations/states.py +44 -39
  194. angr/knowledge_plugins/variables/variable_access.py +2 -2
  195. angr/knowledge_plugins/variables/variable_manager.py +24 -10
  196. angr/knowledge_plugins/xrefs/xref.py +5 -8
  197. angr/misc/__init__.py +4 -4
  198. angr/misc/hookset.py +4 -5
  199. angr/misc/loggers.py +2 -2
  200. angr/misc/telemetry.py +1 -1
  201. angr/procedures/__init__.py +1 -1
  202. angr/procedures/cgc/fdwait.py +2 -2
  203. angr/procedures/definitions/__init__.py +2 -2
  204. angr/procedures/definitions/linux_kernel.py +0 -1
  205. angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
  206. angr/procedures/definitions/parse_win32json.py +0 -1
  207. angr/procedures/ntdll/exceptions.py +1 -1
  208. angr/procedures/stubs/format_parser.py +3 -3
  209. angr/procedures/win32/dynamic_loading.py +1 -1
  210. angr/protos/__init__.py +3 -3
  211. angr/sim_manager.py +3 -5
  212. angr/sim_state.py +40 -42
  213. angr/sim_state_options.py +3 -3
  214. angr/sim_type.py +15 -14
  215. angr/sim_variable.py +42 -45
  216. angr/simos/__init__.py +4 -4
  217. angr/simos/cgc.py +1 -1
  218. angr/simos/simos.py +1 -1
  219. angr/simos/userland.py +1 -1
  220. angr/slicer.py +4 -7
  221. angr/state_plugins/__init__.py +34 -34
  222. angr/state_plugins/callstack.py +5 -12
  223. angr/state_plugins/heap/__init__.py +2 -2
  224. angr/state_plugins/heap/heap_brk.py +2 -4
  225. angr/state_plugins/heap/heap_ptmalloc.py +1 -1
  226. angr/state_plugins/jni_references.py +3 -2
  227. angr/state_plugins/scratch.py +1 -1
  228. angr/state_plugins/sim_action.py +1 -4
  229. angr/state_plugins/sim_event.py +1 -1
  230. angr/state_plugins/solver.py +7 -9
  231. angr/state_plugins/uc_manager.py +1 -1
  232. angr/state_plugins/view.py +2 -2
  233. angr/storage/__init__.py +1 -1
  234. angr/storage/file.py +10 -10
  235. angr/storage/memory_mixins/__init__.py +46 -46
  236. angr/storage/memory_mixins/default_filler_mixin.py +1 -3
  237. angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
  238. angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
  239. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
  240. angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
  241. angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
  242. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
  243. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
  244. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
  245. angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
  246. angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
  247. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
  248. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
  249. angr/storage/memory_object.py +4 -4
  250. angr/utils/__init__.py +3 -3
  251. angr/utils/bits.py +12 -0
  252. angr/utils/dynamic_dictlist.py +1 -1
  253. angr/utils/graph.py +1 -1
  254. angr/utils/orderedset.py +4 -1
  255. angr/utils/segment_list.py +2 -2
  256. angr/utils/ssa/__init__.py +33 -8
  257. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
  258. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/RECORD +262 -263
  259. angr/analyses/propagator/engine_ail.py +0 -1562
  260. angr/storage/memory_mixins/__init__.pyi +0 -48
  261. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
  262. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
  263. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
  264. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
@@ -3,10 +3,10 @@ from __future__ import annotations
3
3
 
4
4
  import pyvex
5
5
 
6
- from angr.engines.light import SimEngineLightVEXMixin
6
+ from angr.engines.light import SimEngineLightVEX
7
7
 
8
8
 
9
- class VEXIRSBScanner(SimEngineLightVEXMixin):
9
+ class VEXIRSBScanner(SimEngineLightVEX[None, None, None, None]):
10
10
  """
11
11
  Scan the VEX IRSB to determine if any argument-passing registers should be narrowed by detecting cases of loading
12
12
  the whole register and immediately narrowing the register before writing to the tmp.
@@ -33,22 +33,22 @@ class VEXIRSBScanner(SimEngineLightVEXMixin):
33
33
  self.reg_read_stmt_id: dict[int, int] = {}
34
34
  self.reg_read_stmts_to_ignore: set[int] = set()
35
35
 
36
- def _top(self, size: int):
36
+ def _top(self, bits: int):
37
37
  return None
38
38
 
39
39
  def _is_top(self, expr) -> bool:
40
40
  return True
41
41
 
42
- def _process_Stmt(self, whitelist=None):
42
+ def _process(self, state, *, block=None, whitelist=None, **kwargs):
43
43
  self.tmps_with_64bit_regs = set()
44
44
  self.tmps_assignment_stmtidx = {}
45
45
  self.tmps_converted_to_32bit = set()
46
46
 
47
- super()._process_Stmt(whitelist=whitelist)
47
+ super()._process(state, block=block, whitelist=whitelist, **kwargs)
48
48
 
49
49
  self.stmts_to_lower = {self.tmps_assignment_stmtidx[i] for i in self.tmps_converted_to_32bit}
50
50
 
51
- def _handle_Put(self, stmt):
51
+ def _handle_stmt_Put(self, stmt):
52
52
  if isinstance(stmt.data, pyvex.IRExpr.RdTmp) and stmt.data.tmp in self.tmp_with_reg_as_value:
53
53
  if (
54
54
  stmt.offset in self.reg_with_reg_as_value
@@ -61,25 +61,46 @@ class VEXIRSBScanner(SimEngineLightVEXMixin):
61
61
  self.reg_read_stmts_to_ignore.add(self.reg_read_stmt_id[old_reg_offset])
62
62
  self.reg_with_reg_as_value[stmt.offset] = self.tmp_with_reg_as_value[stmt.data.tmp]
63
63
 
64
- def _handle_PutI(self, stmt):
64
+ def _handle_stmt_PutI(self, stmt):
65
65
  pass
66
66
 
67
- def _handle_Load(self, expr):
67
+ def _handle_expr_Load(self, expr):
68
68
  pass
69
69
 
70
- def _handle_Store(self, stmt):
70
+ def _handle_stmt_Store(self, stmt):
71
71
  pass
72
72
 
73
- def _handle_LoadG(self, stmt):
73
+ def _handle_stmt_LoadG(self, stmt):
74
74
  pass
75
75
 
76
- def _handle_LLSC(self, stmt: pyvex.IRStmt.LLSC):
76
+ def _handle_stmt_LLSC(self, stmt):
77
77
  pass
78
78
 
79
- def _handle_StoreG(self, stmt):
79
+ def _handle_stmt_CAS(self, stmt):
80
80
  pass
81
81
 
82
- def _handle_WrTmp(self, stmt):
82
+ def _handle_stmt_StoreG(self, stmt):
83
+ pass
84
+
85
+ def _handle_stmt_MBE(self, stmt):
86
+ pass
87
+
88
+ def _handle_stmt_Exit(self, stmt):
89
+ pass
90
+
91
+ def _handle_stmt_NoOp(self, stmt):
92
+ pass
93
+
94
+ def _handle_stmt_IMark(self, stmt):
95
+ pass
96
+
97
+ def _handle_stmt_AbiHint(self, stmt):
98
+ pass
99
+
100
+ def _process_block_end(self, stmt_result, whitelist):
101
+ pass
102
+
103
+ def _handle_stmt_WrTmp(self, stmt):
83
104
  if isinstance(stmt.data, pyvex.IRExpr.Get) and stmt.data.result_size(self.tyenv) == 64:
84
105
  self.tmps_with_64bit_regs.add(stmt.tmp)
85
106
  self.tmps_assignment_stmtidx[stmt.tmp] = self.stmt_idx
@@ -87,46 +108,36 @@ class VEXIRSBScanner(SimEngineLightVEXMixin):
87
108
  if isinstance(stmt.data, pyvex.IRExpr.Get) and stmt.data.result_size(self.tyenv) == 64:
88
109
  self.tmp_with_reg_as_value[stmt.tmp] = stmt.data.offset
89
110
 
90
- super()._handle_WrTmp(stmt)
111
+ self.tmps[stmt.tmp] = self._expr(stmt.data)
91
112
 
92
- def _handle_Get(self, expr):
113
+ def _handle_expr_Get(self, expr):
93
114
  self.reg_read_stmt_id[expr.offset] = self.stmt_idx
94
115
  if expr.offset in self.reg_with_reg_as_value:
95
116
  del self.reg_with_reg_as_value[expr.offset]
96
117
 
97
- def _handle_GetI(self, expr):
118
+ def _handle_expr_GetI(self, expr):
98
119
  pass
99
120
 
100
- def _handle_RdTmp(self, expr):
121
+ def _handle_expr_RdTmp(self, expr):
101
122
  if expr.tmp in self.tmps_converted_to_32bit:
102
123
  self.tmps_converted_to_32bit.remove(expr.tmp)
103
124
 
104
- def _handle_Conversion(self, expr: pyvex.IRExpr.Unop):
105
- if expr.op == "Iop_64to32" and isinstance(expr.args[0], pyvex.IRExpr.RdTmp):
106
- # special handling for t11 = GET:I64(rdi); t4 = 64to32(t11) style of code in x86-64 (and other 64-bit
107
- # architectures as well)
108
- tmp_src = expr.args[0].tmp
109
- if tmp_src in self.tmps_with_64bit_regs:
110
- self.tmps_converted_to_32bit.add(tmp_src)
111
-
112
- def _handle_16HLto32(self, expr):
125
+ def _handle_expr_Const(self, expr):
113
126
  pass
114
127
 
115
- def _handle_Cmp_v(self, expr, _vector_size, _vector_count):
128
+ def _handle_expr_ITE(self, expr):
116
129
  pass
117
130
 
118
- _handle_CmpEQ_v = _handle_Cmp_v
119
- _handle_CmpNE_v = _handle_Cmp_v
120
- _handle_CmpLE_v = _handle_Cmp_v
121
- _handle_CmpLT_v = _handle_Cmp_v
122
- _handle_CmpGE_v = _handle_Cmp_v
123
- _handle_CmpGT_v = _handle_Cmp_v
124
-
125
- def _handle_ExpCmpNE64(self, expr):
131
+ def _handle_expr_VECRET(self, expr):
126
132
  pass
127
133
 
128
- def _handle_CCall(self, expr):
134
+ def _handle_expr_GSPTR(self, expr):
129
135
  pass
130
136
 
131
- def _handle_function(self, func_addr):
132
- pass
137
+ def _handle_conversion(self, from_size, to_size, signed, operand):
138
+ if from_size == 64 and to_size == 32 and isinstance(operand, pyvex.IRExpr.RdTmp):
139
+ # special handling for t11 = GET:I64(rdi); t4 = 64to32(t11) style of code in x86-64 (and other 64-bit
140
+ # architectures as well)
141
+ tmp_src = operand.tmp
142
+ if tmp_src in self.tmps_with_64bit_regs:
143
+ self.tmps_converted_to_32bit.add(tmp_src)
@@ -2,11 +2,14 @@ from __future__ import annotations
2
2
  import logging
3
3
  from collections import defaultdict
4
4
 
5
+ import archinfo
5
6
  import claripy
6
7
 
8
+ import angr
7
9
  from angr.analyses import ForwardAnalysis, visitors
8
10
  from angr.analyses import AnalysesHub
9
11
  from angr.errors import SimMemoryMissingError
12
+ from angr.knowledge_plugins.functions.function import Function
10
13
  from angr.storage.memory_mixins.paged_memory.pages.multi_values import MultiValues
11
14
  from angr import BP, BP_AFTER
12
15
  from angr.sim_variable import SimRegisterVariable, SimStackVariable
@@ -24,8 +27,26 @@ class VariableRecoveryState(VariableRecoveryStateBase):
24
27
  :ivar angr.knowledge.variable_manager.VariableManager variable_manager: The variable manager.
25
28
  """
26
29
 
27
- def __init__(self, block_addr, analysis, arch, func, concrete_states, stack_region=None, register_region=None):
28
- super().__init__(block_addr, analysis, arch, func, stack_region=stack_region, register_region=register_region)
30
+ def __init__(
31
+ self,
32
+ project: angr.Project,
33
+ block_addr: int,
34
+ analysis,
35
+ arch: archinfo.Arch,
36
+ func: Function,
37
+ concrete_states,
38
+ stack_region=None,
39
+ register_region=None,
40
+ ):
41
+ super().__init__(
42
+ project=project,
43
+ block_addr=block_addr,
44
+ analysis=analysis,
45
+ arch=arch,
46
+ func=func,
47
+ stack_region=stack_region,
48
+ register_region=register_region,
49
+ )
29
50
 
30
51
  self._concrete_states = concrete_states
31
52
  # register callbacks
@@ -50,13 +71,14 @@ class VariableRecoveryState(VariableRecoveryStateBase):
50
71
  """
51
72
 
52
73
  for s in self.concrete_states:
53
- if s.ip.concrete_value == addr:
74
+ if s.addr == addr:
54
75
  return s
55
76
 
56
77
  return None
57
78
 
58
79
  def copy(self):
59
80
  return VariableRecoveryState(
81
+ self.project,
60
82
  self.block_addr,
61
83
  self._analysis,
62
84
  self.arch,
@@ -88,7 +110,7 @@ class VariableRecoveryState(VariableRecoveryStateBase):
88
110
  )
89
111
  concrete_state.inspect.add_breakpoint("mem_write", BP(enabled=True, action=self._hook_memory_write))
90
112
 
91
- def merge(self, others: tuple[VariableRecoveryState], successor=None) -> tuple[VariableRecoveryState, bool]:
113
+ def merge(self, others: tuple[VariableRecoveryState, ...], successor=None) -> tuple[VariableRecoveryState, bool]:
92
114
  """
93
115
  Merge two abstract states.
94
116
 
@@ -115,6 +137,7 @@ class VariableRecoveryState(VariableRecoveryStateBase):
115
137
 
116
138
  return (
117
139
  VariableRecoveryState(
140
+ self.project,
118
141
  successor,
119
142
  self._analysis,
120
143
  self.arch,
@@ -477,7 +500,7 @@ class VariableRecovery(ForwardAnalysis, VariableRecoveryBase): # pylint:disable
477
500
  # give it enough stack space
478
501
  concrete_state.regs.bp = concrete_state.regs.sp + 0x100000
479
502
 
480
- return VariableRecoveryState(node.addr, self, self.project.arch, self.function, [concrete_state])
503
+ return VariableRecoveryState(self.project, node.addr, self, self.project.arch, self.function, [concrete_state])
481
504
 
482
505
  def _merge_states(self, node, *states: VariableRecoveryState):
483
506
  if len(states) == 1:
@@ -1,17 +1,19 @@
1
1
  from __future__ import annotations
2
2
  import weakref
3
- from typing import Any, TYPE_CHECKING
3
+ from typing import Any, TYPE_CHECKING, cast, TypeVar
4
4
  from collections.abc import Generator, Iterable
5
5
  import logging
6
6
  from collections import defaultdict
7
7
 
8
+ import archinfo
8
9
  import claripy
9
10
  from claripy.annotation import Annotation
10
11
  from archinfo import Arch
11
12
  from ailment.expression import BinaryOp, StackBaseOffset
12
13
 
14
+ from angr.knowledge_plugins.functions.function import Function
15
+ from angr.project import Project
13
16
  from angr.utils.cowdict import DefaultChainMapCOW
14
- from angr.engines.light import SpOffset
15
17
  from angr.sim_variable import SimVariable
16
18
  from angr.errors import AngrRuntimeError
17
19
  from angr.storage.memory_mixins import MultiValuedMemory
@@ -24,6 +26,8 @@ if TYPE_CHECKING:
24
26
 
25
27
  l = logging.getLogger(name=__name__)
26
28
 
29
+ AnyClaripy = TypeVar("AnyClaripy", bound=claripy.ast.Base)
30
+
27
31
 
28
32
  def parse_stack_pointer(sp):
29
33
  """
@@ -152,10 +156,11 @@ class VariableRecoveryStateBase:
152
156
 
153
157
  def __init__(
154
158
  self,
155
- block_addr,
156
- analysis,
157
- arch,
158
- func,
159
+ block_addr: int,
160
+ analysis: VariableRecoveryBase,
161
+ arch: archinfo.Arch,
162
+ func: Function,
163
+ project: Project,
159
164
  stack_region=None,
160
165
  register_region=None,
161
166
  global_region=None,
@@ -164,7 +169,6 @@ class VariableRecoveryStateBase:
164
169
  func_typevar=None,
165
170
  delayed_type_constraints=None,
166
171
  stack_offset_typevars=None,
167
- project=None,
168
172
  ):
169
173
  self.block_addr = block_addr
170
174
  self._analysis = analysis
@@ -246,18 +250,16 @@ class VariableRecoveryStateBase:
246
250
  return bool(isinstance(thing, claripy.ast.BV) and thing.op == "BVS" and thing.args[0] == "top")
247
251
 
248
252
  @staticmethod
249
- def extract_variables(expr: claripy.ast.Base) -> Generator[tuple[int, SimVariable | SpOffset]]:
253
+ def extract_variables(expr: claripy.ast.Base) -> Generator[tuple[int, SimVariable]]:
250
254
  for anno in expr.annotations:
251
255
  if isinstance(anno, VariableAnnotation):
252
256
  yield from anno.addr_and_variables
253
257
 
254
258
  @staticmethod
255
- def annotate_with_variables(
256
- expr: claripy.ast.Base, addr_and_variables: Iterable[tuple[int, SimVariable | SpOffset]]
257
- ) -> claripy.ast.Base:
259
+ def annotate_with_variables(expr: AnyClaripy, addr_and_variables: Iterable[tuple[int, SimVariable]]) -> AnyClaripy:
258
260
  return expr.replace_annotations((VariableAnnotation(list(addr_and_variables)),))
259
261
 
260
- def stack_address(self, offset: int) -> claripy.ast.Base:
262
+ def stack_address(self, offset: int) -> claripy.ast.BV:
261
263
  base = claripy.BVS("stack_base", self.arch.bits, explicit_name=True)
262
264
  if offset:
263
265
  return base + offset
@@ -267,9 +269,9 @@ class VariableRecoveryStateBase:
267
269
  def is_stack_address(addr: claripy.ast.Base) -> bool:
268
270
  return "stack_base" in addr.variables
269
271
 
270
- def is_global_variable_address(self, addr: claripy.ast.Base) -> bool:
272
+ def is_global_variable_address(self, addr: claripy.ast.Bits) -> bool:
271
273
  if addr.op == "BVV":
272
- addr_v = addr.concrete_value
274
+ addr_v = cast(claripy.ast.BV, addr).concrete_value
273
275
  # make sure it is within a mapped region
274
276
  obj = self.project.loader.find_object_containing(addr_v)
275
277
  if obj is not None:
@@ -277,45 +279,42 @@ class VariableRecoveryStateBase:
277
279
  return False
278
280
 
279
281
  @staticmethod
280
- def extract_stack_offset_from_addr(addr: claripy.ast.Base) -> claripy.ast.Base | None:
282
+ def _get_stack_offset(addr: claripy.ast.Bits) -> int | None:
283
+ # recursive function that returns a python int without really trying to handle bitvector arithmetic wrapping
281
284
  r = None
282
285
  if addr.op == "BVS":
283
286
  if addr.args[0] == "stack_base":
284
- return claripy.BVV(0, addr.size())
287
+ return 0
285
288
  return None
286
289
  if addr.op == "BVV":
287
- r = addr
290
+ r = cast(int, addr.concrete_value)
288
291
  elif addr.op == "__add__":
289
292
  arg_offsets = []
290
- for arg in addr.args:
291
- arg_offset = VariableRecoveryStateBase.extract_stack_offset_from_addr(arg)
293
+ for arg in cast(list[claripy.ast.BV], addr.args):
294
+ arg_offset = VariableRecoveryStateBase._get_stack_offset(arg)
292
295
  if arg_offset is None:
293
296
  return None
294
297
  arg_offsets.append(arg_offset)
295
298
  r = sum(arg_offsets)
296
299
  elif addr.op == "__sub__":
297
- r1 = VariableRecoveryStateBase.extract_stack_offset_from_addr(addr.args[0])
298
- r2 = VariableRecoveryStateBase.extract_stack_offset_from_addr(addr.args[1])
300
+ r1 = VariableRecoveryStateBase._get_stack_offset(cast(claripy.ast.BV, addr.args[0]))
301
+ r2 = VariableRecoveryStateBase._get_stack_offset(cast(claripy.ast.BV, addr.args[1]))
299
302
  if r1 is None or r2 is None:
300
303
  return None
301
304
  r = r1 - r2
302
305
  return r
303
306
 
304
- def get_stack_offset(self, addr: claripy.ast.Base) -> int | None:
307
+ def get_stack_offset(self, addr: claripy.ast.Bits) -> int | None:
305
308
  if "stack_base" in addr.variables:
306
- r = VariableRecoveryStateBase.extract_stack_offset_from_addr(addr)
307
- if r is None:
309
+ val = VariableRecoveryStateBase._get_stack_offset(addr)
310
+ if val is None:
308
311
  return None
309
312
 
310
- # extract_stack_offset_from_addr should ensure that r is a BVV
311
- assert r.concrete
312
-
313
- val = r.concrete_value
314
313
  # convert it to a signed integer
315
- if val >= 2 ** (self.arch.bits - 1):
316
- return val - 2**self.arch.bits
317
- if val < -(2 ** (self.arch.bits - 1)):
318
- return 2**self.arch.bits + val
314
+ while val >= 2 ** (self.arch.bits - 1):
315
+ val -= 2**self.arch.bits
316
+ while val < -(2 ** (self.arch.bits - 1)):
317
+ val += 2**self.arch.bits
319
318
  return val
320
319
 
321
320
  return None
@@ -328,7 +327,7 @@ class VariableRecoveryStateBase:
328
327
  base = 0x7F_FFFF_FFFE_0000
329
328
  mask = 0xFFFF_FFFF_FFFF_FFFF
330
329
  else:
331
- raise AngrRuntimeError("Unsupported bits %d" % self.arch.bits)
330
+ raise AngrRuntimeError(f"Unsupported bits {self.arch.bits}")
332
331
  return (offset + base) & mask
333
332
 
334
333
  @property
@@ -414,7 +413,7 @@ class VariableRecoveryStateBase:
414
413
 
415
414
  return mos_self == mos_other
416
415
 
417
- def _make_phi_variable(self, values: set[claripy.ast.Base]) -> claripy.ast.Base | None:
416
+ def _make_phi_variable(self, values: set[claripy.ast.BV | claripy.ast.FP]) -> claripy.ast.Base | None:
418
417
  # we only create a new phi variable if the there is at least one variable involved
419
418
  variables = set()
420
419
  bits: int | None = None
@@ -74,11 +74,7 @@ class VariableRecoveryFastState(VariableRecoveryStateBase):
74
74
  self.ret_val_size = ret_val_size
75
75
 
76
76
  def __repr__(self):
77
- return "<VRAbstractState@%#x: %d register variables, %d stack variables>" % (
78
- self.block_addr,
79
- len(self.register_region),
80
- len(self.stack_region),
81
- )
77
+ return f"<VRAbstractState@{self.block_addr:#x}: {len(self.register_region)} register variables, {len(self.stack_region)} stack variables>"
82
78
 
83
79
  def __eq__(self, other):
84
80
  if type(other) is not VariableRecoveryFastState:
@@ -288,8 +284,8 @@ class VariableRecoveryFast(ForwardAnalysis, VariableRecoveryBase): # pylint:dis
288
284
 
289
285
  # cleanup (for cpython pickle)
290
286
  self.downsize()
291
- self._ail_engine = None
292
- self._vex_engine = None
287
+ del self._ail_engine
288
+ del self._vex_engine
293
289
 
294
290
  #
295
291
  # Main analysis routines
@@ -523,7 +519,7 @@ class VariableRecoveryFast(ForwardAnalysis, VariableRecoveryBase): # pylint:dis
523
519
  256: pyvex.const.V256,
524
520
  }
525
521
  if size not in mapping:
526
- raise TypeError("Unsupported size %d." % size)
522
+ raise TypeError(f"Unsupported size {size}.")
527
523
  return mapping.get(size)(value)
528
524
 
529
525
  def _peephole_optimize(self, block: Block):
@@ -339,7 +339,7 @@ class Veritesting(Analysis):
339
339
  for merge_point_addr, merge_point_looping_times in merge_points:
340
340
  manager.stash(
341
341
  lambda s, merge_point_addr=merge_point_addr: s.addr == merge_point_addr,
342
- to_stash="_merge_%x_%d" % (merge_point_addr, merge_point_looping_times),
342
+ to_stash=f"_merge_{merge_point_addr:x}_{merge_point_looping_times}",
343
343
  )
344
344
 
345
345
  # Try to merge a set of previously stashed paths, and then unstash them
@@ -370,7 +370,7 @@ class Veritesting(Analysis):
370
370
  if merged_anything:
371
371
  break
372
372
 
373
- stash_name = "_merge_%x_%d" % (merge_point_addr, merge_point_looping_times)
373
+ stash_name = f"_merge_{merge_point_addr:x}_{merge_point_looping_times}"
374
374
  if stash_name not in manager.stashes:
375
375
  continue
376
376
 
angr/analyses/vfg.py CHANGED
@@ -93,11 +93,11 @@ class PendingJob:
93
93
 
94
94
  __slots__ = (
95
95
  "block_id",
96
- "state",
97
96
  "call_stack",
98
97
  "src_block_id",
99
- "src_stmt_idx",
100
98
  "src_ins_addr",
99
+ "src_stmt_idx",
100
+ "state",
101
101
  )
102
102
 
103
103
  def __init__(
@@ -147,7 +147,7 @@ class FunctionAnalysis(AnalysisTask):
147
147
  self.jobs = []
148
148
 
149
149
  def __repr__(self):
150
- return "<Function @ %#08x with %d jobs>" % (self.function_address, len(self.jobs))
150
+ return f"<Function @ {self.function_address:#08x} with {len(self.jobs)} jobs>"
151
151
 
152
152
  #
153
153
  # Properties
@@ -182,7 +182,7 @@ class CallAnalysis(AnalysisTask):
182
182
  self._final_jobs = []
183
183
 
184
184
  def __repr__(self):
185
- return "<Call @ %#08x with %d function tasks>" % (self.address, len(self.function_analysis_tasks))
185
+ return f"<Call @ {self.address:#08x} with {len(self.function_analysis_tasks)} function tasks>"
186
186
 
187
187
  #
188
188
  # Properties
@@ -1668,7 +1668,7 @@ class VFG(ForwardAnalysis[SimState, VFGNode, VFGJob, BlockID], Analysis): # pyl
1668
1668
  except SimValueError:
1669
1669
  l.debug("- target cannot be concretized. %s [%s]", job.dbg_exit_status[suc], suc.history.jumpkind)
1670
1670
  l.debug("Remaining/pending jobs: %d/%d", len(self._job_info_queue), len(self._pending_returns))
1671
- l.debug("Remaining jobs: %s", ["%s %d" % (ent.job, id(ent.job)) for ent in self._job_info_queue])
1671
+ l.debug("Remaining jobs: %s", [f"{ent.job} {id(ent.job)}" for ent in self._job_info_queue])
1672
1672
  l.debug("Task stack: %s", self._task_stack)
1673
1673
 
1674
1674
  @staticmethod
angr/analyses/xrefs.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
  from collections import defaultdict
3
+ from typing import cast
3
4
 
4
5
  import claripy
5
6
  import pyvex
@@ -7,27 +8,29 @@ import pyvex
7
8
  from angr.analyses import visitors, ForwardAnalysis
8
9
  from angr.knowledge_plugins.xrefs import XRef, XRefType
9
10
  from angr.knowledge_plugins.functions.function import Function
10
- from angr.engines.light import SimEngineLight, SimEngineLightVEXMixin
11
+ from angr.engines.light import SimEngineNostmtVEX
11
12
  from .propagator.vex_vars import VEXTmp
12
13
  from .propagator.values import Top
13
14
  from . import register_analysis, PropagatorAnalysis
14
15
  from .analysis import Analysis
15
16
 
16
17
 
17
- class SimEngineXRefsVEX(
18
- SimEngineLightVEXMixin,
19
- SimEngineLight,
20
- ):
18
+ class SimEngineXRefsVEX(SimEngineNostmtVEX[None, None, None]): # go girl give us nothing!!
21
19
  """
22
20
  The VEX engine class for XRefs analysis.
23
21
  """
24
22
 
25
- def __init__(self, xref_manager, project=None, replacements=None):
26
- super().__init__()
27
- self.project = project
23
+ def __init__(self, xref_manager, project, replacements=None):
24
+ super().__init__(project)
28
25
  self.xref_manager = xref_manager
29
26
  self.replacements = replacements if replacements is not None else {}
30
27
 
28
+ def _top(self, bits):
29
+ return None
30
+
31
+ def _is_top(self, expr):
32
+ return True
33
+
31
34
  def add_xref(self, xref_type, from_loc, to_loc):
32
35
  self.xref_manager.add_xref(
33
36
  XRef(
@@ -49,24 +52,27 @@ class SimEngineXRefsVEX(
49
52
  """
50
53
 
51
54
  if isinstance(expr, claripy.ast.Base) and expr.op == "BVV":
52
- return expr.args[0]
55
+ return cast(int, expr.args[0])
56
+ return None
57
+
58
+ def _process_block_end(self, stmt_result, whitelist):
53
59
  return None
54
60
 
55
61
  #
56
62
  # Statement handlers
57
63
  #
58
64
 
59
- def _handle_WrTmp(self, stmt):
65
+ def _handle_stmt_WrTmp(self, stmt):
60
66
  # Don't execute the tmp write since it has been done during constant propagation
61
67
  self._expr(stmt.data)
62
68
  if type(stmt.data) is pyvex.IRExpr.Load:
63
69
  self._handle_data_offset_refs(stmt.tmp)
64
70
 
65
- def _handle_Put(self, stmt):
71
+ def _handle_stmt_Put(self, stmt):
66
72
  # if there is a Load, get it executed
67
73
  self._expr(stmt.data)
68
74
 
69
- def _handle_Store(self, stmt):
75
+ def _handle_stmt_Store(self, stmt):
70
76
  if isinstance(stmt.addr, pyvex.IRExpr.RdTmp):
71
77
  addr_tmp = VEXTmp(stmt.addr.tmp)
72
78
  blockloc = self._codeloc(block_only=True)
@@ -79,7 +85,7 @@ class SimEngineXRefsVEX(
79
85
  addr = stmt.addr.con.value
80
86
  self.add_xref(XRefType.Write, self._codeloc(), addr)
81
87
 
82
- def _handle_StoreG(self, stmt):
88
+ def _handle_stmt_StoreG(self, stmt):
83
89
  blockloc = self._codeloc(block_only=True)
84
90
  if type(stmt.addr) is pyvex.IRExpr.RdTmp:
85
91
  addr_tmp = VEXTmp(stmt.addr.tmp)
@@ -89,7 +95,7 @@ class SimEngineXRefsVEX(
89
95
  if addr_v is not None:
90
96
  self.add_xref(XRefType.Write, self._codeloc(), addr_v)
91
97
 
92
- def _handle_LoadG(self, stmt):
98
+ def _handle_stmt_LoadG(self, stmt):
93
99
  # What are we reading?
94
100
  blockloc = self._codeloc(block_only=True)
95
101
  if type(stmt.addr) is pyvex.IRExpr.RdTmp:
@@ -101,7 +107,7 @@ class SimEngineXRefsVEX(
101
107
  self.add_xref(XRefType.Read, self._codeloc(), addr_v)
102
108
  self._handle_data_offset_refs(stmt.dst)
103
109
 
104
- def _handle_LLSC(self, stmt: pyvex.IRStmt.LLSC):
110
+ def _handle_stmt_LLSC(self, stmt: pyvex.IRStmt.LLSC):
105
111
  blockloc = self._codeloc(block_only=True)
106
112
  if isinstance(stmt.addr, pyvex.IRExpr.RdTmp):
107
113
  addr_tmp = VEXTmp(stmt.addr.tmp)
@@ -135,10 +141,16 @@ class SimEngineXRefsVEX(
135
141
  # Expression handlers
136
142
  #
137
143
 
138
- def _handle_Get(self, expr):
144
+ def _handle_conversion(self, from_size, to_size, signed, operand):
139
145
  return None
140
146
 
141
- def _handle_Load(self, expr):
147
+ def _handle_expr_Const(self, expr):
148
+ return None
149
+
150
+ def _handle_expr_Get(self, expr):
151
+ return None
152
+
153
+ def _handle_expr_Load(self, expr):
142
154
  blockloc = self._codeloc(block_only=True)
143
155
  if type(expr.addr) is pyvex.IRExpr.RdTmp:
144
156
  addr_tmp = VEXTmp(expr.addr.tmp)
@@ -151,7 +163,22 @@ class SimEngineXRefsVEX(
151
163
  addr = expr.addr.con.value
152
164
  self.add_xref(XRefType.Read, self._codeloc(), addr)
153
165
 
154
- def _handle_CCall(self, expr):
166
+ def _handle_expr_CCall(self, expr):
167
+ return None
168
+
169
+ def _handle_expr_VECRET(self, expr):
170
+ return None
171
+
172
+ def _handle_expr_GSPTR(self, expr):
173
+ return None
174
+
175
+ def _handle_expr_ITE(self, expr):
176
+ return None
177
+
178
+ def _handle_expr_RdTmp(self, expr):
179
+ return None
180
+
181
+ def _handle_expr_GetI(self, expr):
155
182
  return None
156
183
 
157
184
  def _handle_function(self, func):
@@ -231,7 +258,7 @@ class XRefsAnalysis(ForwardAnalysis, Analysis): # pylint:disable=abstract-metho
231
258
  return None
232
259
 
233
260
  def _merge_states(self, node, *states):
234
- return None
261
+ return None, False
235
262
 
236
263
  def _run_on_node(self, node, state):
237
264
  block = self.project.factory.block(node.addr, node.size, opt_level=1, cross_insn_opt=False)
@@ -5,6 +5,6 @@ from .kb import KnowledgeBaseSerializer
5
5
 
6
6
 
7
7
  __all__ = (
8
- "LoaderSerializer",
9
8
  "KnowledgeBaseSerializer",
9
+ "LoaderSerializer",
10
10
  )