summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2023-03-16 18:37:37 -0400
committerdusoleil <howcansocksbereal@gmail.com>2023-03-16 18:37:37 -0400
commit6e2d648cd7ffa7866a511bd27ba60188909d79cb (patch)
tree0e273eb82ea0dd45895f8e6342a3d7860c8dc974
parent461792086df23db605e941cddf78cfefe128f855 (diff)
downloadsploit-6e2d648cd7ffa7866a511bd27ba60188909d79cb.tar.gz
sploit-6e2d648cd7ffa7866a511bd27ba60188909d79cb.zip
r2: Add ability to lookup info about a binary.
Call r2's iI command and return a subset of the fields that we care about. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/rev/r2.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/sploit/rev/r2.py b/sploit/rev/r2.py
index b9df8ad..bd4133e 100644
--- a/sploit/rev/r2.py
+++ b/sploit/rev/r2.py
@@ -127,3 +127,15 @@ def get_call_returns(binary,xref_from,xref_to):
ret = run_cmd(binary,cmd_ret)
rets.append(CallRet(xref_from,xref_to,int(x[0],0),int(ret[0],0)))
return rets
+
+def get_bin_info(binary):
+ ilog(f'Retrieving binary and security info about {binary} with r2...')
+
+ BinInfo = nt("BinInfo", "bintype os arch bits endian baddr canary nx pic relocs relro rpath stripped")
+ cmd_info = 'iI'
+ info = run_cmd(binary, cmd_info)
+ info = [re.split(r'\s+',i,1) for i in info]
+ info = {i[0]:i[1] for i in info}
+ info = [info[f] for f in BinInfo._fields]
+ ret = BinInfo(*info)
+ return ret