smallworld-re 1.0.0__py3-none-any.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.
Files changed (166) hide show
  1. smallworld/__init__.py +35 -0
  2. smallworld/analyses/__init__.py +14 -0
  3. smallworld/analyses/analysis.py +88 -0
  4. smallworld/analyses/code_coverage.py +31 -0
  5. smallworld/analyses/colorizer.py +682 -0
  6. smallworld/analyses/colorizer_summary.py +100 -0
  7. smallworld/analyses/field_detection/__init__.py +14 -0
  8. smallworld/analyses/field_detection/field_analysis.py +536 -0
  9. smallworld/analyses/field_detection/guards.py +26 -0
  10. smallworld/analyses/field_detection/hints.py +133 -0
  11. smallworld/analyses/field_detection/malloc.py +211 -0
  12. smallworld/analyses/forced_exec/__init__.py +3 -0
  13. smallworld/analyses/forced_exec/forced_exec.py +87 -0
  14. smallworld/analyses/underlays/__init__.py +4 -0
  15. smallworld/analyses/underlays/basic.py +13 -0
  16. smallworld/analyses/underlays/underlay.py +31 -0
  17. smallworld/analyses/unstable/__init__.py +4 -0
  18. smallworld/analyses/unstable/angr/__init__.py +0 -0
  19. smallworld/analyses/unstable/angr/base.py +12 -0
  20. smallworld/analyses/unstable/angr/divergence.py +274 -0
  21. smallworld/analyses/unstable/angr/model.py +383 -0
  22. smallworld/analyses/unstable/angr/nwbt.py +63 -0
  23. smallworld/analyses/unstable/angr/typedefs.py +170 -0
  24. smallworld/analyses/unstable/angr/utils.py +25 -0
  25. smallworld/analyses/unstable/angr/visitor.py +315 -0
  26. smallworld/analyses/unstable/angr_nwbt.py +106 -0
  27. smallworld/analyses/unstable/code_coverage.py +54 -0
  28. smallworld/analyses/unstable/code_reachable.py +44 -0
  29. smallworld/analyses/unstable/control_flow_tracer.py +71 -0
  30. smallworld/analyses/unstable/pointer_finder.py +90 -0
  31. smallworld/arch/__init__.py +0 -0
  32. smallworld/arch/aarch64_arch.py +286 -0
  33. smallworld/arch/amd64_arch.py +86 -0
  34. smallworld/arch/i386_arch.py +44 -0
  35. smallworld/emulators/__init__.py +14 -0
  36. smallworld/emulators/angr/__init__.py +7 -0
  37. smallworld/emulators/angr/angr.py +1652 -0
  38. smallworld/emulators/angr/default.py +15 -0
  39. smallworld/emulators/angr/exceptions.py +7 -0
  40. smallworld/emulators/angr/exploration/__init__.py +9 -0
  41. smallworld/emulators/angr/exploration/bounds.py +27 -0
  42. smallworld/emulators/angr/exploration/default.py +17 -0
  43. smallworld/emulators/angr/exploration/terminate.py +22 -0
  44. smallworld/emulators/angr/factory.py +55 -0
  45. smallworld/emulators/angr/machdefs/__init__.py +35 -0
  46. smallworld/emulators/angr/machdefs/aarch64.py +292 -0
  47. smallworld/emulators/angr/machdefs/amd64.py +192 -0
  48. smallworld/emulators/angr/machdefs/arm.py +387 -0
  49. smallworld/emulators/angr/machdefs/i386.py +221 -0
  50. smallworld/emulators/angr/machdefs/machdef.py +138 -0
  51. smallworld/emulators/angr/machdefs/mips.py +184 -0
  52. smallworld/emulators/angr/machdefs/mips64.py +189 -0
  53. smallworld/emulators/angr/machdefs/ppc.py +101 -0
  54. smallworld/emulators/angr/machdefs/riscv.py +261 -0
  55. smallworld/emulators/angr/machdefs/xtensa.py +255 -0
  56. smallworld/emulators/angr/memory/__init__.py +7 -0
  57. smallworld/emulators/angr/memory/default.py +10 -0
  58. smallworld/emulators/angr/memory/fixups.py +43 -0
  59. smallworld/emulators/angr/memory/memtrack.py +105 -0
  60. smallworld/emulators/angr/scratch.py +43 -0
  61. smallworld/emulators/angr/simos.py +53 -0
  62. smallworld/emulators/angr/utils.py +70 -0
  63. smallworld/emulators/emulator.py +1013 -0
  64. smallworld/emulators/hookable.py +252 -0
  65. smallworld/emulators/panda/__init__.py +5 -0
  66. smallworld/emulators/panda/machdefs/__init__.py +28 -0
  67. smallworld/emulators/panda/machdefs/aarch64.py +93 -0
  68. smallworld/emulators/panda/machdefs/amd64.py +71 -0
  69. smallworld/emulators/panda/machdefs/arm.py +89 -0
  70. smallworld/emulators/panda/machdefs/i386.py +36 -0
  71. smallworld/emulators/panda/machdefs/machdef.py +86 -0
  72. smallworld/emulators/panda/machdefs/mips.py +94 -0
  73. smallworld/emulators/panda/machdefs/mips64.py +91 -0
  74. smallworld/emulators/panda/machdefs/ppc.py +79 -0
  75. smallworld/emulators/panda/panda.py +575 -0
  76. smallworld/emulators/unicorn/__init__.py +13 -0
  77. smallworld/emulators/unicorn/machdefs/__init__.py +28 -0
  78. smallworld/emulators/unicorn/machdefs/aarch64.py +310 -0
  79. smallworld/emulators/unicorn/machdefs/amd64.py +326 -0
  80. smallworld/emulators/unicorn/machdefs/arm.py +321 -0
  81. smallworld/emulators/unicorn/machdefs/i386.py +137 -0
  82. smallworld/emulators/unicorn/machdefs/machdef.py +117 -0
  83. smallworld/emulators/unicorn/machdefs/mips.py +202 -0
  84. smallworld/emulators/unicorn/unicorn.py +684 -0
  85. smallworld/exceptions/__init__.py +5 -0
  86. smallworld/exceptions/exceptions.py +85 -0
  87. smallworld/exceptions/unstable/__init__.py +1 -0
  88. smallworld/exceptions/unstable/exceptions.py +25 -0
  89. smallworld/extern/__init__.py +4 -0
  90. smallworld/extern/ctypes.py +94 -0
  91. smallworld/extern/unstable/__init__.py +1 -0
  92. smallworld/extern/unstable/ghidra.py +129 -0
  93. smallworld/helpers.py +107 -0
  94. smallworld/hinting/__init__.py +8 -0
  95. smallworld/hinting/hinting.py +214 -0
  96. smallworld/hinting/hints.py +427 -0
  97. smallworld/hinting/unstable/__init__.py +2 -0
  98. smallworld/hinting/utils.py +19 -0
  99. smallworld/instructions/__init__.py +18 -0
  100. smallworld/instructions/aarch64.py +20 -0
  101. smallworld/instructions/arm.py +18 -0
  102. smallworld/instructions/bsid.py +67 -0
  103. smallworld/instructions/instructions.py +258 -0
  104. smallworld/instructions/mips.py +21 -0
  105. smallworld/instructions/x86.py +100 -0
  106. smallworld/logging.py +90 -0
  107. smallworld/platforms.py +95 -0
  108. smallworld/py.typed +0 -0
  109. smallworld/state/__init__.py +6 -0
  110. smallworld/state/cpus/__init__.py +32 -0
  111. smallworld/state/cpus/aarch64.py +563 -0
  112. smallworld/state/cpus/amd64.py +676 -0
  113. smallworld/state/cpus/arm.py +630 -0
  114. smallworld/state/cpus/cpu.py +71 -0
  115. smallworld/state/cpus/i386.py +239 -0
  116. smallworld/state/cpus/mips.py +374 -0
  117. smallworld/state/cpus/mips64.py +372 -0
  118. smallworld/state/cpus/powerpc.py +229 -0
  119. smallworld/state/cpus/riscv.py +357 -0
  120. smallworld/state/cpus/xtensa.py +80 -0
  121. smallworld/state/memory/__init__.py +7 -0
  122. smallworld/state/memory/code.py +70 -0
  123. smallworld/state/memory/elf/__init__.py +3 -0
  124. smallworld/state/memory/elf/elf.py +564 -0
  125. smallworld/state/memory/elf/rela/__init__.py +32 -0
  126. smallworld/state/memory/elf/rela/aarch64.py +27 -0
  127. smallworld/state/memory/elf/rela/amd64.py +32 -0
  128. smallworld/state/memory/elf/rela/arm.py +51 -0
  129. smallworld/state/memory/elf/rela/i386.py +32 -0
  130. smallworld/state/memory/elf/rela/mips.py +45 -0
  131. smallworld/state/memory/elf/rela/ppc.py +45 -0
  132. smallworld/state/memory/elf/rela/rela.py +63 -0
  133. smallworld/state/memory/elf/rela/riscv64.py +27 -0
  134. smallworld/state/memory/elf/rela/xtensa.py +15 -0
  135. smallworld/state/memory/elf/structs.py +55 -0
  136. smallworld/state/memory/heap.py +85 -0
  137. smallworld/state/memory/memory.py +181 -0
  138. smallworld/state/memory/stack/__init__.py +31 -0
  139. smallworld/state/memory/stack/aarch64.py +22 -0
  140. smallworld/state/memory/stack/amd64.py +42 -0
  141. smallworld/state/memory/stack/arm.py +66 -0
  142. smallworld/state/memory/stack/i386.py +22 -0
  143. smallworld/state/memory/stack/mips.py +34 -0
  144. smallworld/state/memory/stack/mips64.py +34 -0
  145. smallworld/state/memory/stack/ppc.py +34 -0
  146. smallworld/state/memory/stack/riscv.py +22 -0
  147. smallworld/state/memory/stack/stack.py +127 -0
  148. smallworld/state/memory/stack/xtensa.py +34 -0
  149. smallworld/state/models/__init__.py +6 -0
  150. smallworld/state/models/mmio.py +186 -0
  151. smallworld/state/models/model.py +163 -0
  152. smallworld/state/models/posix.py +455 -0
  153. smallworld/state/models/x86/__init__.py +2 -0
  154. smallworld/state/models/x86/microsoftcdecl.py +35 -0
  155. smallworld/state/models/x86/systemv.py +240 -0
  156. smallworld/state/state.py +962 -0
  157. smallworld/state/unstable/__init__.py +0 -0
  158. smallworld/state/unstable/elf.py +393 -0
  159. smallworld/state/x86_registers.py +30 -0
  160. smallworld/utils.py +935 -0
  161. smallworld_re-1.0.0.dist-info/LICENSE.txt +21 -0
  162. smallworld_re-1.0.0.dist-info/METADATA +189 -0
  163. smallworld_re-1.0.0.dist-info/RECORD +166 -0
  164. smallworld_re-1.0.0.dist-info/WHEEL +5 -0
  165. smallworld_re-1.0.0.dist-info/entry_points.txt +2 -0
  166. smallworld_re-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,15 @@
1
+ import angr
2
+
3
+ from .exploration import DefaultExplorationTechnique
4
+ from .memory import DefaultMemoryPlugin
5
+ from .scratch import ExpandedScratchPlugin
6
+
7
+
8
+ def configure_default_plugins(emu):
9
+ preset = angr.SimState._presets["default"]
10
+ preset.add_default_plugin("sym_memory", DefaultMemoryPlugin)
11
+ preset.add_default_plugin("scratch", ExpandedScratchPlugin)
12
+
13
+
14
+ def configure_default_strategy(emu):
15
+ emu.mgr.use_technique(DefaultExplorationTechnique())
@@ -0,0 +1,7 @@
1
+ from ... import exceptions
2
+
3
+
4
+ class PathTerminationSignal(exceptions.unstable.AnalysisSignal):
5
+ """Exception allowing an analysis to terminate an execution path."""
6
+
7
+ pass
@@ -0,0 +1,9 @@
1
+ from .bounds import BoundedExplorationMixin
2
+ from .default import DefaultExplorationTechnique
3
+ from .terminate import TerminationExplorationMixin
4
+
5
+ __all__ = [
6
+ "BoundedExplorationMixin",
7
+ "DefaultExplorationTechnique",
8
+ "TerminationExplorationMixin",
9
+ ]
@@ -0,0 +1,27 @@
1
+ import logging
2
+
3
+ log = logging.getLogger(__name__)
4
+
5
+
6
+ class BoundedExplorationMixin:
7
+ """
8
+ Mixin forcing execution to obey our code bounds.
9
+ """
10
+
11
+ def step_state(self, simgr, state, **kwargs):
12
+ if not state._ip.symbolic:
13
+ ip = state._ip.concrete_value
14
+ (r, found) = state.scratch.memory_map.find_closest_range(ip)
15
+ if not found:
16
+ return dict()
17
+ (_, stop) = r
18
+ size = stop - ip
19
+ if not state.scratch.bounds.is_empty():
20
+ (r, found) = state.scratch.bounds.find_closest_range(ip)
21
+ if not found:
22
+ return dict()
23
+ (_, stop) = r
24
+ size = min(size, stop - ip)
25
+
26
+ kwargs["size"] = size
27
+ return super().step_state(simgr, state, **kwargs)
@@ -0,0 +1,17 @@
1
+ import angr
2
+
3
+ from .bounds import BoundedExplorationMixin
4
+ from .terminate import TerminationExplorationMixin
5
+
6
+
7
+ class DefaultExplorationTechnique(
8
+ TerminationExplorationMixin,
9
+ BoundedExplorationMixin,
10
+ angr.exploration_techniques.suggestions.Suggestions,
11
+ ):
12
+ """Default exploration technique.
13
+
14
+ Registers a few default-useful plugins for the SimulationManager.
15
+ """
16
+
17
+ pass
@@ -0,0 +1,22 @@
1
+ from ..exceptions import PathTerminationSignal
2
+
3
+
4
+ class TerminationExplorationMixin:
5
+ """
6
+ Mixin allowing analyses to terminate a single path.
7
+
8
+ This allows analyses to raise an exception
9
+ that aborts successor computation cleanly,
10
+ rather than producing an 'error' state.
11
+
12
+ NOTE: To be effective, this needs to be at the top
13
+ of the mixin hierarchy
14
+ """
15
+
16
+ def step_state(self, simgr, state, **kwargs):
17
+ try:
18
+ out = super().step_state(simgr, state, **kwargs)
19
+ except PathTerminationSignal:
20
+ out = dict()
21
+
22
+ return out
@@ -0,0 +1,55 @@
1
+ import logging
2
+
3
+ from angr.factory import AngrObjectFactory
4
+
5
+ from ...exceptions import AnalysisError
6
+
7
+ log = logging.getLogger(__name__)
8
+
9
+
10
+ class PatchedObjectFactory(AngrObjectFactory):
11
+ """Extension of AngrObjectFactory to allow function overrides
12
+
13
+ There are a couple of core functions (blocks)
14
+ which need to get overloaded, but which are not exposed
15
+ to any kind of plugin interface.
16
+ """
17
+
18
+ def block(self, *args, **kwargs):
19
+ if "backup_state" in kwargs:
20
+ # Bound block lifting based on our code bounds
21
+ # Angr's Vex lifter will happily run off the edge of memory,
22
+ # interpreting undefined memory as zeroes.
23
+ state = kwargs["backup_state"]
24
+ if state._ip.symbolic:
25
+ raise AnalysisError("Cannot build a block for a symbolic IP")
26
+ ip = state._ip.concrete_value
27
+
28
+ # Check if the ip is mapped
29
+ (r, found) = state.scratch.memory_map.find_closest_range(ip)
30
+ if not found:
31
+ # Nope. No code here.
32
+ log.warn(f"No block mapped at {state._ip}")
33
+ max_size = 0
34
+ else:
35
+ # Yep. We have an upper bound on our block
36
+ (start, stop) = r
37
+ max_size = stop - ip
38
+ if not state.scratch.bounds.is_empty():
39
+ # We also have bounds. Test if we're in those
40
+ (r, found) = state.scratch.bounds.find_closest_range(ip)
41
+ if not found:
42
+ # Nope. Out of bounds.
43
+ log.warn(f"{state._ip} is out of bounds")
44
+ max_size = 0
45
+ else:
46
+ # Yep. Allow anything in bounds and in memory
47
+ (start, stop) = r
48
+ max_size = min(max_size, stop - ip)
49
+
50
+ if max_size == 0:
51
+ log.warn(f"Empty block at {state._ip}")
52
+ max_size = min(max_size, 4096)
53
+ kwargs["size"] = max_size
54
+
55
+ return super().block(*args, **kwargs)
@@ -0,0 +1,35 @@
1
+ from .aarch64 import AArch64MachineDef
2
+ from .amd64 import AMD64MachineDef
3
+ from .arm import (
4
+ ARMv5TMachineDef,
5
+ ARMv6MMachineDef,
6
+ ARMv6MThumbMachineDef,
7
+ ARMv7MMachineDef,
8
+ )
9
+ from .i386 import i386MachineDef
10
+ from .machdef import AngrMachineDef
11
+ from .mips import MIPSBEMachineDef, MIPSELMachineDef
12
+ from .mips64 import MIPS64BEMachineDef, MIPS64ELMachineDef
13
+ from .ppc import PowerPC32MachineDef, PowerPC64MachineDef
14
+ from .riscv import RISCV64MachineDef
15
+ from .xtensa import XTensaBEMachineDef, XTensaELMachineDef
16
+
17
+ __all__ = [
18
+ "AArch64MachineDef",
19
+ "AMD64MachineDef",
20
+ "AngrMachineDef",
21
+ "ARMv5TMachineDef",
22
+ "ARMv6MMachineDef",
23
+ "ARMv6MThumbMachineDef",
24
+ "ARMv7MMachineDef",
25
+ "i386MachineDef",
26
+ "MIPSBEMachineDef",
27
+ "MIPSELMachineDef",
28
+ "MIPS64BEMachineDef",
29
+ "MIPS64ELMachineDef",
30
+ "PowerPC32MachineDef",
31
+ "PowerPC64MachineDef",
32
+ "RISCV64MachineDef",
33
+ "XTensaBEMachineDef",
34
+ "XTensaELMachineDef",
35
+ ]
@@ -0,0 +1,292 @@
1
+ import archinfo
2
+
3
+ from ....platforms import Architecture, Byteorder
4
+ from .machdef import AngrMachineDef
5
+
6
+
7
+ class AArch64MachineDef(AngrMachineDef):
8
+ arch = Architecture.AARCH64
9
+ byteorder = Byteorder.LITTLE
10
+
11
+ angr_arch = archinfo.arch_aarch64.ArchAArch64()
12
+ pc_reg = "pc"
13
+
14
+ _registers = {
15
+ # *** General Purpose Registers ***
16
+ "x0": "x0",
17
+ "w0": "w0",
18
+ "x1": "x1",
19
+ "w1": "w1",
20
+ "x2": "x2",
21
+ "w2": "w2",
22
+ "x3": "x3",
23
+ "w3": "w3",
24
+ "x4": "x4",
25
+ "w4": "w4",
26
+ "x5": "x5",
27
+ "w5": "w5",
28
+ "x6": "x6",
29
+ "w6": "w6",
30
+ "x7": "x7",
31
+ "w7": "w7",
32
+ "x8": "x8",
33
+ "w8": "w8",
34
+ "x9": "x9",
35
+ "w9": "w9",
36
+ "x10": "x10",
37
+ "w10": "w10",
38
+ "x11": "x11",
39
+ "w11": "w11",
40
+ "x12": "x12",
41
+ "w12": "w12",
42
+ "x13": "x13",
43
+ "w13": "w13",
44
+ "x14": "x14",
45
+ "w14": "w14",
46
+ "x15": "x15",
47
+ "w15": "w15",
48
+ "x16": "x16",
49
+ "w16": "w16",
50
+ "x17": "x17",
51
+ "w17": "w17",
52
+ "x18": "x18",
53
+ "w18": "w18",
54
+ "x19": "x19",
55
+ "w19": "w19",
56
+ "x20": "x20",
57
+ "w20": "w20",
58
+ "x21": "x21",
59
+ "w21": "w21",
60
+ "x22": "x22",
61
+ "w22": "w22",
62
+ "x23": "x23",
63
+ "w23": "w23",
64
+ "x24": "x24",
65
+ "w24": "w24",
66
+ "x25": "x25",
67
+ "w25": "w25",
68
+ "x26": "x26",
69
+ "w26": "w26",
70
+ "x27": "x27",
71
+ "w27": "w27",
72
+ "x28": "x28",
73
+ "w28": "w28",
74
+ "x29": "x29",
75
+ "w29": "w29",
76
+ "x30": "x30",
77
+ "w30": "w30",
78
+ "pc": "pc",
79
+ "sp": "sp",
80
+ "fp": "fp",
81
+ "lr": "lr",
82
+ "xzr": "xzr",
83
+ "wzr": "wzr",
84
+ # *** System Control Registers ***
85
+ # NOTE: "_elX" indicates that only exception level X or greater can access this register.
86
+ # NOTE: This list is far from complete; it only covers what Unicorn supports
87
+ # NOTE: angr's aarch64 model is aggressively userspace-only. None of these are supported
88
+ # Condition Code Register
89
+ "fpcr": "",
90
+ # Floating Point Status Register
91
+ "fpsr": "",
92
+ # Banked stack pointers for exception handlers
93
+ "sp_el0": "",
94
+ "sp_el1": "",
95
+ "sp_el2": "",
96
+ "sp_el3": "",
97
+ # Banked link registers for exception handlers
98
+ # NOTE: Unicorn thinks there's an elr_el0; according to docs, it doesn't exist
99
+ "elr_el1": "",
100
+ "elr_el2": "",
101
+ "elr_el3": "",
102
+ # Banked exception syndrome registers for exception handlers
103
+ # NOTE: Unicorn thinks there's a far_el0; according to docs, it doesn't exist
104
+ "far_el1": "",
105
+ "far_el2": "",
106
+ "far_el3": "",
107
+ # Banked vector base address registers for exception handlers
108
+ # NOTE: vbar_el0 and vbar_el1 are aliases for each other.
109
+ # Since vbar_el0 doesn't exist in angr, vbar_el1 has to be the "real" copy.
110
+ "vbar_el1": "",
111
+ "vbar_el0": "",
112
+ "vbar_el2": "",
113
+ "vbar_el3": "",
114
+ # Coprocessor access control register
115
+ "cpacr_el1": "",
116
+ # Memory Attribute Indirection Register
117
+ "mair_el1": "",
118
+ # Physical Address Register
119
+ "par_el1": "",
120
+ # Translation Table Zero Base Register
121
+ "ttbr0_el1": "",
122
+ # Translation Table One Base Register
123
+ "ttbr1_el1": "",
124
+ # Thread ID Register
125
+ # NOTE: According to docs, there should be an el2 and el3 copy, too.
126
+ "tpidr_el0": "",
127
+ "tpidr_el1": "",
128
+ # Userspace-visible Thread ID register
129
+ "tpidrro_el0": "",
130
+ # *** Floating Point Registers ***
131
+ # Scalar Floating Point Registers
132
+ "q0": "q0",
133
+ "d0": "d0",
134
+ "s0": "s0",
135
+ "h0": "h0",
136
+ "b0": "b0",
137
+ "q1": "q1",
138
+ "d1": "d1",
139
+ "s1": "s1",
140
+ "h1": "h1",
141
+ "b1": "b1",
142
+ "q2": "q2",
143
+ "d2": "d2",
144
+ "s2": "s2",
145
+ "h2": "h2",
146
+ "b2": "b2",
147
+ "q3": "q3",
148
+ "d3": "d3",
149
+ "s3": "s3",
150
+ "h3": "h3",
151
+ "b3": "b3",
152
+ "q4": "q4",
153
+ "d4": "d4",
154
+ "s4": "s4",
155
+ "h4": "h4",
156
+ "b4": "b4",
157
+ "q5": "q5",
158
+ "d5": "d5",
159
+ "s5": "s5",
160
+ "h5": "h5",
161
+ "b5": "b5",
162
+ "q6": "q6",
163
+ "d6": "d6",
164
+ "s6": "s6",
165
+ "h6": "h6",
166
+ "b6": "b6",
167
+ "q7": "q7",
168
+ "d7": "d7",
169
+ "s7": "s7",
170
+ "h7": "h7",
171
+ "b7": "b7",
172
+ "q8": "q8",
173
+ "d8": "d8",
174
+ "s8": "s8",
175
+ "h8": "h8",
176
+ "b8": "b8",
177
+ "q9": "q9",
178
+ "d9": "d9",
179
+ "s9": "s9",
180
+ "h9": "h9",
181
+ "b9": "b9",
182
+ "q10": "q10",
183
+ "d10": "d10",
184
+ "s10": "s10",
185
+ "h10": "h10",
186
+ "b10": "b10",
187
+ "q11": "q11",
188
+ "d11": "d11",
189
+ "s11": "s11",
190
+ "h11": "h11",
191
+ "b11": "b11",
192
+ "q12": "q12",
193
+ "d12": "d12",
194
+ "s12": "s12",
195
+ "h12": "h12",
196
+ "b12": "b12",
197
+ "q13": "q13",
198
+ "d13": "d13",
199
+ "s13": "s13",
200
+ "h13": "h13",
201
+ "b13": "b13",
202
+ "q14": "q14",
203
+ "d14": "d14",
204
+ "s14": "s14",
205
+ "h14": "h14",
206
+ "b14": "b14",
207
+ "q15": "q15",
208
+ "d15": "d15",
209
+ "s15": "s15",
210
+ "h15": "h15",
211
+ "b15": "b15",
212
+ "q16": "q16",
213
+ "d16": "d16",
214
+ "s16": "s16",
215
+ "h16": "h16",
216
+ "b16": "b16",
217
+ "q17": "q17",
218
+ "d17": "d17",
219
+ "s17": "s17",
220
+ "h17": "h17",
221
+ "b17": "b17",
222
+ "q18": "q18",
223
+ "d18": "d18",
224
+ "s18": "s18",
225
+ "h18": "h18",
226
+ "b18": "b18",
227
+ "q19": "q19",
228
+ "d19": "d19",
229
+ "s19": "s19",
230
+ "h19": "h19",
231
+ "b19": "b19",
232
+ "q20": "q20",
233
+ "d20": "d20",
234
+ "s20": "s20",
235
+ "h20": "h20",
236
+ "b20": "b20",
237
+ "q21": "q21",
238
+ "d21": "d21",
239
+ "s21": "s21",
240
+ "h21": "h21",
241
+ "b21": "b21",
242
+ "q22": "q22",
243
+ "d22": "d22",
244
+ "s22": "s22",
245
+ "h22": "h22",
246
+ "b22": "b22",
247
+ "q23": "q23",
248
+ "d23": "d23",
249
+ "s23": "s23",
250
+ "h23": "h23",
251
+ "b23": "b23",
252
+ "q24": "q24",
253
+ "d24": "d24",
254
+ "s24": "s24",
255
+ "h24": "h24",
256
+ "b24": "b24",
257
+ "q25": "q25",
258
+ "d25": "d25",
259
+ "s25": "s25",
260
+ "h25": "h25",
261
+ "b25": "b25",
262
+ "q26": "q26",
263
+ "d26": "d26",
264
+ "s26": "s26",
265
+ "h26": "h26",
266
+ "b26": "b26",
267
+ "q27": "q27",
268
+ "d27": "d27",
269
+ "s27": "s27",
270
+ "h27": "h27",
271
+ "b27": "b27",
272
+ "q28": "q28",
273
+ "d28": "d28",
274
+ "s28": "s28",
275
+ "h28": "h28",
276
+ "b28": "b28",
277
+ "q29": "q29",
278
+ "d29": "d29",
279
+ "s29": "s29",
280
+ "h29": "h29",
281
+ "b29": "b29",
282
+ "q30": "q30",
283
+ "d30": "d30",
284
+ "s30": "s30",
285
+ "h30": "h30",
286
+ "b30": "b30",
287
+ "q31": "q31",
288
+ "d31": "d31",
289
+ "s31": "s31",
290
+ "h31": "h31",
291
+ "b31": "b31",
292
+ }
@@ -0,0 +1,192 @@
1
+ import archinfo
2
+
3
+ from ....platforms import Architecture, Byteorder
4
+ from .machdef import AngrMachineDef
5
+
6
+
7
+ class AMD64MachineDef(AngrMachineDef):
8
+ # NOTE: angr doesn't support AVX512
9
+ # Thus, this is our only amd64 machdef
10
+ arch = Architecture.X86_64
11
+ byteorder = Byteorder.LITTLE
12
+
13
+ angr_arch = archinfo.arch_amd64.ArchAMD64()
14
+
15
+ pc_reg = "rip"
16
+
17
+ _registers = {
18
+ # *** General Purpose Registers ***
19
+ "rax": "rax",
20
+ "eax": "eax",
21
+ "ax": "ax",
22
+ "al": "al",
23
+ "ah": "ah",
24
+ "rbx": "rbx",
25
+ "ebx": "ebx",
26
+ "bx": "bx",
27
+ "bl": "bl",
28
+ "bh": "bh",
29
+ "rcx": "rcx",
30
+ "ecx": "ecx",
31
+ "cx": "cx",
32
+ "cl": "cl",
33
+ "ch": "ch",
34
+ "rdx": "rdx",
35
+ "edx": "edx",
36
+ "dx": "dx",
37
+ "dl": "dl",
38
+ "dh": "dh",
39
+ "r8": "r8",
40
+ "r8d": "r8d",
41
+ "r8w": "r8w",
42
+ "r8b": "r8b",
43
+ "r9": "r9",
44
+ "r9d": "r9d",
45
+ "r9w": "r9w",
46
+ "r9b": "r9b",
47
+ "r10": "r10",
48
+ "r10d": "r10d",
49
+ "r10w": "r10w",
50
+ "r10b": "r10b",
51
+ "r11": "r11",
52
+ "r11d": "r11d",
53
+ "r11w": "r11w",
54
+ "r11b": "r11b",
55
+ "r12": "r12",
56
+ "r12d": "r12d",
57
+ "r12w": "r12w",
58
+ "r12b": "r12b",
59
+ "r13": "r13",
60
+ "r13d": "r13d",
61
+ "r13w": "r13w",
62
+ "r13b": "r13b",
63
+ "r14": "r14",
64
+ "r14d": "r14d",
65
+ "r14w": "r14w",
66
+ "r14b": "r14b",
67
+ "r15": "r15",
68
+ "r15d": "r15d",
69
+ "r15w": "r15w",
70
+ "r15b": "r15b",
71
+ "rsi": "rsi",
72
+ "esi": "esi",
73
+ "si": "si",
74
+ "sil": "sil",
75
+ "rdi": "rdi",
76
+ "edi": "edi",
77
+ "di": "di",
78
+ "dil": "dil",
79
+ "rbp": "rbp",
80
+ "ebp": "ebp",
81
+ "bp": "bp",
82
+ "bpl": "bpl",
83
+ "rsp": "rsp",
84
+ "esp": "esp",
85
+ "sp": "sp",
86
+ "spl": "spl",
87
+ # *** Instruction Pointer ***
88
+ "rip": "rip",
89
+ "eip": "eip",
90
+ "ip": "ip",
91
+ # *** Segment Registers ***
92
+ "cs": "",
93
+ "ds": "",
94
+ "es": "",
95
+ "fs": "fs",
96
+ "gs": "gs",
97
+ "ss": "",
98
+ # *** Flags Register ***
99
+ "rflags": "rflags",
100
+ "eflags": "eflags",
101
+ "flags": "flags",
102
+ # *** Control Registers ***
103
+ "cr0": "cr0",
104
+ "cr1": "",
105
+ "cr2": "cr2",
106
+ "cr3": "cr3",
107
+ "cr4": "cr4",
108
+ "cr8": "cr8",
109
+ # *** Debug Registers ***
110
+ "dr0": "",
111
+ "dr1": "",
112
+ "dr2": "",
113
+ "dr3": "",
114
+ "dr6": "",
115
+ "dr7": "",
116
+ "dr8": "",
117
+ "dr9": "",
118
+ "dr10": "",
119
+ "dr11": "",
120
+ "dr12": "",
121
+ "dr13": "",
122
+ "dr14": "",
123
+ "dr15": "",
124
+ # *** Descriptor Table Registers ***
125
+ "gdtr": "",
126
+ "idtr": "",
127
+ "ldtr": "",
128
+ # *** Task Register ***
129
+ "tr": "",
130
+ # *** x87 Registers ***
131
+ # TODO: angr seems to support x87, but I have no idea how its register file works
132
+ # I can't find most of the control registers,
133
+ # and there don't seem to be separate "fprN" registers; just one giant blob
134
+ "fpr0": "",
135
+ "fpr1": "",
136
+ "fpr2": "",
137
+ "fpr3": "",
138
+ "fpr4": "",
139
+ "fpr5": "",
140
+ "fpr6": "",
141
+ "fpr7": "",
142
+ "fctrl": "",
143
+ "fstat": "",
144
+ "ftag": "fptag",
145
+ "fip": "",
146
+ "fdp": "",
147
+ "fop": "",
148
+ # *** MMX Registers ***
149
+ "mm0": "mm0",
150
+ "mm1": "mm1",
151
+ "mm2": "mm2",
152
+ "mm3": "mm3",
153
+ "mm4": "mm4",
154
+ "mm5": "mm5",
155
+ "mm6": "mm6",
156
+ "mm7": "mm7",
157
+ # SSE/AVX registers
158
+ "ymm0": "ymm0",
159
+ "xmm0": "xmm0",
160
+ "ymm1": "ymm1",
161
+ "xmm1": "xmm1",
162
+ "ymm2": "ymm2",
163
+ "xmm2": "xmm2",
164
+ "ymm3": "ymm3",
165
+ "xmm3": "xmm3",
166
+ "ymm4": "ymm4",
167
+ "xmm4": "xmm4",
168
+ "ymm5": "ymm5",
169
+ "xmm5": "xmm5",
170
+ "ymm6": "ymm6",
171
+ "xmm6": "xmm6",
172
+ "ymm7": "ymm7",
173
+ "xmm7": "xmm7",
174
+ "ymm8": "ymm8",
175
+ "xmm8": "xmm8",
176
+ "ymm9": "ymm9",
177
+ "xmm9": "xmm9",
178
+ "ymm10": "ymm10",
179
+ "xmm10": "xmm10",
180
+ "ymm11": "ymm11",
181
+ "xmm11": "xmm11",
182
+ "ymm12": "ymm12",
183
+ "xmm12": "xmm12",
184
+ "ymm13": "ymm13",
185
+ "xmm13": "xmm13",
186
+ "ymm14": "ymm14",
187
+ "xmm14": "xmm14",
188
+ "ymm15": "ymm15",
189
+ "xmm15": "xmm15",
190
+ "ymm16": "ymm16",
191
+ "xmm16": "xmm16",
192
+ }