refactor: better logs/ output to parse

This commit is contained in:
Dobin
2024-02-17 14:19:32 +00:00
parent b4ec9031cb
commit c63e16ffab
6 changed files with 23 additions and 16 deletions
+4 -3
View File
@@ -14,19 +14,20 @@ def r2_disas(data: bytes):
ret["hexdump"] = hexdump(data)
# fucking r2 cant handle shellcode when not in files...
# r2 cant really handle shellcode when not in files...
with open(filename, "wb") as f:
f.write(data)
code_len = len(data)
r2 = r2pipe.open(filename)
r2.cmd('aaa')
r2.cmd('e scr.color=0')
ret['text'] = r2.cmd('pd')
ret['text'] = r2.cmd('pD {}'.format(code_len))
ret['text'] = '\n'.join(ret['text'].splitlines()) # fix newlines
r2.cmd('e scr.color=2')
ret['color'] = r2.cmd('pd')
ret['color'] = r2.cmd('pD {}'.format(code_len))
ret['color'] = '\n'.join(ret['color'].splitlines()) # fix newlines
r2.quit()