mirror of https://github.com/pwndbg/pwndbg.git
adding simple r2 (radare) command with auto-seek to $pc (#188)
It's quite handy to drop into radare2 in the middle of a deep debugging session to fire up the visual mode and examine the current location in gdb using the ascii graph view (or something else) in radare2.pull/189/head
parent
bc1cfeaef4
commit
de352771c0
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
import pwndbg.commands
|
||||
|
||||
parser = argparse.ArgumentParser(description=".",
|
||||
epilog="Example: r2 -- -S -AA")
|
||||
parser.add_argument('--no-seek', action='store_true',
|
||||
help='Do not seek to current pc')
|
||||
parser.add_argument('arguments', nargs='*', type=str,
|
||||
help='Arguments to pass to radare')
|
||||
|
||||
@pwndbg.commands.ArgparsedCommand(parser)
|
||||
def r2(arguments, no_seek=False):
|
||||
filename = pwndbg.file.get_file(pwndbg.proc.exe)
|
||||
|
||||
if not filename:
|
||||
print('No file is selected')
|
||||
return
|
||||
|
||||
# Build up the command line to run
|
||||
cmd = ['radare2', filename]
|
||||
if not no_seek and pwndbg.proc.alive:
|
||||
cmd.extend(['-s', hex(pwndbg.regs.pc)])
|
||||
cmd += arguments
|
||||
|
||||
try:
|
||||
subprocess.call(cmd)
|
||||
except Exception:
|
||||
print("Could not run radare2. Please ensure it's installed and in $PATH.")
|
||||
Loading…
Reference in new issue