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
angr/slicer.py CHANGED
@@ -11,10 +11,10 @@ class SimLightState:
11
11
  """
12
12
 
13
13
  __slots__ = (
14
- "temps",
14
+ "options",
15
15
  "regs",
16
16
  "stack_offsets",
17
- "options",
17
+ "temps",
18
18
  )
19
19
 
20
20
  def __init__(self, temps=None, regs=None, stack_offsets=None, options=None):
@@ -155,11 +155,8 @@ class SimSlicer:
155
155
  def _forward_handler_expr_Get(self, expr, state):
156
156
  reg = expr.offset
157
157
 
158
- if (
159
- state.options["mock_sp"]
160
- and reg == self._arch.sp_offset
161
- or state.options["mock_bp"]
162
- and reg == self._arch.bp_offset
158
+ if (state.options["mock_sp"] and reg == self._arch.sp_offset) or (
159
+ state.options["mock_bp"] and reg == self._arch.bp_offset
163
160
  ):
164
161
  return state.regs[reg]
165
162
 
@@ -31,56 +31,56 @@ from .debug_variables import SimDebugVariable, SimDebugVariablePlugin
31
31
 
32
32
 
33
33
  __all__ = (
34
- "SimStatePlugin",
35
- "SimStateLibc",
36
- "SimInspector",
37
- "NO_OVERRIDE",
38
- "BP_BEFORE",
39
34
  "BP_AFTER",
35
+ "BP_BEFORE",
40
36
  "BP_BOTH",
41
37
  "BP_IPDB",
42
38
  "BP_IPYTHON",
39
+ "GDB",
40
+ "NO_OVERRIDE",
41
+ "CallStack",
42
+ "Concrete",
43
+ "PTChunk",
44
+ "PTChunkIterator",
43
45
  "PosixDevFS",
44
46
  "PosixProcFS",
45
- "SimSystemPosix",
46
- "SimSolver",
47
- "SimLightRegisters",
48
- "SimStateLog",
49
- "SimStateHistory",
50
- "SimStateScratch",
51
- "SimStateCGC",
52
- "GDB",
53
- "SimUCManager",
54
- "Unicorn",
55
47
  "SimAction",
56
- "SimActionExit",
57
48
  "SimActionConstraint",
58
- "SimActionOperation",
59
49
  "SimActionData",
50
+ "SimActionExit",
60
51
  "SimActionObject",
52
+ "SimActionOperation",
53
+ "SimDebugVariable",
54
+ "SimDebugVariablePlugin",
61
55
  "SimEvent",
62
- "resource_event",
63
- "CallStack",
64
- "SimStateGlobals",
65
- "SimStatePreconstrainer",
66
- "SimStateLoopData",
67
- "SimRegNameView",
68
- "SimMemView",
69
- "StructMode",
70
- "Stat",
71
56
  "SimFilesystem",
72
- "SimMount",
73
- "SimHostFilesystem",
74
57
  "SimHeapBase",
75
58
  "SimHeapBrk",
76
59
  "SimHeapLibc",
77
60
  "SimHeapPTMalloc",
78
- "PTChunk",
79
- "PTChunkIterator",
80
- "Concrete",
81
- "SimStateJNIReferences",
61
+ "SimHostFilesystem",
62
+ "SimInspector",
82
63
  "SimJavaVmClassloader",
64
+ "SimLightRegisters",
65
+ "SimMemView",
66
+ "SimMount",
67
+ "SimRegNameView",
68
+ "SimSolver",
69
+ "SimStateCGC",
70
+ "SimStateGlobals",
71
+ "SimStateHistory",
72
+ "SimStateJNIReferences",
73
+ "SimStateLibc",
74
+ "SimStateLog",
75
+ "SimStateLoopData",
76
+ "SimStatePlugin",
77
+ "SimStatePreconstrainer",
78
+ "SimStateScratch",
83
79
  "SimSymbolizer",
84
- "SimDebugVariable",
85
- "SimDebugVariablePlugin",
80
+ "SimSystemPosix",
81
+ "SimUCManager",
82
+ "Stat",
83
+ "StructMode",
84
+ "Unicorn",
85
+ "resource_event",
86
86
  )
@@ -119,14 +119,11 @@ class CallStack(SimStatePlugin):
119
119
  :return: A printable representation of the CallStack object
120
120
  :rtype: str
121
121
  """
122
- return "<CallStack (depth %d)>" % len(self)
122
+ return f"<CallStack (depth {len(self)})>"
123
123
 
124
124
  def __str__(self):
125
- return "Backtrace:\n{}".format(
126
- "\n".join(
127
- "Frame %d: %#x => %#x, sp = %#x" % (i, f.call_site_addr, f.func_addr, f.stack_ptr)
128
- for i, f in enumerate(self)
129
- )
125
+ return "Backtrace:\n" + "\n".join(
126
+ f"Frame {i}: {f.call_site_addr:#x} => {f.func_addr:#x}, sp = {f.stack_ptr:#x}" for i, f in enumerate(self)
130
127
  )
131
128
 
132
129
  def __eq__(self, other):
@@ -319,13 +316,9 @@ class CallStack(SimStatePlugin):
319
316
 
320
317
  stack = []
321
318
  for i, frame in enumerate(self):
322
- s = "%d | %s -> %s, returning to %s" % (
323
- i,
324
- "None" if frame.call_site_addr is None else f"{frame.call_site_addr:#x}",
325
- "None" if frame.func_addr is None else f"{frame.func_addr:#x}",
326
- "None" if frame.current_return_target is None else f"{frame.current_return_target:#x}",
319
+ stack.append(
320
+ f"{i} | {frame.call_site_addr:#x} -> {frame.func_addr:#x}, returning to {frame.current_return_target:#x}"
327
321
  )
328
- stack.append(s)
329
322
 
330
323
  return "\n".join(stack)
331
324
 
@@ -6,10 +6,10 @@ from .heap_libc import SimHeapLibc
6
6
  from .heap_ptmalloc import SimHeapPTMalloc, PTChunk, PTChunkIterator
7
7
 
8
8
  __all__ = (
9
+ "PTChunk",
10
+ "PTChunkIterator",
9
11
  "SimHeapBase",
10
12
  "SimHeapBrk",
11
13
  "SimHeapLibc",
12
14
  "SimHeapPTMalloc",
13
- "PTChunk",
14
- "PTChunkIterator",
15
15
  )
@@ -90,10 +90,8 @@ class SimHeapBrk(SimHeapBase):
90
90
 
91
91
  final_size = size * nmemb
92
92
 
93
- if (
94
- self.state.solver.symbolic(sim_nmemb)
95
- or self.state.solver.symbolic(sim_size)
96
- and final_size > plugin.max_variable_size
93
+ if self.state.solver.symbolic(sim_nmemb) or (
94
+ self.state.solver.symbolic(sim_size) and final_size > plugin.max_variable_size
97
95
  ):
98
96
  final_size = plugin.max_variable_size
99
97
 
@@ -75,7 +75,7 @@ class PTChunk(Chunk):
75
75
  next_chunk.set_prev_freeness(is_free)
76
76
  else:
77
77
  self.heap._set_final_freeness(is_free)
78
- if (is_free is not None and is_free or self.is_free()) and next_chunk is not None:
78
+ if ((is_free is not None and is_free) or self.is_free()) and next_chunk is not None:
79
79
  self.state.memory.store(next_chunk.base, size, size=self.state.arch.bytes)
80
80
 
81
81
  def set_prev_freeness(self, is_free):
@@ -30,8 +30,9 @@ class SimStateJNIReferences(SimStatePlugin):
30
30
  if opaque_ref_value in self.global_refs:
31
31
  return self.global_refs[opaque_ref_value]
32
32
  raise KeyError(
33
- "Unknown JNI reference %d. Local references: %s Global references: %s"
34
- % (opaque_ref_value, self.local_refs, self.global_refs)
33
+ f"Unknown JNI reference {opaque_ref_value}. "
34
+ f"Local references: {self.local_refs} "
35
+ f"Global references: {self.global_refs}"
35
36
  )
36
37
 
37
38
  def create_new_reference(self, obj, global_ref=False):
@@ -108,7 +108,7 @@ class SimStateScratch(SimStatePlugin):
108
108
  v = self.temps[tmp]
109
109
  if v is None:
110
110
  raise SimMissingTempError(
111
- "VEX temp variable %d does not exist. This is usually the result of an incorrect slicing." % tmp
111
+ f"VEX temp variable {tmp} does not exist. This is usually the result of an incorrect slicing."
112
112
  )
113
113
  except IndexError as err:
114
114
  raise SimMissingTempError("Accessing a temp that is illegal in this tyenv") from err
@@ -38,10 +38,7 @@ class SimAction(SimEvent):
38
38
  if self.sim_procedure is not None:
39
39
  location = f"{self.sim_procedure.display_name}()"
40
40
  else:
41
- if self.stmt_idx is not None:
42
- location = "0x%x:%d" % (self.ins_addr, self.stmt_idx) # TODO: Revert this!
43
- else:
44
- location = f"0x{self.bbl_addr:x}"
41
+ location = f"0x{self.ins_addr:x}:{self.stmt_idx}" if self.stmt_idx is not None else f"0x{self.bbl_addr:x}"
45
42
  return f"<{self.__class__.__name__} {location} {self._desc()}>"
46
43
 
47
44
  def _desc(self):
@@ -25,7 +25,7 @@ class SimEvent:
25
25
  self.arch = state.arch
26
26
 
27
27
  def __repr__(self):
28
- return "<SimEvent %s %d, with fields %s>" % (self.type, self.id, ", ".join(self.objects.keys()))
28
+ return f"<SimEvent {self.type} {self.id}, with fields {', '.join(self.objects.keys())}>"
29
29
 
30
30
  def _copy_event(self):
31
31
  c = self.__class__.__new__(self.__class__)
@@ -112,7 +112,7 @@ def error_converter(f):
112
112
  def _concrete_bool(e):
113
113
  if isinstance(e, bool):
114
114
  return e
115
- if isinstance(e, claripy.ast.Base) and e.op == "BoolV" or isinstance(e, SimActionObject) and e.op == "BoolV":
115
+ if (isinstance(e, claripy.ast.Base) and e.op == "BoolV") or (isinstance(e, SimActionObject) and e.op == "BoolV"):
116
116
  return e.args[0]
117
117
  return None
118
118
 
@@ -302,10 +302,8 @@ class SimSolver(SimStatePlugin):
302
302
  elif o.SYMBOLIC in self.state.options and o.COMPOSITE_SOLVER in self.state.options:
303
303
  self._stored_solver = claripy.SolverComposite(track=track)
304
304
  elif (
305
- o.SYMBOLIC in self.state.options
306
- and any(opt in self.state.options for opt in o.approximation)
307
- or o.HYBRID_SOLVER in self.state.options
308
- ):
305
+ o.SYMBOLIC in self.state.options and any(opt in self.state.options for opt in o.approximation)
306
+ ) or o.HYBRID_SOLVER in self.state.options:
309
307
  self._stored_solver = claripy.SolverHybrid(track=track, approximate_first=approximate_first)
310
308
  elif o.SYMBOLIC in self.state.options:
311
309
  self._stored_solver = claripy.Solver(track=track)
@@ -856,7 +854,7 @@ class SimSolver(SimStatePlugin):
856
854
 
857
855
  cast_vals = [self._cast_to(e, v, cast_to) for v in self._eval(e, n, **kwargs)]
858
856
  if len(cast_vals) == 0:
859
- raise SimUnsatError("Not satisfiable: %s, expected up to %d solutions" % (e.shallow_repr(), n))
857
+ raise SimUnsatError(f"Not satisfiable: {e.shallow_repr()}, expected up to {n} solutions")
860
858
  return cast_vals
861
859
 
862
860
  @overload
@@ -967,7 +965,7 @@ class SimSolver(SimStatePlugin):
967
965
  """
968
966
  r = self.eval_upto(e, n + 1, cast_to, **kwargs)
969
967
  if len(r) > n:
970
- raise SimValueError("Concretized %d values (must be at most %d) in eval_atmost" % (len(r), n))
968
+ raise SimValueError(f"Concretized {len(r)} values (must be at most {n}) in eval_atmost")
971
969
  return r
972
970
 
973
971
  @overload
@@ -1002,7 +1000,7 @@ class SimSolver(SimStatePlugin):
1002
1000
  """
1003
1001
  r = self.eval_upto(e, n, cast_to, **kwargs)
1004
1002
  if len(r) != n:
1005
- raise SimValueError("Concretized %d values (must be at least %d) in eval_atleast" % (len(r), n))
1003
+ raise SimValueError(f"Concretized {len(r)} values (must be at least {n}) in eval_atleast")
1006
1004
  return r
1007
1005
 
1008
1006
  @overload
@@ -1038,7 +1036,7 @@ class SimSolver(SimStatePlugin):
1038
1036
  """
1039
1037
  r = self.eval_upto(e, n + 1, cast_to, **kwargs)
1040
1038
  if len(r) != n:
1041
- raise SimValueError("Concretized %d values (must be exactly %d) in eval_exact" % (len(r), n))
1039
+ raise SimValueError(f"Concretized {len(r)} values (must be exactly {n}) in eval_exact")
1042
1040
  return r
1043
1041
 
1044
1042
  min_int = min
@@ -48,7 +48,7 @@ class SimUCManager(SimStatePlugin):
48
48
  dst_uc_alloc_depth = self._uc_alloc_depth[dst_addr_ast]
49
49
  if dst_uc_alloc_depth > self._max_alloc_depth:
50
50
  raise SimUCManagerAllocationError(
51
- "Current allocation depth %d is greater than the cap (%d)" % (dst_uc_alloc_depth, self._max_alloc_depth)
51
+ f"Current allocation depth {dst_uc_alloc_depth} is greater than the cap ({self._max_alloc_depth})"
52
52
  )
53
53
 
54
54
  abs_addr = self._region_base + self._pos
@@ -90,8 +90,8 @@ class SimRegNameView(SimStatePlugin):
90
90
  if self.state.arch.name in ("X86", "AMD64"):
91
91
  return (
92
92
  list(self.state.arch.registers.keys())
93
- + ["st%d" % n for n in range(8)]
94
- + ["tag%d" % n for n in range(8)]
93
+ + [f"st{n}" for n in range(8)]
94
+ + [f"tag{n}" for n in range(8)]
95
95
  + ["flags", "eflags", "rflags"]
96
96
  )
97
97
  if is_arm_arch(self.state.arch):
angr/storage/__init__.py CHANGED
@@ -9,7 +9,7 @@ from .memory_mixins import DefaultMemory
9
9
 
10
10
  __all__ = (
11
11
  "DUMMY_SYMBOLIC_READ_VALUE",
12
+ "DefaultMemory",
12
13
  "SimFile",
13
14
  "SimMemoryObject",
14
- "DefaultMemory",
15
15
  )
angr/storage/file.py CHANGED
@@ -109,7 +109,7 @@ class SimFileBase(SimStatePlugin):
109
109
  yield "?"
110
110
 
111
111
  nice_name = "".join(generate())
112
- return "file_%d_%s" % (next(file_counter), nice_name)
112
+ return f"file_{next(file_counter)}_{nice_name}"
113
113
 
114
114
  def concretize(self, **kwargs):
115
115
  """
@@ -250,7 +250,7 @@ class SimFile(SimFileBase, DefaultMemory): # TODO: pick a better base class omg
250
250
  if type(self._size) is int:
251
251
  self._size = claripy.BVV(self._size, state.arch.bits)
252
252
  elif len(self._size) != state.arch.bits:
253
- raise TypeError("SimFile size must be a bitvector of size %d (arch.bits)" % state.arch.bits)
253
+ raise TypeError(f"SimFile size must be a bitvector of size {state.arch.bits} (arch.bits)")
254
254
 
255
255
  @property
256
256
  def size(self):
@@ -379,7 +379,7 @@ class SimFileStream(SimFile):
379
379
  if type(self.pos) is int:
380
380
  self.pos = claripy.BVV(self.pos, state.arch.bits)
381
381
  elif len(self.pos) != state.arch.bits:
382
- raise TypeError("SimFileStream position must be a bitvector of size %d (arch.bits)" % state.arch.bits)
382
+ raise TypeError(f"SimFileStream position must be a bitvector of size {state.arch.bits} (arch.bits)")
383
383
 
384
384
  def read(self, pos, size, **kwargs):
385
385
  no_stream = kwargs.pop("no_stream", False)
@@ -509,9 +509,9 @@ class SimPackets(SimFileBase):
509
509
  if pos is None:
510
510
  pos = len(self.content)
511
511
  if pos < 0:
512
- raise SimFileError("SimPacket.read(%d): Negative packet number?" % pos)
512
+ raise SimFileError(f"SimPacket.read({pos}): Negative packet number?")
513
513
  if pos > len(self.content):
514
- raise SimFileError("SimPacket.read(%d): Packet number is past frontier of %d?" % (pos, len(self.content)))
514
+ raise SimFileError(f"SimPacket.read({pos}): Packet number is past frontier of {len(self.content)}?")
515
515
  if pos != len(self.content):
516
516
  _, realsize = self.content[pos]
517
517
  self.state.add_constraints(realsize <= size) # assert that the packet fits within the read request
@@ -533,7 +533,7 @@ class SimPackets(SimFileBase):
533
533
  # if short reads are enabled, replace size with a symbol
534
534
  if short_reads is True or (short_reads is None and sim_options.SHORT_READS in self.state.options):
535
535
  size = self.state.solver.BVS(
536
- "packetsize_%d_%s" % (len(self.content), self.ident),
536
+ f"packetsize_{len(self.content)}_{self.ident}",
537
537
  self.state.arch.bits,
538
538
  key=("file", self.ident, "packetsize", len(self.content)),
539
539
  )
@@ -561,7 +561,7 @@ class SimPackets(SimFileBase):
561
561
 
562
562
  # generate the packet data and return it
563
563
  data = self.state.solver.BVS(
564
- "packet_%d_%s" % (len(self.content), self.ident),
564
+ f"packet_{len(self.content)}_{self.ident}",
565
565
  max_size * self.state.arch.byte_width,
566
566
  key=("file", self.ident, "packet", len(self.content)),
567
567
  )
@@ -601,9 +601,9 @@ class SimPackets(SimFileBase):
601
601
  if pos is None:
602
602
  pos = len(self.content)
603
603
  if pos < 0:
604
- raise SimFileError("SimPacket.write(%d): Negative packet number?" % pos)
604
+ raise SimFileError(f"SimPacket.write({pos}): Negative packet number?")
605
605
  if pos > len(self.content):
606
- raise SimFileError("SimPacket.write(%d): Packet number is past frontier of %d?" % (pos, len(self.content)))
606
+ raise SimFileError(f"SimPacket.write({pos}): Packet number is past frontier of {len(self.content)}?")
607
607
  if pos != len(self.content):
608
608
  realdata, realsize = self.content[pos]
609
609
  maxlen = max(len(realdata), len(data))
@@ -1171,7 +1171,7 @@ class SimPacketsSlots(SimFileBase):
1171
1171
  self.read_sizes.pop(0)
1172
1172
 
1173
1173
  data = self.state.solver.BVS(
1174
- "packet_%d_%s" % (len(self.read_data), self.ident),
1174
+ f"packet_{len(self.read_data)}_{self.ident}",
1175
1175
  real_size * self.state.arch.byte_width,
1176
1176
  key=("file", self.ident, "packet", len(self.read_data)),
1177
1177
  )
@@ -249,69 +249,69 @@ SimState.register_default("javavm_memory", JavaVmMemory)
249
249
 
250
250
 
251
251
  __all__ = (
252
+ "AbstractMemory",
253
+ "AbstractMergerMixin",
252
254
  "ActionsMixinHigh",
253
255
  "ActionsMixinLow",
254
256
  "AddressConcretizationMixin",
255
- "DataNormalizationMixin",
256
- "InspectMixinHigh",
257
+ "ClemoryBackerMixin",
258
+ "ConcreteBackerMixin",
257
259
  "ConditionalMixin",
258
260
  "ConvenientMappingsMixin",
261
+ "CooperationBase",
262
+ "DataNormalizationMixin",
259
263
  "DefaultFillerMixin",
260
- "SpecialFillerMixin",
261
- "ExplicitFillerMixin",
264
+ "DefaultListPagesMemory",
265
+ "DefaultMemory",
266
+ "DictBackerMixin",
262
267
  "DirtyAddrsMixin",
268
+ "ExplicitFillerMixin",
269
+ "FastMemory",
263
270
  "HexDumperMixin",
271
+ "HistoryTrackingMixin",
272
+ "ISPOMixin",
273
+ "InspectMixinHigh",
274
+ "JavaVmMemory",
275
+ "JavaVmMemoryMixin",
276
+ "KeyValueMemory",
277
+ "KeyValueMemoryMixin",
264
278
  "LabelMergerMixin",
265
- "MultiValueMergerMixin",
266
- "NameResolutionMixin",
267
- "SimplificationMixin",
268
- "SimpleInterfaceMixin",
269
- "SizeNormalizationMixin",
270
- "SizeConcretizationMixin",
271
- "SmartFindMixin",
272
- "SymbolicMergerMixin",
273
- "TopMergerMixin",
274
- "UnderconstrainedMixin",
275
- "UnwrapperMixin",
276
- "ClemoryBackerMixin",
277
- "ConcreteBackerMixin",
278
- "DictBackerMixin",
279
- "PagedMemoryMixin",
279
+ "LabeledMemory",
280
+ "ListPage",
280
281
  "ListPagesMixin",
281
- "UltraPagesMixin",
282
282
  "ListPagesWithLabelsMixin",
283
+ "MVListPage",
283
284
  "MVListPagesMixin",
284
285
  "MVListPagesWithLabelsMixin",
285
- "PrivilegedPagingMixin",
286
- "StackAllocationMixin",
287
- "PagedMemoryMultiValueMixin",
288
- "CooperationBase",
289
286
  "MemoryObjectMixin",
290
- "ISPOMixin",
291
- "RefcountMixin",
292
- "PermissionsMixin",
293
- "HistoryTrackingMixin",
287
+ "MemoryRegionMetaMixin",
288
+ "MultiValueMergerMixin",
289
+ "MultiValuedMemory",
290
+ "NameResolutionMixin",
294
291
  "PageBase",
295
292
  "PageType",
296
- "ListPage",
297
- "MVListPage",
298
- "UltraPage",
299
- "SlottedMemoryMixin",
300
- "RegionedMemoryMixin",
293
+ "PagedMemoryMixin",
294
+ "PagedMemoryMultiValueMixin",
295
+ "PermissionsMixin",
296
+ "PrivilegedPagingMixin",
297
+ "RefcountMixin",
301
298
  "RegionCategoryMixin",
302
- "StaticFindMixin",
303
- "AbstractMergerMixin",
304
- "MemoryRegionMetaMixin",
305
299
  "RegionedAddressConcretizationMixin",
306
- "KeyValueMemoryMixin",
307
- "JavaVmMemoryMixin",
308
- "DefaultMemory",
309
- "DefaultListPagesMemory",
310
- "FastMemory",
311
- "AbstractMemory",
312
300
  "RegionedMemory",
313
- "LabeledMemory",
314
- "MultiValuedMemory",
315
- "KeyValueMemory",
316
- "JavaVmMemory",
301
+ "RegionedMemoryMixin",
302
+ "SimpleInterfaceMixin",
303
+ "SimplificationMixin",
304
+ "SizeConcretizationMixin",
305
+ "SizeNormalizationMixin",
306
+ "SlottedMemoryMixin",
307
+ "SmartFindMixin",
308
+ "SpecialFillerMixin",
309
+ "StackAllocationMixin",
310
+ "StaticFindMixin",
311
+ "SymbolicMergerMixin",
312
+ "TopMergerMixin",
313
+ "UltraPage",
314
+ "UltraPagesMixin",
315
+ "UnderconstrainedMixin",
316
+ "UnwrapperMixin",
317
317
  )
@@ -30,9 +30,7 @@ class DefaultFillerMixin(MemoryMixin):
30
30
  type(addr) is int
31
31
  and self.category == "mem"
32
32
  and options.ZERO_FILL_UNCONSTRAINED_MEMORY in self.state.options
33
- or self.category == "reg"
34
- and options.ZERO_FILL_UNCONSTRAINED_REGISTERS in self.state.options
35
- ):
33
+ ) or (self.category == "reg" and options.ZERO_FILL_UNCONSTRAINED_REGISTERS in self.state.options):
36
34
  return claripy.BVV(0, bits)
37
35
 
38
36
  if self.category == "reg" and type(addr) is int and addr == self.state.arch.ip_offset:
@@ -192,7 +192,7 @@ class JavaVmMemoryMixin(MemoryMixin):
192
192
  self.state.add_constraints(constraint_on_start_idx)
193
193
 
194
194
  def _store_array_element_on_heap(self, array, idx, value, value_type, store_condition=None):
195
- heap_elem_id = "%s[%d]" % (array.id, idx)
195
+ heap_elem_id = f"{array.id}[{idx}]"
196
196
  l.debug("Set %s to %s with condition %s", heap_elem_id, value, store_condition)
197
197
  if store_condition is not None:
198
198
  current_value = self._load_array_element_from_heap(array, idx)
@@ -267,7 +267,7 @@ class JavaVmMemoryMixin(MemoryMixin):
267
267
 
268
268
  def _load_array_element_from_heap(self, array: SimSootValue_ArrayBaseRef, idx):
269
269
  # try to load the element
270
- heap_elem_id = "%s[%d]" % (array.id, idx)
270
+ heap_elem_id = f"{array.id}[{idx}]"
271
271
  value = self.heap.load(heap_elem_id, none_if_missing=True)
272
272
  # if it's not available, initialize it
273
273
  if value is None:
@@ -5,8 +5,8 @@ from archinfo.arch_arm import is_arm_arch
5
5
 
6
6
  from angr.storage.memory_mixins.memory_mixin import MemoryMixin
7
7
 
8
- stn_map = {"st%d" % n: n for n in range(8)}
9
- tag_map = {"tag%d" % n: n for n in range(8)}
8
+ stn_map = {f"st{n}": n for n in range(8)}
9
+ tag_map = {f"tag{n}": n for n in range(8)}
10
10
 
11
11
 
12
12
  class NameResolutionMixin(MemoryMixin):
@@ -107,9 +107,7 @@ class PagedMemoryMixin(
107
107
  permissions = perms
108
108
  break
109
109
 
110
- return dict(
111
- memory=self, memory_id="%s_%d" % (self.id, pageno), permissions=permissions, **self._extra_page_kwargs
112
- )
110
+ return dict(memory=self, memory_id=f"{self.id}_{pageno}", permissions=permissions, **self._extra_page_kwargs)
113
111
 
114
112
  def _divide_addr(self, addr: int) -> tuple[int, int]:
115
113
  return divmod(addr, self.page_size)
@@ -34,14 +34,14 @@ from .ultra_page import UltraPage
34
34
 
35
35
  __all__ = (
36
36
  "CooperationBase",
37
- "MemoryObjectMixin",
38
- "ISPOMixin",
39
- "RefcountMixin",
40
- "PermissionsMixin",
41
37
  "HistoryTrackingMixin",
42
- "PageBase",
43
- "PageType",
38
+ "ISPOMixin",
44
39
  "ListPage",
45
40
  "MVListPage",
41
+ "MemoryObjectMixin",
42
+ "PageBase",
43
+ "PageType",
44
+ "PermissionsMixin",
45
+ "RefcountMixin",
46
46
  "UltraPage",
47
47
  )
@@ -263,7 +263,7 @@ class ListPage(MemoryObjectMixin, PageBase):
263
263
  for c in candidates:
264
264
  s_contains = self._contains(c, page_addr)
265
265
  o_contains = other._contains(c, page_addr)
266
- if not s_contains and o_contains or s_contains and not o_contains:
266
+ if (not s_contains and o_contains) or (s_contains and not o_contains):
267
267
  differences.add(c)
268
268
  else:
269
269
  if self.content[c] is None:
@@ -20,8 +20,8 @@ class MultiValues(Generic[MVType]):
20
20
  """
21
21
 
22
22
  __slots__ = (
23
- "_values",
24
23
  "_single_value",
24
+ "_values",
25
25
  )
26
26
 
27
27
  _single_value: MVType | None
@@ -330,7 +330,7 @@ class MVListPage(
330
330
  for c in candidates:
331
331
  s_contains = self._contains(c, page_addr)
332
332
  o_contains = other._contains(c, page_addr)
333
- if not s_contains and o_contains or s_contains and not o_contains:
333
+ if (not s_contains and o_contains) or (s_contains and not o_contains):
334
334
  differences.add(c)
335
335
  else:
336
336
  if self.content[c] is None and self.sinkhole is not None:
@@ -430,10 +430,8 @@ class UltraPage(MemoryObjectMixin, PageBase):
430
430
  return None
431
431
  else:
432
432
  obj = self.symbolic_data[place]
433
- if (
434
- obj.includes(start + page_addr)
435
- or memory is not None
436
- and obj.includes(start + page_addr + (1 << memory.state.arch.bits))
433
+ if obj.includes(start + page_addr) or (
434
+ memory is not None and obj.includes(start + page_addr + (1 << memory.state.arch.bits))
437
435
  ):
438
436
  return obj
439
437
  return None