angr 9.2.132__py3-none-win_amd64.whl → 9.2.133__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 (203) hide show
  1. angr/__init__.py +128 -128
  2. angr/analyses/__init__.py +38 -38
  3. angr/analyses/backward_slice.py +3 -4
  4. angr/analyses/binary_optimizer.py +5 -12
  5. angr/analyses/bindiff.py +3 -6
  6. angr/analyses/calling_convention.py +3 -4
  7. angr/analyses/cfg/__init__.py +3 -3
  8. angr/analyses/cfg/cfg_base.py +1 -1
  9. angr/analyses/cfg/cfg_fast.py +17 -15
  10. angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
  11. angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
  12. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +9 -7
  13. angr/analyses/data_dep/__init__.py +4 -4
  14. angr/analyses/datagraph_meta.py +1 -1
  15. angr/analyses/ddg.py +2 -6
  16. angr/analyses/decompiler/__init__.py +12 -12
  17. angr/analyses/decompiler/ail_simplifier.py +21 -10
  18. angr/analyses/decompiler/block_similarity.py +2 -4
  19. angr/analyses/decompiler/callsite_maker.py +1 -1
  20. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
  21. angr/analyses/decompiler/clinic.py +14 -7
  22. angr/analyses/decompiler/condition_processor.py +45 -29
  23. angr/analyses/decompiler/counters/__init__.py +3 -3
  24. angr/analyses/decompiler/decompilation_cache.py +7 -7
  25. angr/analyses/decompiler/dephication/__init__.py +1 -1
  26. angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
  27. angr/analyses/decompiler/expression_narrower.py +1 -1
  28. angr/analyses/decompiler/graph_region.py +8 -8
  29. angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
  30. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
  31. angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
  32. angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
  33. angr/analyses/decompiler/optimization_passes/engine_base.py +1 -1
  34. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +2 -4
  35. angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
  36. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
  37. angr/analyses/decompiler/optimization_passes/mod_simplifier.py +9 -3
  38. angr/analyses/decompiler/optimization_passes/optimization_pass.py +3 -0
  39. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
  40. angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
  41. angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
  42. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
  43. angr/analyses/decompiler/presets/__init__.py +1 -1
  44. angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
  45. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
  46. angr/analyses/decompiler/ssailification/rewriting_engine.py +1 -1
  47. angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
  48. angr/analyses/decompiler/structured_codegen/base.py +3 -3
  49. angr/analyses/decompiler/structured_codegen/c.py +34 -37
  50. angr/analyses/decompiler/structuring/__init__.py +3 -3
  51. angr/analyses/decompiler/structuring/phoenix.py +19 -20
  52. angr/analyses/decompiler/structuring/structurer_base.py +2 -2
  53. angr/analyses/decompiler/structuring/structurer_nodes.py +14 -14
  54. angr/analyses/deobfuscator/__init__.py +3 -3
  55. angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
  56. angr/analyses/disassembly.py +4 -4
  57. angr/analyses/forward_analysis/__init__.py +1 -1
  58. angr/analyses/forward_analysis/visitors/graph.py +6 -6
  59. angr/analyses/loop_analysis.py +1 -1
  60. angr/analyses/loopfinder.py +1 -1
  61. angr/analyses/propagator/outdated_definition_walker.py +12 -6
  62. angr/analyses/propagator/vex_vars.py +3 -3
  63. angr/analyses/reaching_definitions/__init__.py +9 -9
  64. angr/analyses/reaching_definitions/call_trace.py +2 -2
  65. angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
  66. angr/analyses/reaching_definitions/rd_state.py +10 -10
  67. angr/analyses/reassembler.py +26 -31
  68. angr/analyses/s_liveness.py +8 -0
  69. angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
  70. angr/analyses/stack_pointer_tracker.py +4 -4
  71. angr/analyses/typehoon/simple_solver.py +7 -9
  72. angr/analyses/typehoon/translator.py +2 -2
  73. angr/analyses/typehoon/typeconsts.py +1 -1
  74. angr/analyses/typehoon/typevars.py +17 -19
  75. angr/analyses/unpacker/__init__.py +1 -1
  76. angr/analyses/variable_recovery/engine_base.py +3 -4
  77. angr/analyses/variable_recovery/variable_recovery_base.py +1 -1
  78. angr/analyses/variable_recovery/variable_recovery_fast.py +2 -6
  79. angr/analyses/veritesting.py +2 -2
  80. angr/analyses/vfg.py +5 -5
  81. angr/angrdb/serializers/__init__.py +1 -1
  82. angr/annocfg.py +1 -1
  83. angr/blade.py +2 -2
  84. angr/block.py +16 -16
  85. angr/calling_conventions.py +11 -13
  86. angr/code_location.py +6 -10
  87. angr/codenode.py +3 -3
  88. angr/engines/__init__.py +12 -14
  89. angr/engines/engine.py +1 -54
  90. angr/engines/light/__init__.py +4 -4
  91. angr/engines/light/data.py +1 -1
  92. angr/engines/pcode/__init__.py +1 -1
  93. angr/engines/pcode/behavior.py +1 -1
  94. angr/engines/pcode/lifter.py +13 -15
  95. angr/engines/soot/expressions/__init__.py +12 -12
  96. angr/engines/soot/statements/__init__.py +6 -6
  97. angr/engines/soot/values/__init__.py +6 -6
  98. angr/engines/soot/values/arrayref.py +2 -2
  99. angr/engines/soot/values/constants.py +1 -1
  100. angr/engines/soot/values/instancefieldref.py +1 -1
  101. angr/engines/soot/values/paramref.py +1 -1
  102. angr/engines/soot/values/staticfieldref.py +1 -1
  103. angr/engines/successors.py +2 -5
  104. angr/engines/vex/__init__.py +5 -5
  105. angr/engines/vex/claripy/ccall.py +2 -2
  106. angr/engines/vex/claripy/irop.py +18 -18
  107. angr/engines/vex/heavy/__init__.py +2 -2
  108. angr/engines/vex/heavy/actions.py +1 -3
  109. angr/engines/vex/heavy/heavy.py +4 -6
  110. angr/engines/vex/lifter.py +2 -4
  111. angr/engines/vex/light/light.py +0 -2
  112. angr/engines/vex/light/slicing.py +3 -3
  113. angr/exploration_techniques/__init__.py +18 -18
  114. angr/exploration_techniques/threading.py +0 -6
  115. angr/factory.py +36 -6
  116. angr/keyed_region.py +4 -4
  117. angr/knowledge_base.py +1 -1
  118. angr/knowledge_plugins/__init__.py +11 -11
  119. angr/knowledge_plugins/cfg/__init__.py +5 -5
  120. angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
  121. angr/knowledge_plugins/cfg/cfg_model.py +8 -8
  122. angr/knowledge_plugins/cfg/cfg_node.py +19 -19
  123. angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
  124. angr/knowledge_plugins/cfg/memory_data.py +5 -7
  125. angr/knowledge_plugins/functions/function.py +48 -52
  126. angr/knowledge_plugins/functions/function_parser.py +4 -4
  127. angr/knowledge_plugins/key_definitions/__init__.py +3 -3
  128. angr/knowledge_plugins/key_definitions/atoms.py +6 -6
  129. angr/knowledge_plugins/key_definitions/definition.py +1 -1
  130. angr/knowledge_plugins/key_definitions/live_definitions.py +14 -14
  131. angr/knowledge_plugins/labels.py +1 -1
  132. angr/knowledge_plugins/propagations/__init__.py +1 -1
  133. angr/knowledge_plugins/propagations/prop_value.py +2 -2
  134. angr/knowledge_plugins/propagations/propagation_model.py +7 -8
  135. angr/knowledge_plugins/propagations/states.py +31 -31
  136. angr/knowledge_plugins/variables/variable_access.py +2 -2
  137. angr/knowledge_plugins/variables/variable_manager.py +1 -1
  138. angr/knowledge_plugins/xrefs/xref.py +5 -8
  139. angr/lib/angr_native.dll +0 -0
  140. angr/misc/__init__.py +4 -4
  141. angr/misc/hookset.py +4 -5
  142. angr/misc/loggers.py +2 -2
  143. angr/misc/telemetry.py +1 -1
  144. angr/procedures/__init__.py +1 -1
  145. angr/procedures/cgc/fdwait.py +2 -2
  146. angr/procedures/definitions/__init__.py +2 -2
  147. angr/procedures/definitions/linux_kernel.py +0 -1
  148. angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
  149. angr/procedures/definitions/parse_win32json.py +0 -1
  150. angr/procedures/ntdll/exceptions.py +1 -1
  151. angr/procedures/stubs/format_parser.py +3 -3
  152. angr/procedures/win32/dynamic_loading.py +1 -1
  153. angr/protos/__init__.py +3 -3
  154. angr/sim_manager.py +2 -2
  155. angr/sim_state.py +1 -1
  156. angr/sim_state_options.py +3 -3
  157. angr/sim_type.py +10 -14
  158. angr/sim_variable.py +13 -17
  159. angr/simos/__init__.py +4 -4
  160. angr/simos/cgc.py +1 -1
  161. angr/simos/simos.py +1 -1
  162. angr/simos/userland.py +1 -1
  163. angr/slicer.py +4 -7
  164. angr/state_plugins/__init__.py +34 -34
  165. angr/state_plugins/callstack.py +5 -12
  166. angr/state_plugins/heap/__init__.py +2 -2
  167. angr/state_plugins/heap/heap_brk.py +2 -4
  168. angr/state_plugins/heap/heap_ptmalloc.py +1 -1
  169. angr/state_plugins/jni_references.py +3 -2
  170. angr/state_plugins/scratch.py +1 -1
  171. angr/state_plugins/sim_action.py +1 -4
  172. angr/state_plugins/sim_event.py +1 -1
  173. angr/state_plugins/solver.py +7 -9
  174. angr/state_plugins/uc_manager.py +1 -1
  175. angr/state_plugins/view.py +2 -2
  176. angr/storage/__init__.py +1 -1
  177. angr/storage/file.py +10 -10
  178. angr/storage/memory_mixins/__init__.py +46 -46
  179. angr/storage/memory_mixins/default_filler_mixin.py +1 -3
  180. angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
  181. angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
  182. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
  183. angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
  184. angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
  185. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
  186. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
  187. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
  188. angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
  189. angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
  190. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
  191. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
  192. angr/storage/memory_object.py +4 -4
  193. angr/utils/__init__.py +3 -3
  194. angr/utils/dynamic_dictlist.py +1 -1
  195. angr/utils/graph.py +1 -1
  196. angr/utils/segment_list.py +2 -2
  197. angr/utils/ssa/__init__.py +12 -5
  198. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
  199. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/RECORD +203 -203
  200. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
  201. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
  202. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
  203. {angr-9.2.132.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
@@ -56,21 +56,21 @@ class ReachingDefinitionsState:
56
56
  """
57
57
 
58
58
  __slots__ = (
59
- "arch",
59
+ "_canonical_size",
60
+ "_element_limit",
61
+ "_environment",
62
+ "_sp_adjusted",
60
63
  "_subject",
64
+ "_track_consts",
61
65
  "_track_tmps",
66
+ "all_definitions",
62
67
  "analysis",
68
+ "arch",
63
69
  "codeloc",
64
70
  "codeloc_uses",
65
- "live_definitions",
66
- "all_definitions",
67
- "_canonical_size",
68
- "heap_allocator",
69
- "_environment",
70
- "_track_consts",
71
- "_sp_adjusted",
72
71
  "exit_observed",
73
- "_element_limit",
72
+ "heap_allocator",
73
+ "live_definitions",
74
74
  )
75
75
 
76
76
  def __init__(
@@ -177,7 +177,7 @@ class ReachingDefinitionsState:
177
177
  return claripy.BVS("stack_base", 32, explicit_name=True)
178
178
  if self.arch.bits == 64:
179
179
  return claripy.BVS("stack_base", 64, explicit_name=True)
180
- raise ValueError("Unsupported architecture word size %d" % self.arch.bits)
180
+ raise ValueError(f"Unsupported architecture word size {self.arch.bits}")
181
181
 
182
182
  def _to_signed(self, n):
183
183
  if n >= 2 ** (self.arch.bits - 1):
@@ -152,7 +152,7 @@ class Label:
152
152
  self.var_size = None
153
153
 
154
154
  if self.name is None:
155
- self.name = "label_%d" % next(Label.g_label_ctr)
155
+ self.name = f"label_{next(Label.g_label_ctr)}"
156
156
 
157
157
  self.original_addr = original_addr
158
158
  self.base_addr = None
@@ -189,7 +189,7 @@ class Label:
189
189
  offset = self.offset
190
190
  sign = "+" if offset >= 0 else "-"
191
191
  offset = abs(offset)
192
- return ".%s%s%d" % (self.name, sign, offset)
192
+ return f".{self.name}{sign}{offset}"
193
193
 
194
194
  @property
195
195
  def offset(self):
@@ -318,7 +318,7 @@ class SymbolManager:
318
318
 
319
319
  i = 0
320
320
  while True:
321
- name = "%s_%d" % (symbol_name, i)
321
+ name = f"{symbol_name}_{i}"
322
322
  if name not in self.symbol_names:
323
323
  self.symbol_names.add(name)
324
324
  return name
@@ -473,9 +473,9 @@ class Operand:
473
473
  def assembly(self):
474
474
  if self.type == OP_TYPE_IMM and self.label:
475
475
  if self.label_offset > 0:
476
- return "%s + %d" % (self.label.operand_str, self.label_offset)
476
+ return f"{self.label.operand_str} + {self.label_offset}"
477
477
  if self.label_offset < 0:
478
- return "%s - %d" % (self.label.operand_str, abs(self.label_offset))
478
+ return f"{self.label.operand_str} - {abs(self.label_offset)}"
479
479
  return self.label.operand_str
480
480
 
481
481
  if self.type == OP_TYPE_MEM:
@@ -483,13 +483,13 @@ class Operand:
483
483
  if self.disp:
484
484
  if self.disp_label:
485
485
  if self.disp_label_offset > 0:
486
- disp = "%s + %d" % (self.disp_label.operand_str, self.disp_label_offset)
486
+ disp = f"{self.disp_label.operand_str} + {self.disp_label_offset}"
487
487
  elif self.disp_label_offset < 0:
488
- disp = "%s - %d" % (self.disp_label.operand_str, abs(self.disp_label_offset))
488
+ disp = f"{self.disp_label.operand_str} - {abs(self.disp_label_offset)}"
489
489
  else:
490
490
  disp = self.disp_label.operand_str
491
491
  else:
492
- disp = "%d" % self.disp
492
+ disp = f"{self.disp}"
493
493
 
494
494
  base = ""
495
495
  if self.base:
@@ -504,12 +504,7 @@ class Operand:
504
504
  disp = "*" + disp
505
505
 
506
506
  if self.index:
507
- s = "%s(%s, %%%s, %d)" % (
508
- disp,
509
- base,
510
- CAPSTONE_REG_MAP[self.project.arch.name][self.index],
511
- self.scale,
512
- )
507
+ s = f"{disp}({base}, %{CAPSTONE_REG_MAP[self.project.arch.name][self.index]}, {self.scale})"
513
508
  elif self.base: # not self.index
514
509
  s = f"{disp}({base})"
515
510
  else:
@@ -524,7 +519,7 @@ class Operand:
524
519
  if self.index and self.scale:
525
520
  if s:
526
521
  s.append("+")
527
- s.append("(%s * %d)" % (CAPSTONE_REG_MAP[self.project.arch.name][self.index], self.scale))
522
+ s.append(f"({CAPSTONE_REG_MAP[self.project.arch.name][self.index]} * {self.scale})")
528
523
 
529
524
  if disp:
530
525
  if disp.startswith("-"):
@@ -807,7 +802,7 @@ class Instruction:
807
802
  if op.type in (OP_TYPE_IMM, OP_TYPE_MEM, OP_TYPE_RAW):
808
803
  all_operands[i] = op_asm
809
804
  else:
810
- raise BinaryError("Unsupported operand type %d." % op.type)
805
+ raise BinaryError(f"Unsupported operand type {op.type}.")
811
806
 
812
807
  if op.type != OP_TYPE_RAW and self.capstone_operand_types[i] == capstone.CS_OP_IMM:
813
808
  if mnemonic.startswith(("j", "call", "loop")):
@@ -1247,7 +1242,7 @@ class Data:
1247
1242
  self._initialize()
1248
1243
 
1249
1244
  def __repr__(self):
1250
- return "<DataItem %s@%#08x, %d bytes>" % (self.sort, self.addr, self.size)
1245
+ return f"<DataItem {self.sort}@{self.addr:#08x}, {self.size} bytes>"
1251
1246
 
1252
1247
  @property
1253
1248
  def content(self):
@@ -1399,7 +1394,7 @@ class Data:
1399
1394
  i += self.project.arch.bytes
1400
1395
 
1401
1396
  if isinstance(symbolized_label, int):
1402
- s += "\t%s %d\n" % (directive, symbolized_label)
1397
+ s += f"\t{directive} {symbolized_label}\n"
1403
1398
  else:
1404
1399
  s += f"\t{directive} {symbolized_label.operand_str}\n"
1405
1400
 
@@ -1442,11 +1437,12 @@ class Data:
1442
1437
 
1443
1438
  show_integer = False
1444
1439
  if len(addr_to_labels) == 0 or (
1445
- len(addr_to_labels) == 1
1446
- and self.addr is not None
1447
- and next(iter(addr_to_labels.keys())) == self.addr
1448
- or self.addr is None
1449
- and next(iter(addr_to_labels.keys())) == 0
1440
+ (
1441
+ len(addr_to_labels) == 1
1442
+ and self.addr is not None
1443
+ and next(iter(addr_to_labels.keys())) == self.addr
1444
+ )
1445
+ or (self.addr is None and next(iter(addr_to_labels.keys())) == 0)
1450
1446
  ):
1451
1447
  show_integer = True
1452
1448
 
@@ -1474,7 +1470,7 @@ class Data:
1474
1470
  content += [f"{label!s}"]
1475
1471
  addr += 1
1476
1472
 
1477
- content += ["\t.byte %d" % c]
1473
+ content += [f"\t.byte {c}"]
1478
1474
 
1479
1475
  else:
1480
1476
  integer = struct.unpack(fmt_str, self.content[0])[0]
@@ -1508,10 +1504,10 @@ class Data:
1508
1504
  content += [f"{label!s}"]
1509
1505
  addr += 1
1510
1506
 
1511
- content += ["\t.byte %d" % c]
1507
+ content += [f"\t.byte {c}"]
1512
1508
  else:
1513
1509
  for piece in self.content:
1514
- content += ["\t.byte %d" % c for c in piece]
1510
+ content += [f"\t.byte {c}" for c in piece]
1515
1511
 
1516
1512
  s += "\n".join(content)
1517
1513
  s += "\n"
@@ -1534,10 +1530,10 @@ class Data:
1534
1530
  content += [f"{label!s}"]
1535
1531
  addr += 1
1536
1532
 
1537
- content += ["\t.byte %d" % c]
1533
+ content += [f"\t.byte {c}"]
1538
1534
  else:
1539
1535
  for piece in self.content:
1540
- content += ["\t.byte %d" % c for c in piece]
1536
+ content += [f"\t.byte {c}" for c in piece]
1541
1537
 
1542
1538
  s += "\n".join(content)
1543
1539
  s += "\n"
@@ -1554,7 +1550,7 @@ class Data:
1554
1550
 
1555
1551
  def _initialize(self):
1556
1552
  if self.memory_data is None:
1557
- if self.size is None or self._initial_content is None and self.sort is None:
1553
+ if self.size is None or (self._initial_content is None and self.sort is None):
1558
1554
  raise BinaryError("You must at least specify size, initial_content, and sort.")
1559
1555
 
1560
1556
  if self.sort == MemoryDataSort.PointerArray:
@@ -2647,8 +2643,7 @@ class Reassembler(Analysis):
2647
2643
  return bool(
2648
2644
  cfg.project.loader.find_section_containing(ptr) is not None
2649
2645
  or cfg.project.loader.find_segment_containing(ptr) is not None
2650
- or self._extra_memory_regions
2651
- and next((a < ptr < b for a, b in self._extra_memory_regions), None)
2646
+ or (self._extra_memory_regions and next((a < ptr < b for a, b in self._extra_memory_regions), None))
2652
2647
  )
2653
2648
 
2654
2649
  def _sequence_handler(self, cfg, irsb, irsb_addr, stmt_idx, data_addr, max_size): # pylint:disable=unused-argument
@@ -29,6 +29,7 @@ class SLivenessAnalysis(Analysis):
29
29
  func_graph=None,
30
30
  entry=None,
31
31
  func_addr: int | None = None,
32
+ arg_vvars: list[VirtualVariable] | None = None,
32
33
  ):
33
34
  self.func = func
34
35
  self.func_addr = func_addr if func_addr is not None else func.addr
@@ -38,6 +39,7 @@ class SLivenessAnalysis(Analysis):
38
39
  if entry is not None
39
40
  else next(iter(bb for bb in self.func_graph if bb.addr == self.func_addr and bb.idx is None))
40
41
  )
42
+ self.arg_vvars = arg_vvars or []
41
43
 
42
44
  self.model = SLivenessModel()
43
45
 
@@ -147,6 +149,12 @@ class SLivenessAnalysis(Analysis):
147
149
  live.discard(def_vvar)
148
150
  live |= vvar_use_collector.vvars
149
151
 
152
+ if block.addr == self.func_addr:
153
+ # deal with function arguments
154
+ for arg_vvar in self.arg_vvars:
155
+ for live_vvar in live:
156
+ graph.add_edge(arg_vvar.varid, live_vvar)
157
+
150
158
  return graph
151
159
 
152
160
 
@@ -171,11 +171,8 @@ class SRDAView:
171
171
  starting_stmt_idx = stmt_idx
172
172
  continue
173
173
 
174
- if (
175
- op_type == ObservationPointType.OP_BEFORE
176
- and stmt.ins_addr == addr
177
- or op_type == ObservationPointType.OP_AFTER
178
- and stmt.ins_addr > addr
174
+ if (op_type == ObservationPointType.OP_BEFORE and stmt.ins_addr == addr) or (
175
+ op_type == ObservationPointType.OP_AFTER and stmt.ins_addr > addr
179
176
  ):
180
177
  starting_stmt_idx = stmt_idx
181
178
  break
@@ -79,7 +79,7 @@ class Register:
79
79
  Represent a register.
80
80
  """
81
81
 
82
- __slots__ = ("offset", "bitlen")
82
+ __slots__ = ("bitlen", "offset")
83
83
 
84
84
  def __init__(self, offset, bitlen):
85
85
  self.offset = offset
@@ -103,8 +103,8 @@ class OffsetVal:
103
103
  """
104
104
 
105
105
  __slots__ = (
106
- "_reg",
107
106
  "_offset",
107
+ "_reg",
108
108
  )
109
109
 
110
110
  def __init__(self, reg, offset):
@@ -177,7 +177,7 @@ class FrozenStackPointerTrackerState:
177
177
  Abstract state for StackPointerTracker analysis with registers and memory values being in frozensets.
178
178
  """
179
179
 
180
- __slots__ = "regs", "memory", "is_tracking_memory", "resilient"
180
+ __slots__ = "is_tracking_memory", "memory", "regs", "resilient"
181
181
 
182
182
  def __init__(
183
183
  self,
@@ -218,7 +218,7 @@ class StackPointerTrackerState:
218
218
  Abstract state for StackPointerTracker analysis.
219
219
  """
220
220
 
221
- __slots__ = "regs", "memory", "is_tracking_memory", "resilient"
221
+ __slots__ = "is_tracking_memory", "memory", "regs", "resilient"
222
222
 
223
223
  def __init__(self, regs, memory, is_tracking_memory, resilient: bool):
224
224
  self.regs = regs
@@ -123,7 +123,7 @@ class SketchNode(SketchNodeBase):
123
123
  Represents a node in a sketch graph.
124
124
  """
125
125
 
126
- __slots__ = ("typevar", "upper_bound", "lower_bound")
126
+ __slots__ = ("lower_bound", "typevar", "upper_bound")
127
127
 
128
128
  def __init__(self, typevar: TypeVariable | DerivedTypeVariable):
129
129
  self.typevar: TypeVariable | DerivedTypeVariable = typevar
@@ -164,8 +164,8 @@ class Sketch:
164
164
 
165
165
  __slots__ = (
166
166
  "graph",
167
- "root",
168
167
  "node_mapping",
168
+ "root",
169
169
  "solver",
170
170
  )
171
171
 
@@ -263,7 +263,7 @@ class FORGOTTEN(enum.Enum):
263
263
 
264
264
 
265
265
  class ConstraintGraphNode:
266
- __slots__ = ("typevar", "variance", "tag", "forgotten")
266
+ __slots__ = ("forgotten", "tag", "typevar", "variance")
267
267
 
268
268
  def __init__(
269
269
  self,
@@ -367,7 +367,7 @@ class SimpleSolver:
367
367
 
368
368
  def __init__(self, bits: int, constraints, typevars):
369
369
  if bits not in (32, 64):
370
- raise ValueError("Pointer size %d is not supported. Expect 32 or 64." % bits)
370
+ raise ValueError(f"Pointer size {bits} is not supported. Expect 32 or 64.")
371
371
 
372
372
  self.bits = bits
373
373
  self._constraints: dict[TypeVariable, set[TypeConstraint]] = constraints
@@ -627,10 +627,8 @@ class SimpleSolver:
627
627
  for _, dst0, data0 in graph.out_edges(cls0, data=True):
628
628
  if "label" in data0 and data0["label"] is not None:
629
629
  for _, dst1, data1 in graph.out_edges(cls1, data=True):
630
- if (
631
- data0["label"] == data1["label"]
632
- or isinstance(data0["label"], Load)
633
- and isinstance(data1["label"], Store)
630
+ if data0["label"] == data1["label"] or (
631
+ isinstance(data0["label"], Load) and isinstance(data1["label"], Store)
634
632
  ):
635
633
  SimpleSolver._unify(
636
634
  equivalence_classes, equivalence_classes[dst0], equivalence_classes[dst1], graph
@@ -1280,4 +1278,4 @@ class SimpleSolver:
1280
1278
  return Pointer32
1281
1279
  if self.bits == 64:
1282
1280
  return Pointer64
1283
- raise NotImplementedError("Unsupported bits %d" % self.bits)
1281
+ raise NotImplementedError(f"Unsupported bits {self.bits}")
@@ -42,7 +42,7 @@ class TypeTranslator:
42
42
  #
43
43
 
44
44
  def struct_name(self):
45
- return "struct_%d" % next(self._struct_ctr)
45
+ return f"struct_{next(self._struct_ctr)}"
46
46
 
47
47
  #
48
48
  # Type translation
@@ -227,7 +227,7 @@ class TypeTranslator:
227
227
  return typeconsts.Pointer32(base)
228
228
  if self.arch.bits == 64:
229
229
  return typeconsts.Pointer64(base)
230
- raise TypeError("Unsupported pointer size %d" % self.arch.bits)
230
+ raise TypeError(f"Unsupported pointer size {self.arch.bits}")
231
231
 
232
232
 
233
233
  TypeConstHandlers = {
@@ -189,7 +189,7 @@ class Array(TypeConstant):
189
189
  def __repr__(self, memo=None):
190
190
  if self.count is None:
191
191
  return f"{self.element!r}[?]"
192
- return "%r[%d]" % (self.element, self.count)
192
+ return f"{self.element!r}[{self.count}]"
193
193
 
194
194
  def __eq__(self, other):
195
195
  return type(other) is type(self) and self.element == other.element and self.count == other.count
@@ -26,9 +26,9 @@ class TypeConstraint:
26
26
 
27
27
  class Equivalence(TypeConstraint):
28
28
  __slots__ = (
29
+ "_cached_hash",
29
30
  "type_a",
30
31
  "type_b",
31
- "_cached_hash",
32
32
  )
33
33
 
34
34
  def __init__(self, type_a, type_b):
@@ -44,10 +44,8 @@ class Equivalence(TypeConstraint):
44
44
 
45
45
  def __eq__(self, other):
46
46
  return type(other) is Equivalence and (
47
- self.type_a == other.type_a
48
- and self.type_b == other.type_b
49
- or self.type_b == other.type_a
50
- and self.type_a == other.type_b
47
+ (self.type_a == other.type_a and self.type_b == other.type_b)
48
+ or (self.type_b == other.type_a and self.type_a == other.type_b)
51
49
  )
52
50
 
53
51
  def __hash__(self):
@@ -55,7 +53,7 @@ class Equivalence(TypeConstraint):
55
53
 
56
54
 
57
55
  class Existence(TypeConstraint):
58
- __slots__ = ("type_", "_cached_hash")
56
+ __slots__ = ("_cached_hash", "type_")
59
57
 
60
58
  def __init__(self, type_):
61
59
  self.type_ = type_
@@ -85,9 +83,9 @@ class Existence(TypeConstraint):
85
83
 
86
84
  class Subtype(TypeConstraint):
87
85
  __slots__ = (
88
- "super_type",
89
- "sub_type",
90
86
  "_cached_hash",
87
+ "sub_type",
88
+ "super_type",
91
89
  )
92
90
 
93
91
  def __init__(self, sub_type: TypeType, super_type: TypeType):
@@ -141,10 +139,10 @@ class Add(TypeConstraint):
141
139
  """
142
140
 
143
141
  __slots__ = (
142
+ "_cached_hash",
144
143
  "type_0",
145
144
  "type_1",
146
145
  "type_r",
147
- "_cached_hash",
148
146
  )
149
147
 
150
148
  def __init__(self, type_0, type_1, type_r):
@@ -210,10 +208,10 @@ class Sub(TypeConstraint):
210
208
  """
211
209
 
212
210
  __slots__ = (
211
+ "_cached_hash",
213
212
  "type_0",
214
213
  "type_1",
215
214
  "type_r",
216
- "_cached_hash",
217
215
  )
218
216
 
219
217
  def __init__(self, type_0, type_1, type_r):
@@ -277,7 +275,7 @@ _typevariable_counter = count()
277
275
 
278
276
 
279
277
  class TypeVariable:
280
- __slots__ = ("idx", "name", "_cached_hash")
278
+ __slots__ = ("_cached_hash", "idx", "name")
281
279
 
282
280
  def __init__(self, idx: int | None = None, name: str | None = None):
283
281
  if idx is None:
@@ -310,11 +308,11 @@ class TypeVariable:
310
308
  def __repr__(self):
311
309
  if self.name:
312
310
  return f"{self.name}|tv_{self.idx:02d}"
313
- return "tv_%02d" % self.idx
311
+ return f"tv_{self.idx:02d}"
314
312
 
315
313
 
316
314
  class DerivedTypeVariable(TypeVariable):
317
- __slots__ = ("type_var", "labels")
315
+ __slots__ = ("labels", "type_var")
318
316
 
319
317
  labels: tuple[BaseLabel, ...]
320
318
 
@@ -398,8 +396,8 @@ class DerivedTypeVariable(TypeVariable):
398
396
 
399
397
  class TypeVariables:
400
398
  __slots__ = (
401
- "_typevars",
402
399
  "_last_typevars",
400
+ "_typevars",
403
401
  )
404
402
 
405
403
  def __init__(self):
@@ -418,7 +416,7 @@ class TypeVariables:
418
416
  # sum(len(v) for v in self._typevars.items()),
419
417
  # len(self._typevars),
420
418
  # )
421
- return "{TypeVars: %d items}" % len(self._typevars)
419
+ return f"{{TypeVars: {len(self._typevars)} items}}"
422
420
 
423
421
  def add_type_variable(self, var: SimVariable, codeloc, typevar: TypeType): # pylint:disable=unused-argument
424
422
  if var not in self._typevars:
@@ -514,7 +512,7 @@ class AddN(BaseLabel):
514
512
  super().__init__()
515
513
 
516
514
  def __repr__(self):
517
- return "+%d" % self.n
515
+ return f"+{self.n}"
518
516
 
519
517
 
520
518
  class SubN(BaseLabel):
@@ -525,7 +523,7 @@ class SubN(BaseLabel):
525
523
  super().__init__()
526
524
 
527
525
  def __repr__(self):
528
- return "-%d" % self.n
526
+ return f"-{self.n}"
529
527
 
530
528
 
531
529
  class ConvertTo(BaseLabel):
@@ -536,13 +534,13 @@ class ConvertTo(BaseLabel):
536
534
  super().__init__()
537
535
 
538
536
  def __repr__(self):
539
- return "conv(%d)" % self.to_bits
537
+ return f"conv({self.to_bits})"
540
538
 
541
539
 
542
540
  class ReinterpretAs(BaseLabel):
543
541
  __slots__ = (
544
- "to_type",
545
542
  "to_bits",
543
+ "to_type",
546
544
  )
547
545
 
548
546
  def __init__(self, to_type, to_bits):
@@ -3,4 +3,4 @@ from .packing_detector import PackingDetector
3
3
  from .obfuscation_detector import ObfuscationDetector
4
4
 
5
5
 
6
- __all__ = ("PackingDetector", "ObfuscationDetector")
6
+ __all__ = ("ObfuscationDetector", "PackingDetector")
@@ -35,9 +35,9 @@ class RichR(Generic[RichRT_co]):
35
35
 
36
36
  __slots__ = (
37
37
  "data",
38
- "variable",
39
- "typevar",
40
38
  "type_constraints",
39
+ "typevar",
40
+ "variable",
41
41
  )
42
42
 
43
43
  def __init__(
@@ -384,8 +384,7 @@ class SimEngineVRBase(
384
384
  if (
385
385
  vvar.category == ailment.expression.VirtualVariableCategory.REGISTER
386
386
  and vvar.oident in (self.project.arch.ip_offset, self.project.arch.sp_offset, self.project.arch.lr_offset)
387
- or not create_variable
388
- ):
387
+ ) or not create_variable:
389
388
  # only store the value. don't worry about variables.
390
389
  self.vvar_region[vvar_id] = richr.data
391
390
  return
@@ -327,7 +327,7 @@ class VariableRecoveryStateBase:
327
327
  base = 0x7F_FFFF_FFFE_0000
328
328
  mask = 0xFFFF_FFFF_FFFF_FFFF
329
329
  else:
330
- raise AngrRuntimeError("Unsupported bits %d" % self.arch.bits)
330
+ raise AngrRuntimeError(f"Unsupported bits {self.arch.bits}")
331
331
  return (offset + base) & mask
332
332
 
333
333
  @property
@@ -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:
@@ -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
@@ -5,6 +5,6 @@ from .kb import KnowledgeBaseSerializer
5
5
 
6
6
 
7
7
  __all__ = (
8
- "LoaderSerializer",
9
8
  "KnowledgeBaseSerializer",
9
+ "LoaderSerializer",
10
10
  )
angr/annocfg.py CHANGED
@@ -229,7 +229,7 @@ class AnnotatedCFG:
229
229
  whitelist = self.get_whitelisted_statements(irsb_addr)
230
230
  for i in range(len(statements)):
231
231
  line = "+" if whitelist is None or i in whitelist else "-"
232
- line += "[% 3d] " % i
232
+ line += f"[{i: 3d}] "
233
233
  # We cannot get data returned by pp(). WTF?
234
234
  print(line, end="")
235
235
  statements[i].pp()