summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-07-06 23:30:49 -0400
committerMalfurious <m@lfurio.us>2022-09-12 20:18:55 -0400
commit98c491856cb4dcbbee2af41194aa22e1ce0515a3 (patch)
tree6381723e5a411dec4bb0a7cbc1519a80d649ccfc
parenta425bd4110a272cb889326a0b26cfb81cd67be8e (diff)
downloadsploit-98c491856cb4dcbbee2af41194aa22e1ce0515a3.tar.gz
sploit-98c491856cb4dcbbee2af41194aa22e1ce0515a3.zip
sploit: mem: Allow Symtbl base to be modified
Allow a Symtbl's base to be modified in-place, without mapping into a new object. This is useful when working with the Symtbl aspect of a Payload. This includes setting a non-zero base on construction. As usual, when defining base on construction, any additional kwargs symbols are interpreted relative to the given base. The order of arguments does not matter. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/mem.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/sploit/mem.py b/sploit/mem.py
index 3fee92f..9ae0575 100644
--- a/sploit/mem.py
+++ b/sploit/mem.py
@@ -1,8 +1,8 @@
import types
class Symtbl:
- def __init__(self, **kwargs):
- object.__setattr__(self, '_namesp', types.SimpleNamespace(base=0,sym={},sub={}))
+ def __init__(self, *, base=0, **kwargs):
+ object.__setattr__(self, '_namesp', types.SimpleNamespace(base=base,sym={},sub={}))
for k, v in {**kwargs}.items():
setattr(self, k, v)
@@ -15,11 +15,13 @@ class Symtbl:
def __setattr__(self, ident, value):
if ident in dir(self): raise Exception(f'Symtbl: assignment would shadow non-symbol "{ident}"')
- if ident == 'base': raise Exception('Symtbl: may not redefine symbol "base"')
self = self._namesp
- if type(value) is tuple: self.sub[ident], off = value
- else: off = value
- self.sym[ident] = off - self.base
+ if ident == 'base':
+ self.base = value
+ else:
+ if type(value) is tuple: self.sub[ident], off = value
+ else: off = value
+ self.sym[ident] = off - self.base
def map(self, addr, off=0):
self = self._namesp