From 90d7c4ea1b303b25eaa233d75101e0e35d710e7f Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 19 Mar 2022 04:09:15 -0400 Subject: Add indirection to arch access Add a layer of indirection to access the active arch config. Currently when importing sploit.arch.arch, the name will be bound to whatever the current reference is and won't follow if another module (user script) updates the reference in sploit.arch. A layer of indirection seemlessly solves that issue and also provides a cleaner interface for setting the active arch from the user script. Signed-off-by: dusoleil --- tools/sploit/sploit/arch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/sploit/sploit/arch.py b/tools/sploit/sploit/arch.py index f6d4789..e5de2ce 100644 --- a/tools/sploit/sploit/arch.py +++ b/tools/sploit/sploit/arch.py @@ -12,4 +12,10 @@ x86_64 = Arch( 8, 'little', 16, b'\x90') ARM = Arch( 4, 'little', 8, b'\xe1\xa0\x00\x00') THUMB = Arch( 4, 'little', 8, b'\x46\xc0') -arch = x86_64 +class __ActiveArch__: + __arch = x86_64 + def __getattr__(self,k): + return getattr(self.__arch,k) + def set(self,a): + self.__arch = a +arch = __ActiveArch__() -- cgit v1.2.3