summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-03-05 04:01:25 -0500
committerMalfurious <m@lfurio.us>2022-03-06 19:41:24 -0500
commit882231b1af6021b4a083533005ef13d191638acb (patch)
treeff2d1c1e8b9e6b9259134007fee066c8885398da /tools
parent979df27c374181e2c1da8899a1f436d9a4ae29c8 (diff)
downloadlib-des-gnux-882231b1af6021b4a083533005ef13d191638acb.tar.gz
lib-des-gnux-882231b1af6021b4a083533005ef13d191638acb.zip
sploit: Add ARM/THUMB architecture details
This _should_ be accurate for ARMv7-a at least (including thumb mode). We might want to later include ARMv8 details, which would primarily include a 64-bit profile - I just don't have the details at the moment. A namedtuple is now used as the implementation of type 'Arch', which allows the definitions to be much more compact and table-like, aiding readability. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/arch.py29
1 files changed, 8 insertions, 21 deletions
diff --git a/tools/sploit/sploit/arch.py b/tools/sploit/sploit/arch.py
index ce88111..f6d4789 100644
--- a/tools/sploit/sploit/arch.py
+++ b/tools/sploit/sploit/arch.py
@@ -1,28 +1,15 @@
+from collections import namedtuple as nt
+
def btoi(b, signed=False):
return int.from_bytes(b, arch.endianness, signed=signed)
def itob(i, signed=False):
return i.to_bytes(arch.wordsize, arch.endianness, signed=signed)
-class Arch:
- def __init__(self, wordsize, endianness, alignment, nopcode):
- self.wordsize = wordsize
- self.endianness = endianness
- self.alignment = alignment
- self.nopcode = nopcode
-
-archx86 = Arch(
- wordsize = 4,
- endianness = "little",
- alignment = 16,
- nopcode = b'\x90'
-)
-
-archx86_64 = Arch(
- wordsize = 8,
- endianness = "little",
- alignment = 16,
- nopcode = b'\x90'
-)
+Arch = nt("Arch", "wordsize endianness alignment nopcode")
+x86 = Arch( 4, 'little', 16, b'\x90')
+x86_64 = Arch( 8, 'little', 16, b'\x90')
+ARM = Arch( 4, 'little', 8, b'\xe1\xa0\x00\x00')
+THUMB = Arch( 4, 'little', 8, b'\x46\xc0')
-arch = archx86_64
+arch = x86_64