From 198c658454eb88fc4805275da549ff67f2931cc2 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 5 Mar 2022 04:01:25 -0500 Subject: 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 --- sploit/arch.py | 29 ++++++++--------------------- 1 file 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 -- cgit v1.2.3