summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2021-09-02 00:03:59 -0400
committerdusoleil <howcansocksbereal@gmail.com>2021-09-02 00:03:59 -0400
commitab6bcf9c5c8e8c7490d6b70141c4b2c864f15752 (patch)
treed777dca646bf87de7334397faca26904a247dfcc
parentd78a5ad4bd97dde7cb87084580ade729ebdece7d (diff)
downloadlib-des-gnux-ab6bcf9c5c8e8c7490d6b70141c4b2c864f15752.tar.gz
lib-des-gnux-ab6bcf9c5c8e8c7490d6b70141c4b2c864f15752.zip
Add arch config module
Add Arch class which specifies wordsize, endianness, alignment, and a nop code for an architecture. Add a couple predefined architectures for x86 and x86_64 Add a "configured" architecture which is set to x86_64 by default. Added btoi and itob functions which will convert to and from bytes and ints based on the current architecture config Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--tools/sploit/sploit/__init__.py2
-rw-r--r--tools/sploit/sploit/arch.py28
2 files changed, 29 insertions, 1 deletions
diff --git a/tools/sploit/sploit/__init__.py b/tools/sploit/sploit/__init__.py
index c90b980..d9ea6b0 100644
--- a/tools/sploit/sploit/__init__.py
+++ b/tools/sploit/sploit/__init__.py
@@ -1 +1 @@
-__all__ = ["log","comm","until"]
+__all__ = ["log","comm","until","arch"]
diff --git a/tools/sploit/sploit/arch.py b/tools/sploit/sploit/arch.py
new file mode 100644
index 0000000..d75bbda
--- /dev/null
+++ b/tools/sploit/sploit/arch.py
@@ -0,0 +1,28 @@
+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, nop):
+ self.wordsize = wordsize
+ self.endianness = endianness
+ self.alignment = alignment
+ self.nop = nop
+
+archx86 = Arch(
+ wordsize = 4,
+ endianness = "little",
+ alignment = 16,
+ nop = b'\x90'
+)
+
+archx86_64 = Arch(
+ wordsize = 8,
+ endianness = "little",
+ alignment = 16,
+ nop = b'\x90'
+)
+
+arch = archx86_64