summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sploit/arch.py14
-rw-r--r--sploit/payload.py4
2 files changed, 12 insertions, 6 deletions
diff --git a/sploit/arch.py b/sploit/arch.py
index 36f48a4..5933a95 100644
--- a/sploit/arch.py
+++ b/sploit/arch.py
@@ -100,8 +100,14 @@ def uint64(i):
"""Convert given int to unsigned 64 bit int."""
return __int(i, False, 8)
-def btoi(b, signed=False):
- return int.from_bytes(b, arch.endianness, signed=signed)
+def btoi(b, byteorder=None):
+ """Convert given byte array to an int."""
+ byteorder = byteorder or arch.endianness
+ return int.from_bytes(b, byteorder, signed=False)
+
+def itob(i, width=None, byteorder=None):
+ """Convert given int to a byte array."""
+ width = width or arch.wordsize
+ byteorder = byteorder or arch.endianness
+ return __int(i,False,width).to_bytes(width, byteorder, signed=False)
-def itob(i, signed=False):
- return i.to_bytes(arch.wordsize, arch.endianness, signed=signed)
diff --git a/sploit/payload.py b/sploit/payload.py
index 1775ceb..1ece105 100644
--- a/sploit/payload.py
+++ b/sploit/payload.py
@@ -43,8 +43,8 @@ class Payload:
values = [ v.encode() + b'\x00' for v in values ]
return self.bin(*values, sym=self._name('str', sym))
- def int(self, *values, sym=None, signed=False):
- values = [ itob(v, signed=signed) for v in values ]
+ def int(self, *values, sym=None):
+ values = [ itob(v) for v in values ]
return self.bin(*values, sym=self._name('int', sym))
def ret(self, *values, sym=None):