summaryrefslogtreecommitdiffstats
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
commit198c658454eb88fc4805275da549ff67f2931cc2 (patch)
tree6e03eb02046cc667774e2f6e49381d7dbbe099a6
parent93d36981b1ea0494e3aeb344ce2b4e43ca55991c (diff)
downloadsploit-198c658454eb88fc4805275da549ff67f2931cc2.tar.gz
sploit-198c658454eb88fc4805275da549ff67f2931cc2.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>
-rw-r--r--sploit/arch.py29
1 files changed, 8 insertions, 21 deletions
diff --git a/sploit/arch.py b/sploit/arch.py
index ce88111..f6d4789 100644
--- a/sploit/arch.py
+++ b/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