From f388499a625af89e56669a8c76c65da21a7c1b1a Mon Sep 17 00:00:00 2001 From: dusoleil Date: Thu, 23 Mar 2023 03:45:20 -0400 Subject: rev: Use json output for get_bin_info() Grabbing the json and returning that dict directly avoids all of the processing we were doing before. I also added in a small, temporary band-aid for PE files until we add actual support for them. The 'relro' key doesn't exist on PE files, so just default it to '' in ELF. Signed-off-by: dusoleil --- sploit/rev/elf.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'sploit/rev/elf.py') diff --git a/sploit/rev/elf.py b/sploit/rev/elf.py index 28cd08d..b1479d6 100644 --- a/sploit/rev/elf.py +++ b/sploit/rev/elf.py @@ -147,12 +147,12 @@ class ELF: # Fancy magic class that provides a psuedo-namespace to get properties of the binary def __init__(self, bininfo): self.info = { - "type" : bininfo.bintype, - "os" : bininfo.os, - "baddr" : int(bininfo.baddr,0), - "arch_string" : bininfo.arch, - "wordsize" : int(bininfo.bits)//8, - "endianness" : bininfo.endian, + "type" : bininfo['bintype'], + "os" : bininfo['os'], + "baddr" : bininfo['baddr'], + "arch_string" : bininfo['arch'], + "wordsize" : bininfo['bits']//8, + "endianness" : bininfo['endian'], } def __getattr__(self, k): return self.info[k] @@ -166,15 +166,14 @@ class ELF: class __SECINFO__(__BININFO__): # Fancy magic class that provides a psuedo-namespace to get security properties of the binary def __init__(self, bininfo): - bool = lambda s : s == 'true' or s == 'True' self.info = { - "stripped" : bool(bininfo.stripped), - "pic" : bool(bininfo.pic), - "relro" : bininfo.relro, - "relocs" : bool(bininfo.relocs), - "canary" : bool(bininfo.canary), - "nx" : bool(bininfo.nx), - "rpath" : bininfo.rpath, + "stripped" : bininfo['stripped'], + "pic" : bininfo['pic'], + "relro" : bininfo.get('relro',''), + "relocs" : bininfo['relocs'], + "canary" : bininfo['canary'], + "nx" : bininfo['nx'], + "rpath" : bininfo['rpath'], } def retaddr(self, caller, callee): -- cgit v1.2.3