diff options
author | Malfurious <m@lfurio.us> | 2022-07-06 23:30:49 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2022-09-12 20:18:55 -0400 |
commit | 81f8130fa479fd827bc84354ee9a72b80c9cde02 (patch) | |
tree | 840841c5b25f6ac3e7db7e540a91f0bb5f8a709d | |
parent | 94efc98b3d75d5520189c2d105541cd09aa3cff7 (diff) | |
download | lib-des-gnux-81f8130fa479fd827bc84354ee9a72b80c9cde02.tar.gz lib-des-gnux-81f8130fa479fd827bc84354ee9a72b80c9cde02.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-- | tools/sploit/sploit/mem.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py index 3fee92f..9ae0575 100644 --- a/tools/sploit/sploit/mem.py +++ b/tools/sploit/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 |