angr 9.2.116__py3-none-macosx_10_9_x86_64.whl → 9.2.117__py3-none-macosx_10_9_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of angr might be problematic. Click here for more details.

Files changed (144) hide show
  1. angr/__init__.py +1 -1
  2. angr/analyses/cfg/cfg_emulated.py +4 -4
  3. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +7 -7
  4. angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +3 -2
  5. angr/analyses/identifier/functions/free.py +3 -1
  6. angr/analyses/identifier/identify.py +13 -15
  7. angr/analyses/identifier/runner.py +2 -2
  8. angr/analyses/vfg.py +4 -4
  9. angr/calling_conventions.py +4 -2
  10. angr/concretization_strategies/any_named.py +3 -1
  11. angr/concretization_strategies/controlled_data.py +4 -2
  12. angr/concretization_strategies/signed_add.py +3 -1
  13. angr/engines/concrete.py +3 -1
  14. angr/engines/pcode/behavior.py +2 -0
  15. angr/engines/pcode/emulate.py +4 -4
  16. angr/engines/pcode/engine.py +3 -7
  17. angr/engines/soot/engine.py +7 -6
  18. angr/engines/soot/expressions/constants.py +6 -5
  19. angr/engines/soot/expressions/newArray.py +3 -1
  20. angr/engines/soot/expressions/newMultiArray.py +3 -1
  21. angr/engines/soot/statements/goto.py +3 -1
  22. angr/engines/soot/statements/if_.py +3 -1
  23. angr/engines/soot/statements/switch.py +3 -1
  24. angr/engines/soot/statements/throw.py +4 -2
  25. angr/engines/soot/values/arrayref.py +5 -5
  26. angr/engines/unicorn.py +8 -7
  27. angr/engines/vex/heavy/concretizers.py +6 -6
  28. angr/engines/vex/heavy/dirty.py +20 -22
  29. angr/engines/vex/heavy/heavy.py +4 -8
  30. angr/exploration_techniques/director.py +1 -1
  31. angr/exploration_techniques/driller_core.py +3 -1
  32. angr/exploration_techniques/tracer.py +2 -1
  33. angr/lib/angr_native.dylib +0 -0
  34. angr/procedures/cgc/allocate.py +8 -10
  35. angr/procedures/cgc/deallocate.py +10 -3
  36. angr/procedures/cgc/fdwait.py +15 -13
  37. angr/procedures/cgc/random.py +11 -5
  38. angr/procedures/cgc/receive.py +5 -3
  39. angr/procedures/cgc/transmit.py +5 -4
  40. angr/procedures/glibc/__libc_start_main.py +5 -4
  41. angr/procedures/java_jni/__init__.py +4 -4
  42. angr/procedures/java_jni/array_operations.py +3 -1
  43. angr/procedures/java_lang/string.py +1 -1
  44. angr/procedures/java_util/random.py +3 -1
  45. angr/procedures/libc/access.py +4 -2
  46. angr/procedures/libc/feof.py +4 -3
  47. angr/procedures/libc/fgetc.py +3 -1
  48. angr/procedures/libc/fgets.py +5 -5
  49. angr/procedures/libc/fopen.py +5 -4
  50. angr/procedures/libc/fread.py +4 -3
  51. angr/procedures/libc/fseek.py +4 -3
  52. angr/procedures/libc/getdelim.py +7 -4
  53. angr/procedures/libc/gets.py +4 -2
  54. angr/procedures/libc/memcmp.py +18 -15
  55. angr/procedures/libc/memset.py +9 -7
  56. angr/procedures/libc/puts.py +3 -1
  57. angr/procedures/libc/snprintf.py +4 -2
  58. angr/procedures/libc/sprintf.py +3 -1
  59. angr/procedures/libc/strchr.py +6 -3
  60. angr/procedures/libc/strcmp.py +5 -3
  61. angr/procedures/libc/strlen.py +3 -3
  62. angr/procedures/libc/strncmp.py +28 -28
  63. angr/procedures/libc/strncpy.py +5 -2
  64. angr/procedures/libc/strstr.py +10 -7
  65. angr/procedures/libc/strtol.py +32 -34
  66. angr/procedures/libc/tolower.py +3 -1
  67. angr/procedures/libc/toupper.py +3 -1
  68. angr/procedures/linux_kernel/fstat.py +13 -13
  69. angr/procedures/linux_kernel/fstat64.py +15 -15
  70. angr/procedures/linux_kernel/lseek.py +5 -3
  71. angr/procedures/linux_kernel/sigaction.py +4 -2
  72. angr/procedures/linux_kernel/sigprocmask.py +5 -3
  73. angr/procedures/linux_kernel/tgkill.py +3 -1
  74. angr/procedures/linux_kernel/time.py +7 -4
  75. angr/procedures/msvcr/fmode.py +3 -1
  76. angr/procedures/ntdll/exceptions.py +3 -1
  77. angr/procedures/posix/bzero.py +3 -1
  78. angr/procedures/posix/fdopen.py +6 -4
  79. angr/procedures/posix/fork.py +6 -4
  80. angr/procedures/posix/mmap.py +6 -3
  81. angr/procedures/posix/poll.py +6 -5
  82. angr/procedures/posix/readdir.py +10 -7
  83. angr/procedures/posix/select.py +4 -2
  84. angr/procedures/posix/send.py +4 -3
  85. angr/procedures/posix/sigaction.py +4 -2
  86. angr/procedures/posix/sim_time.py +3 -1
  87. angr/procedures/posix/strcasecmp.py +3 -1
  88. angr/procedures/posix/strtok_r.py +10 -7
  89. angr/procedures/stubs/Redirect.py +3 -1
  90. angr/procedures/stubs/ReturnChar.py +3 -3
  91. angr/procedures/stubs/UserHook.py +3 -1
  92. angr/procedures/stubs/b64_decode.py +3 -1
  93. angr/procedures/stubs/crazy_scanf.py +6 -4
  94. angr/procedures/stubs/format_parser.py +13 -15
  95. angr/procedures/tracer/receive.py +3 -1
  96. angr/procedures/tracer/transmit.py +3 -1
  97. angr/procedures/win32/GetLastInputInfo.py +4 -2
  98. angr/procedures/win32/GetProcessAffinityMask.py +4 -2
  99. angr/procedures/win32/gethostbyname.py +3 -1
  100. angr/procedures/win32/heap.py +3 -1
  101. angr/procedures/win32/local_storage.py +4 -2
  102. angr/procedures/win32/sim_time.py +7 -4
  103. angr/procedures/win_user32/chars.py +4 -2
  104. angr/procedures/win_user32/messagebox.py +3 -1
  105. angr/sim_procedure.py +7 -7
  106. angr/sim_state.py +10 -7
  107. angr/sim_type.py +3 -3
  108. angr/simos/cgc.py +2 -2
  109. angr/simos/simos.py +5 -4
  110. angr/simos/windows.py +5 -5
  111. angr/state_plugins/heap/heap_brk.py +5 -3
  112. angr/state_plugins/heap/heap_ptmalloc.py +5 -4
  113. angr/state_plugins/history.py +7 -5
  114. angr/state_plugins/light_registers.py +2 -2
  115. angr/state_plugins/plugin.py +2 -2
  116. angr/state_plugins/posix.py +28 -26
  117. angr/state_plugins/preconstrainer.py +2 -1
  118. angr/state_plugins/solver.py +11 -27
  119. angr/state_plugins/trace_additions.py +9 -13
  120. angr/state_plugins/uc_manager.py +4 -2
  121. angr/state_plugins/unicorn_engine.py +1 -1
  122. angr/state_plugins/view.py +1 -1
  123. angr/storage/file.py +21 -26
  124. angr/storage/memory_mixins/actions_mixin.py +4 -2
  125. angr/storage/memory_mixins/address_concretization_mixin.py +3 -3
  126. angr/storage/memory_mixins/default_filler_mixin.py +6 -4
  127. angr/storage/memory_mixins/javavm_memory/javavm_memory_mixin.py +7 -5
  128. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -1
  129. angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +1 -1
  130. angr/storage/memory_mixins/regioned_memory/region_data.py +3 -1
  131. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +1 -1
  132. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +5 -4
  133. angr/storage/memory_mixins/simple_interface_mixin.py +2 -2
  134. angr/storage/memory_mixins/size_resolution_mixin.py +3 -1
  135. angr/storage/memory_mixins/slotted_memory.py +1 -1
  136. angr/storage/memory_mixins/smart_find_mixin.py +2 -2
  137. angr/storage/memory_mixins/symbolic_merger_mixin.py +5 -3
  138. angr/tablespecs.py +3 -3
  139. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/METADATA +6 -6
  140. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/RECORD +144 -144
  141. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/WHEEL +1 -1
  142. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/LICENSE +0 -0
  143. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/entry_points.txt +0 -0
  144. {angr-9.2.116.dist-info → angr-9.2.117.dist-info}/top_level.txt +0 -0
angr/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # pylint: disable=wildcard-import
2
2
  # pylint: disable=wrong-import-position
3
3
 
4
- __version__ = "9.2.116"
4
+ __version__ = "9.2.117"
5
5
 
6
6
  if bytes is str:
7
7
  raise Exception(
@@ -1016,7 +1016,7 @@ class CFGEmulated(ForwardAnalysis, CFGBase): # pylint: disable=abstract-method
1016
1016
  state = self._initial_state.copy()
1017
1017
  state.history.jumpkind = jumpkind
1018
1018
  self._reset_state_mode(state, "fastpath")
1019
- state._ip = state.solver.BVV(ip, self.project.arch.bits)
1019
+ state._ip = claripy.BVV(ip, self.project.arch.bits)
1020
1020
 
1021
1021
  if jumpkind is not None:
1022
1022
  state.history.jumpkind = jumpkind
@@ -1095,7 +1095,7 @@ class CFGEmulated(ForwardAnalysis, CFGBase): # pylint: disable=abstract-method
1095
1095
  f = self._pending_function_hints.pop()
1096
1096
  if f not in analyzed_addrs:
1097
1097
  new_state = self.project.factory.entry_state(mode="fastpath")
1098
- new_state.ip = new_state.solver.BVV(f, self.project.arch.bits)
1098
+ new_state.ip = claripy.BVV(f, self.project.arch.bits)
1099
1099
 
1100
1100
  # TOOD: Specially for MIPS
1101
1101
  if new_state.arch.name in ("MIPS32", "MIPS64"):
@@ -1783,7 +1783,7 @@ class CFGEmulated(ForwardAnalysis, CFGBase): # pylint: disable=abstract-method
1783
1783
  if suc_jumpkind == "Ijk_Ret":
1784
1784
  target_addr = job.call_stack.current_return_target
1785
1785
  if target_addr is not None:
1786
- new_state.ip = new_state.solver.BVV(target_addr, new_state.arch.bits)
1786
+ new_state.ip = claripy.BVV(target_addr, new_state.arch.bits)
1787
1787
 
1788
1788
  if target_addr is None:
1789
1789
  # Unlucky...
@@ -2445,7 +2445,7 @@ class CFGEmulated(ForwardAnalysis, CFGBase): # pylint: disable=abstract-method
2445
2445
  resolved = True
2446
2446
  for t in targets:
2447
2447
  new_ex = suc.copy()
2448
- new_ex.ip = suc.solver.BVV(t, suc.ip.size())
2448
+ new_ex.ip = claripy.BVV(t, suc.ip.size())
2449
2449
  all_successors.append(new_ex)
2450
2450
  else:
2451
2451
  break
@@ -634,7 +634,7 @@ class StoreHook:
634
634
  write_length = len(state.inspect.mem_write_expr)
635
635
  else:
636
636
  write_length = write_length * state.arch.byte_width
637
- state.inspect.mem_write_expr = state.solver.BVS("instrumented_store", write_length)
637
+ state.inspect.mem_write_expr = claripy.BVS("instrumented_store", write_length)
638
638
 
639
639
 
640
640
  class LoadHook:
@@ -648,7 +648,7 @@ class LoadHook:
648
648
  def hook_before(self, state):
649
649
  addr = state.inspect.mem_read_address
650
650
  size = state.solver.eval(state.inspect.mem_read_length)
651
- self._var = state.solver.BVS("instrumented_load", size * 8)
651
+ self._var = claripy.BVS("instrumented_load", size * 8)
652
652
  state.memory.store(addr, self._var, endness=state.arch.memory_endness)
653
653
 
654
654
  def hook_after(self, state):
@@ -662,7 +662,7 @@ class PutHook:
662
662
 
663
663
  @staticmethod
664
664
  def hook(state):
665
- state.inspect.reg_write_expr = state.solver.BVS(
665
+ state.inspect.reg_write_expr = claripy.BVS(
666
666
  "instrumented_put", state.solver.eval(state.inspect.reg_write_length) * 8
667
667
  )
668
668
 
@@ -678,7 +678,7 @@ class RegisterInitializerHook:
678
678
  self.value = value
679
679
 
680
680
  def hook(self, state):
681
- state.registers.store(self.reg_offset, state.solver.BVV(self.value, self.reg_bits))
681
+ state.registers.store(self.reg_offset, claripy.BVV(self.value, self.reg_bits))
682
682
 
683
683
 
684
684
  class BSSHook:
@@ -2106,7 +2106,7 @@ class JumpTableResolver(IndirectJumpResolver):
2106
2106
  read_length = claripy.backends.vsa.convert(read_length).upper_bound
2107
2107
  if read_length > 16:
2108
2108
  return
2109
- new_read_addr = state.solver.BVV(UninitReadMeta.uninit_read_base, state.arch.bits)
2109
+ new_read_addr = claripy.BVV(UninitReadMeta.uninit_read_base, state.arch.bits)
2110
2110
  UninitReadMeta.uninit_read_base += read_length
2111
2111
 
2112
2112
  # replace the expression in registers
@@ -2238,7 +2238,7 @@ class JumpTableResolver(IndirectJumpResolver):
2238
2238
  # blx r0
2239
2239
  # It's not a jump table, but we resolve it anyway
2240
2240
  jump_target_addr = load_stmt.data.addr.con.value
2241
- return state.solver.BVV(jump_target_addr, state.arch.bits)
2241
+ return claripy.BVV(jump_target_addr, state.arch.bits)
2242
2242
  elif isinstance(load_stmt, pyvex.IRStmt.LoadG):
2243
2243
  if type(load_stmt.addr) is pyvex.IRExpr.RdTmp:
2244
2244
  load_addr_tmp = load_stmt.addr.tmp
@@ -2254,7 +2254,7 @@ class JumpTableResolver(IndirectJumpResolver):
2254
2254
  # Note that this block has two branches: One goes to 45450, the other one goes to whatever the original
2255
2255
  # value of R3 is. Some intensive data-flow analysis is required in this case.
2256
2256
  jump_target_addr = load_stmt.addr.con.value
2257
- return state.solver.BVV(jump_target_addr, state.arch.bits)
2257
+ return claripy.BVV(jump_target_addr, state.arch.bits)
2258
2258
  else:
2259
2259
  raise TypeError("Unsupported address loading statement type %s." % type(load_stmt))
2260
2260
 
@@ -2,8 +2,9 @@
2
2
  from typing import TYPE_CHECKING
3
3
  import logging
4
4
 
5
- import pyvex
6
5
  import archinfo
6
+ import claripy
7
+ import pyvex
7
8
 
8
9
 
9
10
  from .... import options, BP_BEFORE
@@ -45,7 +46,7 @@ class OverwriteTmpValueCallback:
45
46
  self.gp_value = gp_value
46
47
 
47
48
  def overwrite_tmp_value(self, state):
48
- state.inspect.tmp_write_expr = state.solver.BVV(self.gp_value, state.arch.bits)
49
+ state.inspect.tmp_write_expr = claripy.BVV(self.gp_value, state.arch.bits)
49
50
 
50
51
 
51
52
  class MipsElfFastResolver(IndirectJumpResolver):
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from ..func import Func, TestData
4
6
  from ..errors import IdentifierException
5
7
 
@@ -52,7 +54,7 @@ class free(Func):
52
54
  test_input = [malloc_vals[-1]]
53
55
  test_output = [None]
54
56
  return_val = None
55
- state.memory.store(malloc_vals[-1], state.solver.BVS("some_data", 0x80 * 8))
57
+ state.memory.store(malloc_vals[-1], claripy.BVS("some_data", 0x80 * 8))
56
58
  free_test = TestData(test_input, test_output, return_val, max_steps)
57
59
  state = runner.get_out_state(func, free_test, initial_state=state)
58
60
  if state is None:
@@ -1,10 +1,10 @@
1
+ import logging
1
2
  from collections import defaultdict
2
3
  from itertools import chain
3
- import logging
4
-
5
- from networkx import NetworkXError
6
4
 
5
+ import claripy
7
6
  from cle.backends.cgc import CGC
7
+ from networkx import NetworkXError
8
8
 
9
9
  from .errors import IdentifierException
10
10
  from .functions import Functions
@@ -75,9 +75,7 @@ class Identifier(Analysis):
75
75
 
76
76
  self.base_symbolic_state = self.make_symbolic_state(self.project, self._reg_list)
77
77
  self.base_symbolic_state.options.discard(options.SUPPORT_FLOATING_POINT)
78
- self.base_symbolic_state.regs.bp = self.base_symbolic_state.solver.BVS(
79
- "sreg_" + "ebp" + "-", self.project.arch.bits
80
- )
78
+ self.base_symbolic_state.regs.bp = claripy.BVS("sreg_" + "ebp" + "-", self.project.arch.bits)
81
79
 
82
80
  for f in self._cfg.functions.values():
83
81
  if f.is_syscall:
@@ -308,7 +306,7 @@ class Identifier(Analysis):
308
306
 
309
307
  func_info = self.func_info[self.block_to_func[addr_trace[0]]]
310
308
  for i in range(func_info.frame_size // self.project.arch.bytes + 5):
311
- s.stack_push(s.solver.BVS("var_" + hex(i), self.project.arch.bits))
309
+ s.stack_push(claripy.BVS("var_" + hex(i), self.project.arch.bits))
312
310
 
313
311
  if func_info.bp_based:
314
312
  s.regs.bp = s.regs.sp + func_info.bp_sp_diff
@@ -322,7 +320,7 @@ class Identifier(Analysis):
322
320
  for ss in simgr.active:
323
321
  # todo could write symbolic data to pointers passed to functions
324
322
  if ss.history.jumpkind == "Ijk_Call":
325
- ss.regs.eax = ss.solver.BVS("unconstrained_ret_%#x" % ss.addr, ss.arch.bits)
323
+ ss.regs.eax = claripy.BVS("unconstrained_ret_%#x" % ss.addr, ss.arch.bits)
326
324
  ss.regs.ip = ss.stack_pop()
327
325
  ss.history.jumpkind = "Ijk_Ret"
328
326
  if ss.addr == addr_trace[0]:
@@ -333,7 +331,7 @@ class Identifier(Analysis):
333
331
  if len(simgr.unconstrained) > 0:
334
332
  s = simgr.unconstrained[0]
335
333
  if s.history.jumpkind == "Ijk_Call":
336
- s.regs.eax = s.solver.BVS("unconstrained_ret", s.arch.bits)
334
+ s.regs.eax = claripy.BVS("unconstrained_ret", s.arch.bits)
337
335
  s.regs.ip = s.stack_pop()
338
336
  s.history.jumpkind = "Ijk_Ret"
339
337
  s.regs.ip = addr_trace[0]
@@ -437,7 +435,7 @@ class Identifier(Analysis):
437
435
  state = input_state.copy()
438
436
  # overwrite all registers
439
437
  for reg in reg_list:
440
- state.registers.store(reg, state.solver.BVS("sreg_" + reg + "-", project.arch.bits, explicit_name=True))
438
+ state.registers.store(reg, claripy.BVS("sreg_" + reg + "-", project.arch.bits, explicit_name=True))
441
439
  # restore sp
442
440
  state.regs.sp = input_state.regs.sp
443
441
  # restore bp
@@ -600,11 +598,11 @@ class Identifier(Analysis):
600
598
  for bl_addr in func.block_addrs:
601
599
  all_addrs.update(set(self._cfg.model.get_any_node(bl_addr).instruction_addrs))
602
600
 
603
- sp = main_state.solver.BVS("sym_sp", self.project.arch.bits, explicit_name=True)
601
+ sp = claripy.BVS("sym_sp", self.project.arch.bits, explicit_name=True)
604
602
  main_state.regs.sp = sp
605
603
  bp = None
606
604
  if bp_based:
607
- bp = main_state.solver.BVS("sym_bp", self.project.arch.bits, explicit_name=True)
605
+ bp = claripy.BVS("sym_bp", self.project.arch.bits, explicit_name=True)
608
606
  main_state.regs.bp = bp
609
607
 
610
608
  stack_vars = set()
@@ -731,7 +729,7 @@ class Identifier(Analysis):
731
729
  def _sets_ebp_from_esp(self, state, addr):
732
730
  state = state.copy()
733
731
  state.regs.ip = addr
734
- state.regs.sp = state.solver.BVS("sym_sp", 32, explicit_name=True)
732
+ state.regs.sp = claripy.BVS("sym_sp", 32, explicit_name=True)
735
733
  succ = self.project.factory.successors(state).all_successors[0]
736
734
 
737
735
  diff = state.regs.sp - succ.regs.bp
@@ -818,7 +816,7 @@ class Identifier(Analysis):
818
816
  options.TRACK_CONSTRAINT_ACTIONS,
819
817
  }
820
818
  )
821
- symbolic_stack = initial_state.solver.BVS("symbolic_stack", project.arch.bits * stack_length)
819
+ symbolic_stack = claripy.BVS("symbolic_stack", project.arch.bits * stack_length)
822
820
  initial_state.memory.store(initial_state.regs.sp, symbolic_stack)
823
821
  if initial_state.arch.bp_offset != initial_state.arch.sp_offset:
824
822
  initial_state.regs.bp = initial_state.regs.sp + 20 * initial_state.arch.bytes
@@ -835,7 +833,7 @@ class Identifier(Analysis):
835
833
  symbolic_state = input_state.copy()
836
834
  # overwrite all registers
837
835
  for reg in reg_list:
838
- symbolic_state.registers.store(reg, symbolic_state.solver.BVS("sreg_" + reg + "-", project.arch.bits))
836
+ symbolic_state.registers.store(reg, claripy.BVS("sreg_" + reg + "-", project.arch.bits))
839
837
  # restore sp
840
838
  symbolic_state.regs.sp = input_state.regs.sp
841
839
  # restore bp
@@ -52,7 +52,7 @@ class Runner:
52
52
  entry_state = self.project.factory.entry_state(add_options=add_options, remove_options=remove_options)
53
53
 
54
54
  # map the CGC flag page
55
- fake_flag_data = entry_state.solver.BVV(FLAG_DATA)
55
+ fake_flag_data = claripy.BVV(FLAG_DATA)
56
56
  entry_state.memory.store(0x4347C000, fake_flag_data)
57
57
  # map the place where I put arguments
58
58
  entry_state.memory.map_region(0x2000, 0x10000, 7)
@@ -176,7 +176,7 @@ class Runner:
176
176
  buf = state.solver.eval(state.regs.ebx)
177
177
  for i in range(count):
178
178
  a = random.randint(0, 255)
179
- state.memory.store(buf + i, state.solver.BVV(a, 8))
179
+ state.memory.store(buf + i, claripy.BVV(a, 8))
180
180
 
181
181
  def get_base_call_state(self, function, test_data, initial_state=None, concrete_rand=False):
182
182
  curr_buf_loc = 0x2000
angr/analyses/vfg.py CHANGED
@@ -1303,7 +1303,7 @@ class VFG(ForwardAnalysis[SimState, VFGNode, VFGJob, BlockID], Analysis): # pyl
1303
1303
  # TODO: the following code is totally untested other than X86 and AMD64. Don't freak out if you find bugs :)
1304
1304
  # TODO: Test it
1305
1305
 
1306
- ret_bvv = state.solver.BVV(ret_addr, self.project.arch.bits)
1306
+ ret_bvv = claripy.BVV(ret_addr, self.project.arch.bits)
1307
1307
 
1308
1308
  if self.project.arch.name in ("X86", "AMD64"):
1309
1309
  state.stack_push(ret_bvv)
@@ -1524,13 +1524,13 @@ class VFG(ForwardAnalysis[SimState, VFGNode, VFGJob, BlockID], Analysis): # pyl
1524
1524
  successor_state.registers.store(arch.sp_offset, reg_sp_expr)
1525
1525
 
1526
1526
  # Clear the return value with a TOP
1527
- top_si = successor_state.solver.TSI(arch.bits)
1527
+ top_si = claripy.TSI(arch.bits)
1528
1528
  successor_state.registers.store(arch.ret_offset, top_si)
1529
1529
 
1530
1530
  if job.call_skipped:
1531
1531
  # TODO: Make sure the return values make sense
1532
1532
  # if self.project.arch.name == "X86":
1533
- # successor_state.regs.eax = successor_state.solver.BVS(
1533
+ # successor_state.regs.eax = claripy.BVS(
1534
1534
  # "ret_val", 32, min=0, max=0xFFFFFFFF, stride=1
1535
1535
  # )
1536
1536
 
@@ -1564,7 +1564,7 @@ class VFG(ForwardAnalysis[SimState, VFGNode, VFGJob, BlockID], Analysis): # pyl
1564
1564
  reg_sp_si = self._create_stack_region(successor_state, successor_addr)
1565
1565
 
1566
1566
  # Save the new sp register
1567
- new_reg_sp_expr = successor_state.solver.ValueSet(successor_state.arch.bits, "global", 0, reg_sp_si)
1567
+ new_reg_sp_expr = claripy.ValueSet(successor_state.arch.bits, "global", 0, reg_sp_si)
1568
1568
  successor_state.regs.sp = new_reg_sp_expr
1569
1569
 
1570
1570
  elif successor.history.jumpkind == "Ijk_Ret":
@@ -413,7 +413,7 @@ class SimComboArg(SimFunctionArgument):
413
413
  vals = []
414
414
  for loc in reversed(self.locations):
415
415
  vals.append(loc.get_value(state, **kwargs))
416
- return self.check_value_get(state.solver.Concat(*vals))
416
+ return self.check_value_get(claripy.Concat(*vals))
417
417
 
418
418
 
419
419
  class SimStructArg(SimFunctionArgument):
@@ -1031,7 +1031,7 @@ class SimCC:
1031
1031
  if isinstance(ty, SimTypeFloat):
1032
1032
  return SimCC._standardize_value(float(arg), ty, state, alloc)
1033
1033
 
1034
- val = state.solver.BVV(arg, ty.size)
1034
+ val = claripy.BVV(arg, ty.size)
1035
1035
  return val
1036
1036
 
1037
1037
  elif isinstance(arg, float):
@@ -2300,6 +2300,8 @@ def default_cc( # pylint:disable=unused-argument
2300
2300
  if alias not in cc_map or platform not in cc_map[alias]:
2301
2301
  if default is not ...:
2302
2302
  return default
2303
+ else:
2304
+ return None
2303
2305
  return cc_map[alias][platform]
2304
2306
 
2305
2307
 
@@ -1,3 +1,5 @@
1
+ import claripy
2
+
1
3
  from . import SimConcretizationStrategy
2
4
 
3
5
 
@@ -24,7 +26,7 @@ class SimConcretizationStrategyAnyNamed(SimConcretizationStrategy):
24
26
  target = self._any(memory, addr, extra_constraints=child_constraints, **kwargs)
25
27
  # Create new BVS
26
28
  old_name = " ".join(repr(addr)[:-1].split(" ")[1:])
27
- new_BVS = memory.state.solver.BVS(f"[{old_name}]", memory.state.arch.bits, explicit_name=True)
29
+ new_BVS = claripy.BVS(f"[{old_name}]", memory.state.arch.bits, explicit_name=True)
28
30
  memory.store(target, new_BVS, endness=memory.state.arch.memory_endness)
29
31
  # Enforce the address
30
32
  memory.state.solver.add(addr == target)
@@ -1,5 +1,7 @@
1
1
  from itertools import groupby
2
2
 
3
+ import claripy
4
+
3
5
  from . import SimConcretizationStrategy
4
6
 
5
7
 
@@ -40,10 +42,10 @@ class SimConcretizationStrategyControlledData(SimConcretizationStrategy):
40
42
 
41
43
  # create constraints from intervals
42
44
  for base, length in intervals:
43
- constraints.append(memory.state.solver.And(addr >= base, addr < base + length))
45
+ constraints.append(claripy.And(addr >= base, addr < base + length))
44
46
 
45
47
  # try to get solutions for controlled memory
46
- ored_constraints = memory.state.solver.Or(*constraints)
48
+ ored_constraints = claripy.Or(*constraints)
47
49
  child_constraints = (ored_constraints,)
48
50
  extra_constraints = kwargs.pop("extra_constraints", None)
49
51
  if extra_constraints is not None:
@@ -1,3 +1,5 @@
1
+ import claripy
2
+
1
3
  from . import SimConcretizationStrategy
2
4
 
3
5
 
@@ -21,4 +23,4 @@ class SimConcretizationStrategySignedAdd(SimConcretizationStrategy):
21
23
  new_arg = (1 << addr.args[1].size()) - memory.state.solver.eval(addr.args[1])
22
24
  if new_arg < self._substraction_limit:
23
25
  addr.op = "__sub__"
24
- addr.args = (addr.args[0], memory.state.solver.BVV(new_arg, addr.args[1].size()))
26
+ addr.args = (addr.args[0], claripy.BVV(new_arg, addr.args[1].size()))
angr/engines/concrete.py CHANGED
@@ -1,6 +1,8 @@
1
1
  import logging
2
2
  import threading
3
3
 
4
+ import claripy
5
+
4
6
  from angr.errors import AngrError
5
7
  from .engine import SuccessorsMixin
6
8
  from ..errors import SimConcreteRegisterError
@@ -58,7 +60,7 @@ class SimEngineConcrete(SuccessorsMixin):
58
60
 
59
61
  successors.engine = "SimEngineConcrete"
60
62
  successors.sort = "SimEngineConcrete"
61
- successors.add_successor(new_state, new_state.ip, new_state.solver.true, new_state.unicorn.jumpkind)
63
+ successors.add_successor(new_state, new_state.ip, claripy.true, new_state.unicorn.jumpkind)
62
64
  successors.description = "Concrete Successors"
63
65
  successors.processed = True
64
66
 
@@ -868,6 +868,8 @@ class OpBehaviorSubpiece(OpBehavior):
868
868
  def evaluate_binary(self, size_out: int, size_in: int, in1: BV, in2: BV) -> BV:
869
869
  if in2.size() < in1.size():
870
870
  in2 = in2.sign_extend(in1.size() - in2.size())
871
+ if in1.size() < in2.size():
872
+ in1 = in1.sign_extend(in2.size() - in1.size())
871
873
  return (in1 >> (in2 * 8)) & (2 ** (size_out * 8) - 1)
872
874
 
873
875
 
@@ -187,7 +187,7 @@ class PcodeEmulatorMixin(SimEngineBase):
187
187
  elif space.name == "unique":
188
188
  self._pcode_tmps[varnode.offset] = value
189
189
 
190
- elif space.name in ("ram", "mem"):
190
+ elif space.name.lower() in ("ram", "mem"):
191
191
  l.debug("Storing %s to offset %s", value, varnode.offset)
192
192
  self.state.memory.store(varnode.offset, value, endness=self.project.arch.memory_endness)
193
193
 
@@ -225,7 +225,7 @@ class PcodeEmulatorMixin(SimEngineBase):
225
225
  self._pcode_tmps[varnode.offset] = claripy.BVV(0, size * 8)
226
226
  return self._pcode_tmps[varnode.offset]
227
227
 
228
- elif space_name in ("ram", "mem"):
228
+ elif space_name.lower() in ("ram", "mem"):
229
229
  val = self.state.memory.load(varnode.offset, endness=self.project.arch.memory_endness, size=size)
230
230
  l.debug("Loaded %s from offset %s", val, varnode.offset)
231
231
  return val
@@ -285,7 +285,7 @@ class PcodeEmulatorMixin(SimEngineBase):
285
285
  space = self._current_op.inputs[0].getSpaceFromConst()
286
286
  offset = self._get_value(self._current_op.inputs[1])
287
287
  out = self._current_op.output
288
- if space.name in ("ram", "mem"):
288
+ if space.name.lower() in ("ram", "mem"):
289
289
  res = self.state.memory.load(offset, out.size, endness=self.project.arch.memory_endness)
290
290
  elif space.name in "register":
291
291
  res = self.state.registers.load(offset, size=out.size, endness=self.project.arch.register_endness)
@@ -304,7 +304,7 @@ class PcodeEmulatorMixin(SimEngineBase):
304
304
  offset = self._get_value(self._current_op.inputs[1])
305
305
  data = self._get_value(self._current_op.inputs[2])
306
306
  l.debug("Storing %s at offset %s", data, offset)
307
- if space.name in ("ram", "mem"):
307
+ if space.name.lower() in ("ram", "mem"):
308
308
  self.state.memory.store(offset, data, endness=self.project.arch.memory_endness)
309
309
  elif space.name == "register":
310
310
  self.state.registers.store(offset, data, endness=self.project.arch.register_endness)
@@ -224,7 +224,7 @@ class HeavyPcodeMixin(
224
224
  "return value in Call-less mode.",
225
225
  exit_state.arch.name,
226
226
  )
227
- exit_state.scratch.target = exit_state.solver.BVV(
227
+ exit_state.scratch.target = claripy.BVV(
228
228
  successors.addr + self.state.scratch.irsb.size, exit_state.arch.bits
229
229
  )
230
230
  exit_state.history.jumpkind = "Ijk_Ret"
@@ -238,12 +238,8 @@ class HeavyPcodeMixin(
238
238
  l.debug("%s adding postcall exit.", self)
239
239
 
240
240
  ret_state = exit_state.copy()
241
- guard = (
242
- ret_state.solver.true
243
- if o.TRUE_RET_EMULATION_GUARD in self.state.options
244
- else ret_state.solver.false
245
- )
246
- ret_target = ret_state.solver.BVV(successors.addr + self.state.scratch.irsb.size, ret_state.arch.bits)
241
+ guard = claripy.true if o.TRUE_RET_EMULATION_GUARD in self.state.options else claripy.false
242
+ ret_target = claripy.BVV(successors.addr + self.state.scratch.irsb.size, ret_state.arch.bits)
247
243
  if ret_state.arch.call_pushes_ret and not exit_jumpkind.startswith("Ijk_Sys"):
248
244
  ret_state.regs.sp = ret_state.regs.sp + ret_state.arch.bytes
249
245
  successors.add_successor(
@@ -1,5 +1,6 @@
1
1
  import logging
2
2
 
3
+ import claripy
3
4
  from archinfo.arch_soot import (
4
5
  ArchSoot,
5
6
  SootAddressDescriptor,
@@ -134,7 +135,7 @@ class SootMixin(SuccessorsMixin, ProcedureMixin):
134
135
  next_addr = self._get_next_linear_instruction(state, stmt_idx)
135
136
  l.debug("Advancing execution linearly to %s", next_addr)
136
137
  if next_addr is not None:
137
- successors.add_successor(state.copy(), next_addr, state.solver.true, "Ijk_Boring")
138
+ successors.add_successor(state.copy(), next_addr, claripy.true, "Ijk_Boring")
138
139
 
139
140
  def _handle_soot_stmt(self, state, successors, stmt_idx, stmt):
140
141
  # execute statement
@@ -172,7 +173,7 @@ class SootMixin(SuccessorsMixin, ProcedureMixin):
172
173
  # add invoke state as the successor and terminate execution
173
174
  # prematurely, since Soot does not guarantee that an invoke stmt
174
175
  # terminates a block
175
- successors.add_successor(invoke_state, addr, state.solver.true, "Ijk_Call")
176
+ successors.add_successor(invoke_state, addr, claripy.true, "Ijk_Call")
176
177
  return True
177
178
 
178
179
  # add jmp exit
@@ -198,7 +199,7 @@ class SootMixin(SuccessorsMixin, ProcedureMixin):
198
199
  def _add_return_exit(cls, state, successors, return_val=None):
199
200
  ret_state = state.copy()
200
201
  cls.prepare_return_state(ret_state, return_val)
201
- successors.add_successor(ret_state, state.callstack.ret_addr, ret_state.solver.true, "Ijk_Ret")
202
+ successors.add_successor(ret_state, state.callstack.ret_addr, claripy.true, "Ijk_Ret")
202
203
  successors.processed = True
203
204
 
204
205
  def _get_sim_procedure(self, addr):
@@ -321,9 +322,9 @@ class SootMixin(SuccessorsMixin, ProcedureMixin):
321
322
  if type(statement) is SimSootStmt_Return:
322
323
  exit_code = statement.return_value
323
324
  # TODO symbolic exit code?
324
- exit_code = state.solver.BVV(exit_code, state.arch.bits)
325
+ exit_code = claripy.BVV(exit_code, state.arch.bits)
325
326
  state.history.add_event("terminate", exit_code=exit_code)
326
- successors.add_successor(state, state.regs.ip, state.solver.true, "Ijk_Exit")
327
+ successors.add_successor(state, state.regs.ip, claripy.true, "Ijk_Exit")
327
328
  successors.processed = True
328
329
  raise BlockTerminationNotice()
329
330
 
@@ -345,7 +346,7 @@ class SootMixin(SuccessorsMixin, ProcedureMixin):
345
346
 
346
347
  # set successor flags
347
348
  ret_state.regs._ip = ret_state.callstack.ret_addr
348
- ret_state.scratch.guard = ret_state.solver.true
349
+ ret_state.scratch.guard = claripy.true
349
350
  ret_state.history.jumpkind = "Ijk_Ret"
350
351
 
351
352
  # if available, lookup the return value in native memory
@@ -1,3 +1,4 @@
1
+ import claripy
1
2
  from archinfo.arch_soot import SootClassDescriptor, SootNullConstant
2
3
  from claripy import FSORT_DOUBLE, FSORT_FLOAT
3
4
 
@@ -7,28 +8,28 @@ from .base import SimSootExpr
7
8
 
8
9
  class SimSootExpr_IntConstant(SimSootExpr):
9
10
  def _execute(self):
10
- self.expr = self.state.solver.BVV(self.expr.value, 32)
11
+ self.expr = claripy.BVV(self.expr.value, 32)
11
12
 
12
13
 
13
14
  class SimSootExpr_LongConstant(SimSootExpr):
14
15
  def _execute(self):
15
- self.expr = self.state.solver.BVV(self.expr.value, 64)
16
+ self.expr = claripy.BVV(self.expr.value, 64)
16
17
 
17
18
 
18
19
  class SimSootExpr_FloatConstant(SimSootExpr):
19
20
  def _execute(self):
20
- self.expr = self.state.solver.FPV(self.expr.value, FSORT_FLOAT)
21
+ self.expr = claripy.FPV(self.expr.value, FSORT_FLOAT)
21
22
 
22
23
 
23
24
  class SimSootExpr_DoubleConstant(SimSootExpr):
24
25
  def _execute(self):
25
- self.expr = self.state.solver.FPV(self.expr.value, FSORT_DOUBLE)
26
+ self.expr = claripy.FPV(self.expr.value, FSORT_DOUBLE)
26
27
 
27
28
 
28
29
  class SimSootExpr_StringConstant(SimSootExpr):
29
30
  def _execute(self):
30
31
  # strip away quotes introduced by soot
31
- str_val = self.state.solver.StringV(self.expr.value.strip('"'))
32
+ str_val = claripy.StringV(self.expr.value.strip('"'))
32
33
  str_ref = SimSootValue_StringRef(self.state.memory.get_new_uuid())
33
34
  self.state.memory.store(str_ref, str_val)
34
35
  self.expr = str_ref
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from ..values import SimSootValue_ArrayBaseRef
4
6
  from .base import SimSootExpr
5
7
 
@@ -27,7 +29,7 @@ class SimSootExpr_NewArray(SimSootExpr):
27
29
  @staticmethod
28
30
  def _bound_array_size(state, array_size):
29
31
  # check if array size can exceed MAX_ARRAY_SIZE
30
- max_array_size = state.solver.BVV(state.javavm_memory.max_array_size, 32)
32
+ max_array_size = claripy.BVV(state.javavm_memory.max_array_size, 32)
31
33
  size_stays_below_maximum = state.solver.eval_upto(max_array_size.SGE(array_size), 2)
32
34
 
33
35
  # overwrite size, if it *always* exceeds the maximum
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from .base import SimSootExpr
4
6
  from .newArray import SimSootExpr_NewArray
5
7
  from ..values import SimSootValue_ArrayBaseRef
@@ -39,7 +41,7 @@ class SimSootExpr_NewMultiArray(SimSootExpr):
39
41
  @staticmethod
40
42
  def _bound_multi_array_size(state, multi_array_size):
41
43
  # check if array size can exceed MAX_ARRAY_SIZE
42
- max_multi_array_size = state.solver.BVV(state.javavm_memory.max_array_size, 32)
44
+ max_multi_array_size = claripy.BVV(state.javavm_memory.max_array_size, 32)
43
45
  size_stays_below_maximum = state.solver.eval_upto(max_multi_array_size.SGE(multi_array_size), 2)
44
46
 
45
47
  # overwrite size, if it *always* exceeds the maximum
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from .base import SimSootStmt
4
6
 
5
7
  l = logging.getLogger("angr.engines.soot.statements.goto")
@@ -8,4 +10,4 @@ l = logging.getLogger("angr.engines.soot.statements.goto")
8
10
  class SimSootStmt_Goto(SimSootStmt):
9
11
  def _execute(self):
10
12
  jmp_target = self._get_bb_addr_from_instr(instr=self.stmt.target)
11
- self._add_jmp_target(target=jmp_target, condition=self.state.solver.true)
13
+ self._add_jmp_target(target=jmp_target, condition=claripy.true)
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from .base import SimSootStmt
4
6
 
5
7
  l = logging.getLogger("angr.engines.soot.statements.if")
@@ -12,5 +14,5 @@ class SimSootStmt_If(SimSootStmt):
12
14
  self._add_jmp_target(target=jmp_target, condition=jmp_condition)
13
15
  self._add_jmp_target(
14
16
  target=None, # if target is None, engine goes on linearly
15
- condition=(jmp_condition == self.state.solver.false),
17
+ condition=(jmp_condition == claripy.false),
16
18
  )
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ import claripy
4
+
3
5
  from .base import SimSootStmt
4
6
 
5
7
  l = logging.getLogger("angr.engines.soot.statements.switch")
@@ -26,7 +28,7 @@ class SwitchBase(SimSootStmt):
26
28
 
27
29
  # add default target
28
30
  default_jmp_target = self._get_bb_addr_from_instr(self.stmt.default_target)
29
- default_jmp_cond = self.state.solver.And(*default_jmp_conditions)
31
+ default_jmp_cond = claripy.And(*default_jmp_conditions)
30
32
  self._add_jmp_target(default_jmp_target, default_jmp_cond)
31
33
 
32
34