Hack for supporting both rizin and radare2

Provides support for both Rizin and radare2 without needing another ghidra file.
pull/1578/head
Maria 3 years ago committed by Gulshan Singh
parent fd14aa0e55
commit 84120d161b

@ -633,8 +633,8 @@ def load_commands() -> None:
import pwndbg.commands.probeleak
import pwndbg.commands.procinfo
import pwndbg.commands.radare2
import pwndbg.commands.rizin
import pwndbg.commands.reload
import pwndbg.commands.rizin
import pwndbg.commands.rop
import pwndbg.commands.ropper
import pwndbg.commands.search

@ -16,9 +16,7 @@ parser.add_argument(
parser.add_argument("arguments", nargs="*", type=str, help="Arguments to pass to rizin")
@pwndbg.commands.ArgparsedCommand(
parser, aliases=["rizin"], category=CommandCategory.INTEGRATIONS
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["rizin"], category=CommandCategory.INTEGRATIONS)
@pwndbg.commands.OnlyWithFile
def rz(arguments, no_seek=False, no_rebase=False) -> None:
filename = pwndbg.gdblib.file.get_file(pwndbg.gdblib.proc.exe)

@ -6,6 +6,7 @@ import pwndbg.color.context as C
import pwndbg.color.syntax_highlight as H
import pwndbg.gdblib.regs
import pwndbg.radare2
import pwndbg.rizin
def decompile(func=None):
@ -13,19 +14,24 @@ def decompile(func=None):
Return the source of the given function decompiled by ghidra.
If no function is given, decompile the function within the current pc.
This function requires radare2, r2pipe and r2ghidra.
This function requires radare2, r2pipe and r2ghidra, or their related rizin counterparts.
Raises Exception if any fatal error occurs.
"""
try:
r2 = pwndbg.radare2.r2pipe()
except ImportError:
raise Exception("r2pipe not available, but required for r2->ghidra bridge")
try:
r2 = pwndbg.rizin.rzpipe()
except ImportError:
raise Exception("r2pipe or rzpipe not available, but required for r2/rz->ghidra bridge")
# LD -> list supported decompilers (e cmd.pdc=?)
# Outputs for example: pdc\npdg
if "pdg" not in r2.cmd("LD").split("\n"):
raise Exception("radare2 plugin r2ghidra must be installed and available from r2")
raise Exception(
"radare2/rizin plugin r2ghidra/rzghidra must be installed and available from r2/rz"
)
if not func:
func = (

Loading…
Cancel
Save