smallworld-re 1.0.2__py3-none-any.whl → 2.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.
- smallworld/analyses/__init__.py +8 -0
- smallworld/analyses/analysis.py +8 -67
- smallworld/analyses/code_coverage.py +1 -2
- smallworld/analyses/colorizer.py +301 -534
- smallworld/analyses/colorizer_def_use.py +217 -0
- smallworld/analyses/colorizer_summary.py +173 -83
- smallworld/analyses/field_detection/field_analysis.py +7 -8
- smallworld/analyses/field_detection/hints.py +1 -1
- smallworld/analyses/field_detection/malloc.py +2 -2
- smallworld/analyses/trace_execution.py +160 -0
- smallworld/analyses/trace_execution_types.py +42 -0
- smallworld/analyses/unstable/angr/divergence.py +1 -2
- smallworld/analyses/unstable/angr/model.py +5 -6
- smallworld/analyses/unstable/angr_nwbt.py +3 -4
- smallworld/analyses/unstable/code_coverage.py +2 -3
- smallworld/analyses/unstable/code_reachable.py +2 -3
- smallworld/analyses/unstable/control_flow_tracer.py +2 -3
- smallworld/analyses/unstable/pointer_finder.py +2 -3
- smallworld/analyses/unstable/utils/tui.py +71 -0
- smallworld/emulators/__init__.py +3 -1
- smallworld/emulators/angr/angr.py +30 -9
- smallworld/emulators/angr/machdefs/__init__.py +2 -0
- smallworld/emulators/angr/machdefs/aarch64.py +1 -1
- smallworld/emulators/angr/machdefs/amd64.py +0 -4
- smallworld/emulators/angr/machdefs/arm.py +0 -2
- smallworld/emulators/angr/machdefs/i386.py +0 -2
- smallworld/emulators/angr/machdefs/loongarch.py +340 -0
- smallworld/emulators/angr/machdefs/machdef.py +1 -8
- smallworld/emulators/angr/machdefs/mips.py +0 -2
- smallworld/emulators/angr/machdefs/mips64.py +0 -2
- smallworld/emulators/angr/machdefs/ppc.py +1 -2
- smallworld/emulators/angr/machdefs/riscv.py +8 -10
- smallworld/emulators/angr/machdefs/xtensa.py +7 -4
- smallworld/emulators/emulator.py +22 -0
- smallworld/emulators/ghidra/__init__.py +37 -0
- smallworld/emulators/ghidra/ghidra.py +513 -0
- smallworld/emulators/ghidra/machdefs/__init__.py +31 -0
- smallworld/emulators/ghidra/machdefs/aarch64.py +289 -0
- smallworld/emulators/ghidra/machdefs/amd64.py +185 -0
- smallworld/emulators/ghidra/machdefs/arm.py +370 -0
- smallworld/emulators/ghidra/machdefs/i386.py +109 -0
- smallworld/emulators/ghidra/machdefs/loongarch.py +162 -0
- smallworld/emulators/ghidra/machdefs/machdef.py +81 -0
- smallworld/emulators/ghidra/machdefs/mips.py +163 -0
- smallworld/emulators/ghidra/machdefs/mips64.py +186 -0
- smallworld/emulators/ghidra/machdefs/ppc.py +98 -0
- smallworld/emulators/ghidra/machdefs/riscv.py +208 -0
- smallworld/emulators/ghidra/machdefs/xtensa.py +21 -0
- smallworld/emulators/ghidra/typing.py +28 -0
- smallworld/emulators/hookable.py +18 -4
- smallworld/emulators/panda/machdefs/__init__.py +2 -2
- smallworld/emulators/panda/machdefs/aarch64.py +186 -11
- smallworld/emulators/panda/machdefs/amd64.py +103 -11
- smallworld/emulators/panda/machdefs/arm.py +216 -20
- smallworld/emulators/panda/machdefs/i386.py +30 -7
- smallworld/emulators/panda/machdefs/machdef.py +9 -16
- smallworld/emulators/panda/machdefs/mips.py +49 -5
- smallworld/emulators/panda/machdefs/mips64.py +57 -5
- smallworld/emulators/panda/machdefs/ppc.py +38 -13
- smallworld/emulators/panda/panda.py +146 -44
- smallworld/emulators/unicorn/__init__.py +2 -0
- smallworld/emulators/unicorn/machdefs/aarch64.py +253 -264
- smallworld/emulators/unicorn/machdefs/amd64.py +254 -259
- smallworld/emulators/unicorn/machdefs/arm.py +200 -212
- smallworld/emulators/unicorn/machdefs/i386.py +84 -90
- smallworld/emulators/unicorn/machdefs/machdef.py +2 -23
- smallworld/emulators/unicorn/machdefs/mips.py +127 -135
- smallworld/emulators/unicorn/unicorn.py +52 -13
- smallworld/helpers.py +4 -19
- smallworld/hinting/hinting.py +22 -192
- smallworld/hinting/hints.py +50 -18
- smallworld/instructions/bsid.py +8 -8
- smallworld/logging.py +4 -2
- smallworld/platforms/__init__.py +12 -0
- smallworld/platforms/defs/__init__.py +36 -0
- smallworld/platforms/defs/aarch64.py +450 -0
- smallworld/platforms/defs/amd64.py +463 -0
- smallworld/platforms/defs/arm.py +519 -0
- smallworld/platforms/defs/i386.py +258 -0
- smallworld/platforms/defs/loongarch.py +270 -0
- smallworld/platforms/defs/mips.py +321 -0
- smallworld/platforms/defs/mips64.py +313 -0
- smallworld/platforms/defs/platformdef.py +97 -0
- smallworld/platforms/defs/powerpc.py +259 -0
- smallworld/platforms/defs/riscv.py +257 -0
- smallworld/platforms/defs/xtensa.py +96 -0
- smallworld/{platforms.py → platforms/platforms.py} +3 -0
- smallworld/state/cpus/__init__.py +2 -0
- smallworld/state/cpus/aarch64.py +0 -9
- smallworld/state/cpus/amd64.py +6 -28
- smallworld/state/cpus/arm.py +0 -11
- smallworld/state/cpus/cpu.py +0 -11
- smallworld/state/cpus/i386.py +0 -7
- smallworld/state/cpus/loongarch.py +299 -0
- smallworld/state/cpus/mips.py +4 -47
- smallworld/state/cpus/mips64.py +18 -58
- smallworld/state/cpus/powerpc.py +2 -9
- smallworld/state/cpus/riscv.py +1 -11
- smallworld/state/cpus/xtensa.py +0 -5
- smallworld/state/memory/code.py +44 -2
- smallworld/state/memory/elf/__init__.py +5 -1
- smallworld/state/memory/elf/coredump/__init__.py +3 -0
- smallworld/state/memory/elf/coredump/coredump.py +46 -0
- smallworld/state/memory/elf/coredump/prstatus/__init__.py +27 -0
- smallworld/state/memory/elf/coredump/prstatus/aarch64.py +46 -0
- smallworld/state/memory/elf/coredump/prstatus/amd64.py +40 -0
- smallworld/state/memory/elf/coredump/prstatus/arm.py +53 -0
- smallworld/state/memory/elf/coredump/prstatus/i386.py +30 -0
- smallworld/state/memory/elf/coredump/prstatus/mips.py +55 -0
- smallworld/state/memory/elf/coredump/prstatus/mips64.py +57 -0
- smallworld/state/memory/elf/coredump/prstatus/ppc.py +82 -0
- smallworld/state/memory/elf/coredump/prstatus/prstatus.py +129 -0
- smallworld/state/memory/elf/elf.py +225 -61
- smallworld/state/memory/elf/register_state.py +36 -0
- smallworld/state/memory/elf/rela/__init__.py +2 -0
- smallworld/state/memory/elf/rela/aarch64.py +3 -1
- smallworld/state/memory/elf/rela/amd64.py +4 -2
- smallworld/state/memory/elf/rela/arm.py +4 -2
- smallworld/state/memory/elf/rela/i386.py +4 -2
- smallworld/state/memory/elf/rela/loongarch.py +32 -0
- smallworld/state/memory/elf/rela/mips.py +39 -18
- smallworld/state/memory/elf/rela/ppc.py +31 -14
- smallworld/state/memory/elf/structs.py +3 -0
- smallworld/state/memory/heap.py +2 -2
- smallworld/state/memory/memory.py +18 -0
- smallworld/state/memory/pe/__init__.py +3 -0
- smallworld/state/memory/pe/pe.py +361 -0
- smallworld/state/memory/pe/structs.py +60 -0
- smallworld/state/memory/stack/__init__.py +2 -0
- smallworld/state/memory/stack/loongarch.py +26 -0
- smallworld/state/models/__init__.py +29 -2
- smallworld/state/models/aarch64/__init__.py +1 -0
- smallworld/state/models/aarch64/systemv/__init__.py +6 -0
- smallworld/state/models/aarch64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/aarch64/systemv/c99/signal.py +16 -0
- smallworld/state/models/aarch64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/aarch64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/aarch64/systemv/c99/string.py +139 -0
- smallworld/state/models/aarch64/systemv/c99/time.py +61 -0
- smallworld/state/models/aarch64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/aarch64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/aarch64/systemv/posix/signal.py +157 -0
- smallworld/state/models/aarch64/systemv/systemv.py +80 -0
- smallworld/state/models/amd64/__init__.py +1 -0
- smallworld/state/models/amd64/systemv/__init__.py +6 -0
- smallworld/state/models/amd64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/amd64/systemv/c99/signal.py +16 -0
- smallworld/state/models/amd64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/amd64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/amd64/systemv/c99/string.py +139 -0
- smallworld/state/models/amd64/systemv/c99/time.py +61 -0
- smallworld/state/models/amd64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/amd64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/amd64/systemv/posix/signal.py +157 -0
- smallworld/state/models/amd64/systemv/systemv.py +78 -0
- smallworld/state/models/armel/__init__.py +1 -0
- smallworld/state/models/armel/systemv/__init__.py +6 -0
- smallworld/state/models/armel/systemv/c99/__init__.py +12 -0
- smallworld/state/models/armel/systemv/c99/signal.py +16 -0
- smallworld/state/models/armel/systemv/c99/stdio.py +265 -0
- smallworld/state/models/armel/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/armel/systemv/c99/string.py +139 -0
- smallworld/state/models/armel/systemv/c99/time.py +61 -0
- smallworld/state/models/armel/systemv/posix/__init__.py +6 -0
- smallworld/state/models/armel/systemv/posix/libgen.py +16 -0
- smallworld/state/models/armel/systemv/posix/signal.py +157 -0
- smallworld/state/models/armel/systemv/systemv.py +82 -0
- smallworld/state/models/armhf/__init__.py +1 -0
- smallworld/state/models/armhf/systemv/__init__.py +6 -0
- smallworld/state/models/armhf/systemv/c99/__init__.py +12 -0
- smallworld/state/models/armhf/systemv/c99/signal.py +16 -0
- smallworld/state/models/armhf/systemv/c99/stdio.py +265 -0
- smallworld/state/models/armhf/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/armhf/systemv/c99/string.py +139 -0
- smallworld/state/models/armhf/systemv/c99/time.py +61 -0
- smallworld/state/models/armhf/systemv/posix/__init__.py +6 -0
- smallworld/state/models/armhf/systemv/posix/libgen.py +16 -0
- smallworld/state/models/armhf/systemv/posix/signal.py +157 -0
- smallworld/state/models/armhf/systemv/systemv.py +77 -0
- smallworld/state/models/c99/__init__.py +12 -0
- smallworld/state/models/c99/fmt_print.py +915 -0
- smallworld/state/models/c99/fmt_scan.py +864 -0
- smallworld/state/models/c99/math.py +362 -0
- smallworld/state/models/c99/signal.py +71 -0
- smallworld/state/models/c99/stdio.py +1305 -0
- smallworld/state/models/c99/stdlib.py +595 -0
- smallworld/state/models/c99/string.py +674 -0
- smallworld/state/models/c99/time.py +340 -0
- smallworld/state/models/c99/utils.py +89 -0
- smallworld/state/models/cstd.py +759 -0
- smallworld/state/models/errno.py +581 -0
- smallworld/state/models/filedesc.py +515 -0
- smallworld/state/models/i386/__init__.py +1 -0
- smallworld/state/models/i386/systemv/__init__.py +6 -0
- smallworld/state/models/i386/systemv/c99/__init__.py +12 -0
- smallworld/state/models/i386/systemv/c99/signal.py +16 -0
- smallworld/state/models/i386/systemv/c99/stdio.py +265 -0
- smallworld/state/models/i386/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/i386/systemv/c99/string.py +139 -0
- smallworld/state/models/i386/systemv/c99/time.py +61 -0
- smallworld/state/models/i386/systemv/posix/__init__.py +6 -0
- smallworld/state/models/i386/systemv/posix/libgen.py +16 -0
- smallworld/state/models/i386/systemv/posix/signal.py +157 -0
- smallworld/state/models/i386/systemv/systemv.py +71 -0
- smallworld/state/models/loongarch64/__init__.py +1 -0
- smallworld/state/models/loongarch64/systemv/__init__.py +6 -0
- smallworld/state/models/loongarch64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/loongarch64/systemv/c99/signal.py +16 -0
- smallworld/state/models/loongarch64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/loongarch64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/loongarch64/systemv/c99/string.py +139 -0
- smallworld/state/models/loongarch64/systemv/c99/time.py +61 -0
- smallworld/state/models/loongarch64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/loongarch64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/loongarch64/systemv/posix/signal.py +157 -0
- smallworld/state/models/loongarch64/systemv/systemv.py +83 -0
- smallworld/state/models/mips/__init__.py +1 -0
- smallworld/state/models/mips/systemv/__init__.py +6 -0
- smallworld/state/models/mips/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips/systemv/c99/string.py +139 -0
- smallworld/state/models/mips/systemv/c99/time.py +61 -0
- smallworld/state/models/mips/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips/systemv/systemv.py +78 -0
- smallworld/state/models/mips64/__init__.py +1 -0
- smallworld/state/models/mips64/systemv/__init__.py +6 -0
- smallworld/state/models/mips64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips64/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips64/systemv/c99/string.py +139 -0
- smallworld/state/models/mips64/systemv/c99/time.py +61 -0
- smallworld/state/models/mips64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips64/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips64/systemv/systemv.py +98 -0
- smallworld/state/models/mips64el/__init__.py +1 -0
- smallworld/state/models/mips64el/systemv/__init__.py +6 -0
- smallworld/state/models/mips64el/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips64el/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips64el/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips64el/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips64el/systemv/c99/string.py +139 -0
- smallworld/state/models/mips64el/systemv/c99/time.py +61 -0
- smallworld/state/models/mips64el/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips64el/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips64el/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips64el/systemv/systemv.py +96 -0
- smallworld/state/models/mipsel/__init__.py +1 -0
- smallworld/state/models/mipsel/systemv/__init__.py +6 -0
- smallworld/state/models/mipsel/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mipsel/systemv/c99/signal.py +16 -0
- smallworld/state/models/mipsel/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mipsel/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mipsel/systemv/c99/string.py +139 -0
- smallworld/state/models/mipsel/systemv/c99/time.py +61 -0
- smallworld/state/models/mipsel/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mipsel/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mipsel/systemv/posix/signal.py +157 -0
- smallworld/state/models/mipsel/systemv/systemv.py +78 -0
- smallworld/state/models/model.py +27 -2
- smallworld/state/models/posix/__init__.py +6 -0
- smallworld/state/models/posix/libgen.py +123 -0
- smallworld/state/models/posix/signal.py +690 -0
- smallworld/state/models/powerpc/__init__.py +1 -0
- smallworld/state/models/powerpc/systemv/__init__.py +6 -0
- smallworld/state/models/powerpc/systemv/c99/__init__.py +12 -0
- smallworld/state/models/powerpc/systemv/c99/signal.py +16 -0
- smallworld/state/models/powerpc/systemv/c99/stdio.py +265 -0
- smallworld/state/models/powerpc/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/powerpc/systemv/c99/string.py +139 -0
- smallworld/state/models/powerpc/systemv/c99/time.py +61 -0
- smallworld/state/models/powerpc/systemv/posix/__init__.py +6 -0
- smallworld/state/models/powerpc/systemv/posix/libgen.py +16 -0
- smallworld/state/models/powerpc/systemv/posix/signal.py +157 -0
- smallworld/state/models/powerpc/systemv/systemv.py +93 -0
- smallworld/state/models/riscv64/__init__.py +1 -0
- smallworld/state/models/riscv64/systemv/__init__.py +6 -0
- smallworld/state/models/riscv64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/riscv64/systemv/c99/signal.py +16 -0
- smallworld/state/models/riscv64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/riscv64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/riscv64/systemv/c99/string.py +139 -0
- smallworld/state/models/riscv64/systemv/c99/time.py +61 -0
- smallworld/state/models/riscv64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/riscv64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/riscv64/systemv/posix/signal.py +157 -0
- smallworld/state/models/riscv64/systemv/systemv.py +85 -0
- smallworld/state/state.py +65 -24
- smallworld/state/unstable/elf.py +16 -31
- smallworld/utils.py +6 -1
- {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/METADATA +76 -43
- smallworld_re-2.0.0.dist-info/RECORD +374 -0
- {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/WHEEL +1 -1
- smallworld/state/models/x86/__init__.py +0 -2
- smallworld/state/models/x86/microsoftcdecl.py +0 -35
- smallworld/state/models/x86/systemv.py +0 -240
- smallworld_re-1.0.2.dist-info/RECORD +0 -166
- /smallworld/state/models/{posix.py → _posix.py} +0 -0
- {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/entry_points.txt +0 -0
- {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info/licenses}/LICENSE.txt +0 -0
- {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,8 @@
|
|
1
|
-
import capstone
|
2
|
-
|
3
1
|
from ....platforms import Architecture, Byteorder
|
4
2
|
from .machdef import PandaMachineDef
|
5
3
|
|
6
4
|
|
7
5
|
class ARMMachineDef(PandaMachineDef):
|
8
|
-
cs_arch = capstone.CS_ARCH_ARM
|
9
|
-
cs_mode = capstone.CS_MODE_ARM | capstone.CS_MODE_LITTLE_ENDIAN
|
10
|
-
|
11
6
|
panda_arch = "arm"
|
12
7
|
|
13
8
|
# I'm going to define all the ones we are making possible as of now
|
@@ -29,11 +24,16 @@ class ARMMachineDef(PandaMachineDef):
|
|
29
24
|
"r12",
|
30
25
|
"sp",
|
31
26
|
"lr",
|
32
|
-
"
|
27
|
+
"pc",
|
33
28
|
}
|
34
29
|
|
35
30
|
self._registers = {i: i for i in self._registers}
|
36
|
-
self._registers = self._registers | {
|
31
|
+
self._registers = self._registers | {
|
32
|
+
"sb": "r9",
|
33
|
+
"sl": "r10",
|
34
|
+
"fp": "r11",
|
35
|
+
"ip": "r12",
|
36
|
+
}
|
37
37
|
|
38
38
|
|
39
39
|
class ARMMachineMixinM:
|
@@ -43,15 +43,76 @@ class ARMMachineMixinM:
|
|
43
43
|
super().__init__()
|
44
44
|
self._registers_m = {
|
45
45
|
# NOTE: None of the expected privileged registers exist
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
"psr",
|
47
|
+
"primask",
|
48
|
+
"basepri",
|
49
|
+
"faultmask",
|
50
|
+
"control",
|
51
|
+
"msp",
|
52
|
+
"psp",
|
53
53
|
}
|
54
|
-
self._registers = self._registers | {i:
|
54
|
+
self._registers = self._registers | {i: None for i in self._registers_m}
|
55
|
+
|
56
|
+
|
57
|
+
class ARMMachineMixinFP:
|
58
|
+
def __init__(self):
|
59
|
+
super().__init__()
|
60
|
+
self._registers_fp = {
|
61
|
+
"fpscr",
|
62
|
+
"fpexc",
|
63
|
+
"fpsid",
|
64
|
+
"mvfr0",
|
65
|
+
"mvfr1",
|
66
|
+
"d0",
|
67
|
+
"s0",
|
68
|
+
"s1",
|
69
|
+
"d1",
|
70
|
+
"s2",
|
71
|
+
"s3",
|
72
|
+
"d2",
|
73
|
+
"s4",
|
74
|
+
"s5",
|
75
|
+
"d3",
|
76
|
+
"s6",
|
77
|
+
"s7",
|
78
|
+
"d4",
|
79
|
+
"s8",
|
80
|
+
"s9",
|
81
|
+
"d5",
|
82
|
+
"s10",
|
83
|
+
"s11",
|
84
|
+
"d6",
|
85
|
+
"s12",
|
86
|
+
"s13",
|
87
|
+
"d7",
|
88
|
+
"s14",
|
89
|
+
"s15",
|
90
|
+
"d8",
|
91
|
+
"s16",
|
92
|
+
"s17",
|
93
|
+
"d9",
|
94
|
+
"s18",
|
95
|
+
"s19",
|
96
|
+
"d10",
|
97
|
+
"s20",
|
98
|
+
"s21",
|
99
|
+
"d11",
|
100
|
+
"s22",
|
101
|
+
"s23",
|
102
|
+
"d12",
|
103
|
+
"s24",
|
104
|
+
"s25",
|
105
|
+
"d13",
|
106
|
+
"s26",
|
107
|
+
"s27",
|
108
|
+
"d14",
|
109
|
+
"s28",
|
110
|
+
"s29",
|
111
|
+
"d15",
|
112
|
+
"s30",
|
113
|
+
"s31",
|
114
|
+
}
|
115
|
+
self._registers = self._registers | {i: None for i in self._registers_fp}
|
55
116
|
|
56
117
|
|
57
118
|
class ARMMachineMixinA:
|
@@ -62,13 +123,148 @@ class ARMMachineMixinA:
|
|
62
123
|
# TODO: QEMU doesn't quite support what I expect.
|
63
124
|
# I expected to see cpsr and spsr.
|
64
125
|
# I either got the CPU model wrong, or something else is weird.
|
126
|
+
# (I strongly suspect Panda exposes the bitmasked aliases of cpsr)
|
65
127
|
self._registers_a = {
|
66
|
-
"
|
128
|
+
"cpsr": None,
|
129
|
+
"spsr": None,
|
130
|
+
"sp_usr": None,
|
131
|
+
"lr_usr": None,
|
132
|
+
"r8_usr": None,
|
133
|
+
"r9_usr": None,
|
134
|
+
"r10_usr": None,
|
135
|
+
"r11_usr": None,
|
136
|
+
"r12_usr": None,
|
137
|
+
"sp_hyp": None,
|
138
|
+
"spsr_hyp": None,
|
139
|
+
"elr_hyp": None,
|
140
|
+
"sp_svc": None,
|
141
|
+
"lr_svc": None,
|
142
|
+
"spsr_svc": None,
|
143
|
+
"sp_abt": None,
|
144
|
+
"lr_abt": None,
|
145
|
+
"spsr_abt": None,
|
146
|
+
"sp_und": None,
|
147
|
+
"lr_und": None,
|
148
|
+
"spsr_und": None,
|
149
|
+
"sp_mon": None,
|
150
|
+
"lr_mon": None,
|
151
|
+
"spsr_mon": None,
|
152
|
+
"sp_irq": None,
|
153
|
+
"lr_irq": None,
|
154
|
+
"spsr_irq": None,
|
155
|
+
"sp_fiq": None,
|
156
|
+
"lr_fiq": None,
|
157
|
+
"spsr_fiq": None,
|
158
|
+
"r8_fiq": None,
|
159
|
+
"r9_fiq": None,
|
160
|
+
"r10_fiq": None,
|
161
|
+
"r11_fiq": None,
|
162
|
+
"r12_fiq": None,
|
163
|
+
}
|
164
|
+
self._registers = self._registers | {k: v for k, v in self._registers_a.items()}
|
165
|
+
|
166
|
+
|
167
|
+
class ARMMachineMixinVFP:
|
168
|
+
def __init__(self):
|
169
|
+
super().__init__()
|
170
|
+
self._registers_vfp = {
|
171
|
+
# *** Floating-point Control Registers ***
|
172
|
+
# Floating-point Status and Control Register
|
173
|
+
"fpscr",
|
174
|
+
# Floating-point Exception Control Register
|
175
|
+
"fpexc",
|
176
|
+
# Floating-point System ID Register
|
177
|
+
"fpsid",
|
178
|
+
# Media and VFP Feature Register 0
|
179
|
+
"mvfr0",
|
180
|
+
# Media and VFP Feature Register 1
|
181
|
+
"mvfr1",
|
182
|
+
# *** Floating-point Registers ****
|
183
|
+
"q0",
|
184
|
+
"d0",
|
185
|
+
"s0",
|
186
|
+
"s1",
|
187
|
+
"d1",
|
188
|
+
"s2",
|
189
|
+
"s3",
|
190
|
+
"q1",
|
191
|
+
"d2",
|
192
|
+
"s4",
|
193
|
+
"s5",
|
194
|
+
"d3",
|
195
|
+
"s6",
|
196
|
+
"s7",
|
197
|
+
"q2",
|
198
|
+
"d4",
|
199
|
+
"s8",
|
200
|
+
"s9",
|
201
|
+
"d5",
|
202
|
+
"s10",
|
203
|
+
"s11",
|
204
|
+
"q3",
|
205
|
+
"d6",
|
206
|
+
"s12",
|
207
|
+
"s13",
|
208
|
+
"d7",
|
209
|
+
"s14",
|
210
|
+
"s15",
|
211
|
+
"q4",
|
212
|
+
"d8",
|
213
|
+
"s16",
|
214
|
+
"s17",
|
215
|
+
"d9",
|
216
|
+
"s18",
|
217
|
+
"s19",
|
218
|
+
"q5",
|
219
|
+
"d10",
|
220
|
+
"s20",
|
221
|
+
"s21",
|
222
|
+
"d11",
|
223
|
+
"s22",
|
224
|
+
"s23",
|
225
|
+
"q6",
|
226
|
+
"d12",
|
227
|
+
"s24",
|
228
|
+
"s25",
|
229
|
+
"d13",
|
230
|
+
"s26",
|
231
|
+
"s27",
|
232
|
+
"q7",
|
233
|
+
"d14",
|
234
|
+
"s28",
|
235
|
+
"s29",
|
236
|
+
"d15",
|
237
|
+
"s30",
|
238
|
+
"s31",
|
239
|
+
"q8",
|
240
|
+
"d16",
|
241
|
+
"d17",
|
242
|
+
"q9",
|
243
|
+
"d18",
|
244
|
+
"d19",
|
245
|
+
"q10",
|
246
|
+
"d20",
|
247
|
+
"d21",
|
248
|
+
"q11",
|
249
|
+
"d22",
|
250
|
+
"d23",
|
251
|
+
"q12",
|
252
|
+
"d24",
|
253
|
+
"d25",
|
254
|
+
"q13",
|
255
|
+
"d26",
|
256
|
+
"d27",
|
257
|
+
"q14",
|
258
|
+
"d28",
|
259
|
+
"d29",
|
260
|
+
"q15",
|
261
|
+
"d30",
|
262
|
+
"d31",
|
67
263
|
}
|
68
|
-
self._registers = self._registers | {i:
|
264
|
+
self._registers = self._registers | {i: None for i in self._registers_vfp}
|
69
265
|
|
70
266
|
|
71
|
-
class ARMv5TMachineDef(ARMMachineDef):
|
267
|
+
class ARMv5TMachineDef(ARMMachineMixinM, ARMMachineDef):
|
72
268
|
arch = Architecture.ARM_V5T
|
73
269
|
byteorder = Byteorder.LITTLE
|
74
270
|
cpu = "pxa255"
|
@@ -77,13 +273,13 @@ class ARMv5TMachineDef(ARMMachineDef):
|
|
77
273
|
# TODO: Something's very weird with Panda's Arm 7 models.
|
78
274
|
# cortex-a9 should be an A-series, but it looks more like an M-series.
|
79
275
|
# cortex-m4 looks like an M-series, but aborts; I suspect we're missing configuration.
|
80
|
-
class ARMv7AMachineDef(ARMMachineMixinA, ARMMachineDef):
|
276
|
+
class ARMv7AMachineDef(ARMMachineMixinVFP, ARMMachineMixinA, ARMMachineDef):
|
81
277
|
arch = Architecture.ARM_V7A
|
82
278
|
byteorder = Byteorder.LITTLE
|
83
279
|
cpu = "cortex-a9"
|
84
280
|
|
85
281
|
|
86
|
-
class ARMv7MMachineDef(ARMMachineMixinM, ARMMachineDef):
|
282
|
+
class ARMv7MMachineDef(ARMMachineMixinFP, ARMMachineMixinM, ARMMachineDef):
|
87
283
|
arch = Architecture.ARM_V7M
|
88
284
|
byteorder = Byteorder.LITTLE
|
89
285
|
cpu = "cortex-m4"
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import capstone
|
2
|
-
|
3
1
|
from ....platforms import Architecture, Byteorder
|
4
2
|
from .machdef import PandaMachineDef
|
5
3
|
|
@@ -10,26 +8,51 @@ class i386MachineDef(PandaMachineDef):
|
|
10
8
|
|
11
9
|
panda_arch = "i386"
|
12
10
|
|
13
|
-
cs_arch = capstone.CS_ARCH_X86
|
14
|
-
cs_mode = capstone.CS_MODE_32
|
15
|
-
|
16
11
|
# I'm going to define all the ones we are making possible as of now
|
17
12
|
# I need to submit a PR to change to X86 32 bit and to includ eflags
|
18
13
|
_registers_general = {"eax", "ebx", "ecx", "edx", "esi", "edi", "esp", "ebp", "eip"}
|
19
14
|
_registers_short = {"ax", "bx", "cx", "dx", "si", "di", "sp", "bp"}
|
20
15
|
_registers_byte = {"al", "bl", "cl", "dl", "ah", "bh", "ch", "dh"}
|
16
|
+
_registers_flags = {"eflags", "flags"}
|
21
17
|
_registers_seg = {"es", "cs", "ss", "ds", "fs", "gs"}
|
22
18
|
_registers_control = {"cr0", "cr1", "cr2", "cr3", "cr4"}
|
19
|
+
_registers_debug = {"dr0", "dr1", "dr2", "dr3", "dr6", "dr7"}
|
23
20
|
_registers_mmr = {"gdtr": "gdt", "idtr": "idt", "tr": "tr", "ldtr": "ldt"}
|
24
|
-
|
21
|
+
_registers_x87 = {
|
22
|
+
"fpr0",
|
23
|
+
"fpr1",
|
24
|
+
"fpr2",
|
25
|
+
"fpr3",
|
26
|
+
"fpr4",
|
27
|
+
"fpr5",
|
28
|
+
"fpr6",
|
29
|
+
"fpr7",
|
30
|
+
"fctrl",
|
31
|
+
"fstat",
|
32
|
+
"ftag",
|
33
|
+
"fip",
|
34
|
+
"fdp",
|
35
|
+
"fop",
|
36
|
+
}
|
37
|
+
_registers_mmx = {"mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"}
|
38
|
+
_registers_xmm = {"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"}
|
39
|
+
_registers_pc = {"pc": "eip", "ip": None}
|
40
|
+
_registers_absent = {"dil", "sil", "spl", "bpl", "cr8"}
|
25
41
|
|
26
42
|
_registers = {}
|
27
43
|
_registers = _registers | {i: i for i in _registers_general}
|
44
|
+
_registers = _registers | {i: i for i in _registers_short}
|
28
45
|
_registers = _registers | {i: i for i in _registers_byte}
|
46
|
+
_registers = _registers | {i: None for i in _registers_flags}
|
29
47
|
_registers = _registers | {i: i for i in _registers_seg}
|
30
48
|
_registers = _registers | {i: i for i in _registers_control}
|
49
|
+
_registers = _registers | {i: None for i in _registers_debug}
|
31
50
|
_registers = _registers | {i: j for i, j in _registers_mmr.items()}
|
32
|
-
_registers = _registers | {i:
|
51
|
+
_registers = _registers | {i: None for i in _registers_x87}
|
52
|
+
_registers = _registers | {i: None for i in _registers_mmx}
|
53
|
+
_registers = _registers | {i: None for i in _registers_xmm}
|
54
|
+
_registers = _registers | {i: j for i, j in _registers_pc.items()}
|
55
|
+
_registers = _registers | {i: None for i in _registers_absent}
|
33
56
|
# _registers = (
|
34
57
|
# _registers_general | _registers_byte | _registers_seg | _registers_control
|
35
58
|
# )
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import abc
|
2
2
|
import typing
|
3
3
|
|
4
|
-
from .... import platforms, utils
|
4
|
+
from .... import exceptions, platforms, utils
|
5
5
|
|
6
6
|
|
7
7
|
class PandaMachineDef(metaclass=abc.ABCMeta):
|
@@ -25,23 +25,16 @@ class PandaMachineDef(metaclass=abc.ABCMeta):
|
|
25
25
|
"""The panda architecture to use"""
|
26
26
|
raise NotImplementedError("This is an abstract method.")
|
27
27
|
|
28
|
-
|
29
|
-
@abc.abstractmethod
|
30
|
-
def cs_arch(self) -> int:
|
31
|
-
"""The capstone architecture to use"""
|
32
|
-
raise NotImplementedError("This is an abstract method.")
|
33
|
-
|
34
|
-
@property
|
35
|
-
@abc.abstractmethod
|
36
|
-
def cs_mode(self) -> int:
|
37
|
-
"""The capstone mode to use"""
|
38
|
-
raise NotImplementedError("This is an abstract method.")
|
39
|
-
|
40
|
-
_registers: typing.Dict[str, str] = {}
|
28
|
+
_registers: typing.Dict[str, typing.Optional[str]] = {}
|
41
29
|
|
42
30
|
def panda_reg(self, name: str) -> str:
|
43
31
|
if name in self._registers:
|
44
|
-
|
32
|
+
res = self._registers[name]
|
33
|
+
if res is None:
|
34
|
+
raise exceptions.UnsupportedRegisterError(
|
35
|
+
f"Register {name} not recognized by Panda for {self.arch}:{self.byteorder}"
|
36
|
+
)
|
37
|
+
return res
|
45
38
|
else:
|
46
39
|
raise ValueError(
|
47
40
|
f"Unknown register for {self.arch}:{self.byteorder}: {name}"
|
@@ -54,7 +47,7 @@ class PandaMachineDef(metaclass=abc.ABCMeta):
|
|
54
47
|
for this arch/mode/byteorder, or return 0,
|
55
48
|
which always indicates an invalid register
|
56
49
|
"""
|
57
|
-
if name in self._registers:
|
50
|
+
if name in self._registers and self._registers[name] is not None:
|
58
51
|
return True
|
59
52
|
else:
|
60
53
|
return False
|
@@ -1,12 +1,9 @@
|
|
1
|
-
import capstone
|
2
|
-
|
3
1
|
from ....platforms import Architecture, Byteorder
|
4
2
|
from .machdef import PandaMachineDef
|
5
3
|
|
6
4
|
|
7
5
|
class MIPSMachineDef(PandaMachineDef):
|
8
6
|
arch = Architecture.MIPS32
|
9
|
-
cs_arch = capstone.CS_ARCH_MIPS
|
10
7
|
cpu = "M14K"
|
11
8
|
|
12
9
|
# I'm going to define all the ones we are making possible as of now
|
@@ -79,16 +76,63 @@ class MIPSMachineDef(PandaMachineDef):
|
|
79
76
|
"ra": "ra",
|
80
77
|
"31": "ra",
|
81
78
|
"pc": "pc",
|
79
|
+
"f0": None,
|
80
|
+
"f1": None,
|
81
|
+
"f2": None,
|
82
|
+
"f3": None,
|
83
|
+
"f4": None,
|
84
|
+
"f5": None,
|
85
|
+
"f6": None,
|
86
|
+
"f7": None,
|
87
|
+
"f8": None,
|
88
|
+
"f9": None,
|
89
|
+
"f10": None,
|
90
|
+
"f11": None,
|
91
|
+
"f12": None,
|
92
|
+
"f13": None,
|
93
|
+
"f14": None,
|
94
|
+
"f15": None,
|
95
|
+
"f16": None,
|
96
|
+
"f17": None,
|
97
|
+
"f18": None,
|
98
|
+
"f19": None,
|
99
|
+
"f20": None,
|
100
|
+
"f21": None,
|
101
|
+
"f22": None,
|
102
|
+
"f23": None,
|
103
|
+
"f24": None,
|
104
|
+
"f25": None,
|
105
|
+
"f26": None,
|
106
|
+
"f27": None,
|
107
|
+
"f28": None,
|
108
|
+
"f29": None,
|
109
|
+
"f30": None,
|
110
|
+
"f31": None,
|
111
|
+
"fir": None,
|
112
|
+
"fcsr": None,
|
113
|
+
"fexr": None,
|
114
|
+
"fenr": None,
|
115
|
+
"fccr": None,
|
116
|
+
"ac0": None,
|
117
|
+
"lo0": None,
|
118
|
+
"hi0": None,
|
119
|
+
"ac1": None,
|
120
|
+
"lo1": None,
|
121
|
+
"hi1": None,
|
122
|
+
"ac2": None,
|
123
|
+
"lo2": None,
|
124
|
+
"hi2": None,
|
125
|
+
"ac3": None,
|
126
|
+
"lo3": None,
|
127
|
+
"hi3": None,
|
82
128
|
}
|
83
129
|
|
84
130
|
|
85
131
|
class MIPSELMachineDef(MIPSMachineDef):
|
86
132
|
panda_arch = "mipsel"
|
87
133
|
byteorder = Byteorder.LITTLE
|
88
|
-
cs_mode = capstone.CS_MODE_MIPS32 | capstone.CS_MODE_LITTLE_ENDIAN
|
89
134
|
|
90
135
|
|
91
136
|
class MIPSBEMachineDef(MIPSMachineDef):
|
92
137
|
panda_arch = "mips"
|
93
138
|
byteorder = Byteorder.BIG
|
94
|
-
cs_mode = capstone.CS_MODE_MIPS32 | capstone.CS_MODE_BIG_ENDIAN
|
@@ -1,15 +1,11 @@
|
|
1
|
-
import capstone
|
2
|
-
|
3
1
|
from ....platforms import Architecture, Byteorder
|
4
2
|
from .machdef import PandaMachineDef
|
5
3
|
|
6
4
|
|
7
5
|
class MIPS64MachineDef(PandaMachineDef):
|
8
6
|
arch = Architecture.MIPS64
|
9
|
-
cs_arch = capstone.CS_ARCH_MIPS
|
10
7
|
|
11
8
|
# We don't need this
|
12
|
-
panda_arch = "mips64"
|
13
9
|
|
14
10
|
# I'm going to define all the ones we are making possible as of now
|
15
11
|
# I need to submit a PR to change to X86 32 bit and to includ eflags
|
@@ -81,11 +77,67 @@ class MIPS64MachineDef(PandaMachineDef):
|
|
81
77
|
"ra": "ra",
|
82
78
|
"31": "ra",
|
83
79
|
"pc": "pc",
|
80
|
+
"f0": None,
|
81
|
+
"f1": None,
|
82
|
+
"f2": None,
|
83
|
+
"f3": None,
|
84
|
+
"f4": None,
|
85
|
+
"f5": None,
|
86
|
+
"f6": None,
|
87
|
+
"f7": None,
|
88
|
+
"f8": None,
|
89
|
+
"f9": None,
|
90
|
+
"f10": None,
|
91
|
+
"f11": None,
|
92
|
+
"f12": None,
|
93
|
+
"f13": None,
|
94
|
+
"f14": None,
|
95
|
+
"f15": None,
|
96
|
+
"f16": None,
|
97
|
+
"f17": None,
|
98
|
+
"f18": None,
|
99
|
+
"f19": None,
|
100
|
+
"f20": None,
|
101
|
+
"f21": None,
|
102
|
+
"f22": None,
|
103
|
+
"f23": None,
|
104
|
+
"f24": None,
|
105
|
+
"f25": None,
|
106
|
+
"f26": None,
|
107
|
+
"f27": None,
|
108
|
+
"f28": None,
|
109
|
+
"f29": None,
|
110
|
+
"f30": None,
|
111
|
+
"f31": None,
|
112
|
+
"fir": None,
|
113
|
+
"fcsr": None,
|
114
|
+
"fexr": None,
|
115
|
+
"fenr": None,
|
116
|
+
"fccr": None,
|
117
|
+
"ac0": None,
|
118
|
+
"lo0": None,
|
119
|
+
"hi0": None,
|
120
|
+
"ac1": None,
|
121
|
+
"lo1": None,
|
122
|
+
"hi1": None,
|
123
|
+
"ac2": None,
|
124
|
+
"lo2": None,
|
125
|
+
"hi2": None,
|
126
|
+
"ac3": None,
|
127
|
+
"lo3": None,
|
128
|
+
"hi3": None,
|
84
129
|
}
|
85
130
|
|
86
131
|
|
87
132
|
class MIPS64BEMachineDef(MIPS64MachineDef):
|
88
133
|
byteorder = Byteorder.BIG
|
134
|
+
panda_arch = "mips64"
|
135
|
+
machine = "malta"
|
136
|
+
cpu = "MIPS64R2-generic"
|
137
|
+
|
138
|
+
|
139
|
+
class MIPS64ELMachineDef(MIPS64MachineDef):
|
140
|
+
byteorder = Byteorder.LITTLE
|
141
|
+
panda_arch = "mips64el"
|
89
142
|
machine = "malta"
|
90
143
|
cpu = "MIPS64R2-generic"
|
91
|
-
cs_mode = capstone.CS_MODE_MIPS64 | capstone.CS_MODE_BIG_ENDIAN
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import capstone
|
2
|
-
|
3
1
|
from ....platforms import Architecture, Byteorder
|
4
2
|
from .machdef import PandaMachineDef
|
5
3
|
|
@@ -7,9 +5,6 @@ from .machdef import PandaMachineDef
|
|
7
5
|
class PowerPCMachineDef(PandaMachineDef):
|
8
6
|
byteorder = Byteorder.BIG
|
9
7
|
|
10
|
-
cs_arch = capstone.CS_ARCH_PPC
|
11
|
-
cs_mode = capstone.CS_MODE_32 | capstone.CS_MODE_BIG_ENDIAN
|
12
|
-
|
13
8
|
panda_arch = "ppc"
|
14
9
|
|
15
10
|
# I'm going to define all the ones we are making possible as of now
|
@@ -61,19 +56,49 @@ class PowerPCMachineDef(PandaMachineDef):
|
|
61
56
|
}
|
62
57
|
_registers_mapping = {
|
63
58
|
"r1": "sp",
|
59
|
+
"bp": "r31",
|
60
|
+
}
|
61
|
+
_registers_unsupported = {
|
62
|
+
"f0",
|
63
|
+
"f1",
|
64
|
+
"f2",
|
65
|
+
"f3",
|
66
|
+
"f4",
|
67
|
+
"f5",
|
68
|
+
"f6",
|
69
|
+
"f7",
|
70
|
+
"f8",
|
71
|
+
"f9",
|
72
|
+
"f10",
|
73
|
+
"f11",
|
74
|
+
"f12",
|
75
|
+
"f13",
|
76
|
+
"f14",
|
77
|
+
"f15",
|
78
|
+
"f16",
|
79
|
+
"f17",
|
80
|
+
"f18",
|
81
|
+
"f19",
|
82
|
+
"f20",
|
83
|
+
"f21",
|
84
|
+
"f22",
|
85
|
+
"f23",
|
86
|
+
"f24",
|
87
|
+
"f25",
|
88
|
+
"f26",
|
89
|
+
"f27",
|
90
|
+
"f28",
|
91
|
+
"f29",
|
92
|
+
"f30",
|
93
|
+
"f31",
|
94
|
+
"xer",
|
95
|
+
"fpscr",
|
64
96
|
}
|
65
97
|
_registers = {i: j for i, j in _registers_mapping.items()}
|
66
98
|
_registers = _registers | {i: i for i in _registers_identity}
|
99
|
+
_registers = _registers | {i: None for i in _registers_unsupported}
|
67
100
|
|
68
101
|
|
69
102
|
class PowerPC32MachineDef(PowerPCMachineDef):
|
70
103
|
arch = Architecture.POWERPC32
|
71
|
-
cs_mode = capstone.CS_MODE_32 | capstone.CS_MODE_BIG_ENDIAN
|
72
104
|
cpu = "ppc32"
|
73
|
-
|
74
|
-
|
75
|
-
# TODO: Do we have a panda PPC 64 bit cpu?
|
76
|
-
class PowerPC64MachineDef(PowerPCMachineDef):
|
77
|
-
arch = Architecture.POWERPC64
|
78
|
-
cs_mode = capstone.CS_MODE_64 | capstone.CS_MODE_BIG_ENDIAN
|
79
|
-
# cpu = "970"
|