summaryrefslogtreecommitdiffstats
path: root/sploit/arch.py
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2023-03-13 05:40:15 -0400
committerdusoleil <howcansocksbereal@gmail.com>2023-03-13 18:28:35 -0400
commit6be0169515cc0cfc3bed4800c2276f0ed7237d97 (patch)
treeb7bcf7f002c2775bcc2aedd4b39f38b754459219 /sploit/arch.py
parentac7f4a52d61dca66d0ebc791c758430f291fed3a (diff)
downloadsploit-6be0169515cc0cfc3bed4800c2276f0ed7237d97.tar.gz
sploit-6be0169515cc0cfc3bed4800c2276f0ed7237d97.zip
arch: Add docstrings
Signed-off-by: dusoleil <howcansocksbereal@gmail.com> Reviewed-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'sploit/arch.py')
-rw-r--r--sploit/arch.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/sploit/arch.py b/sploit/arch.py
index 5575b05..ac8ac14 100644
--- a/sploit/arch.py
+++ b/sploit/arch.py
@@ -1,3 +1,24 @@
+"""
+Architecture-aware utilities and global architecture config
+
+It is common within sploit and for users of sploit to need different behavior
+depending on the architecture of the target. This module encapsulates those
+behaviors and bases them on a global architecture that is also configured here.
+
+Users can set the global arch with arch.set() and all of the methods in this
+module will honor it. An architecture can be defined through the Arch dataclass
+and there are also several predefined architecture constants that can be used.
+
+arch (Arch): the architecture config that sploit will use whenever it needs to
+know the architecture of the target
+
+predefined architectures:
+ x86
+ x86_64
+ ARM
+ THUMB
+"""
+
from dataclasses import dataclass
def btoi(b, signed=False):
@@ -8,11 +29,23 @@ def itob(i, signed=False):
@dataclass(frozen=True)
class Arch:
+ """
+ Dataclass of information about a target architecture
+
+ wordsize (int): the width, in bytes, of the natural unit of data
+ endianness (str): byte order. either "little" or "big"
+ alignment (int): the multiple, in bytes, that return addresses must exist
+ on the stack
+ nopcode (bytes): the exact bytes of a "do nothing" instruction
+ """
+
wordsize: int
endianness: str
alignment: int
nopcode: bytes
+
def set(self,k):
+ """Copy the given Arch into this instance."""
self.__dict__.update(k.__dict__)
x86 = Arch( 4, 'little', 16, b'\x90')