mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-24 22:08:40 +08:00
Merge branch 'GP-5619_emteere_VariousSpeedImprovements_VERSION2'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-kernel
|
||||
::@title dbgeng kernel
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Kernel debugging using <tt>dbgeng</tt> (in a Python interpreter)</h3>
|
||||
::@desc <p>
|
||||
@@ -6,7 +6,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#win_kernel
|
||||
::@enum Connection:str Remote Local EXDI
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-attach
|
||||
::@title dbgeng attach
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Attach with <tt>dbgeng</tt> (in a Python interpreter)</h3>
|
||||
::@desc <p>
|
||||
@@ -6,7 +6,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#attach
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-ext
|
||||
::@title dbgeng extra options
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with <tt>dbgeng</tt> (in a Python interpreter)</h3>
|
||||
@@ -7,7 +7,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#ext
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-trace
|
||||
::@title dbgeng TTD
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Open trace with <tt>dbgeng</tt> (in a Python interpreter)</h3>
|
||||
::@desc <p>
|
||||
@@ -6,7 +6,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#ttd
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#local
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-remote
|
||||
::@title dbgeng remote
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Connect to a remote debugger (via the .server interface)</h3>
|
||||
::@desc <p>
|
||||
@@ -6,7 +6,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#remote
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
::@title dbgeng-svrcx
|
||||
::@title dbgeng svrcx
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Connect to a remote <tt>dbgeng</tt> connection server and launch the target (in a Python interpreter)</h3>
|
||||
@@ -7,7 +7,7 @@
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@menu-group dbgeng
|
||||
::@icon icon.debugger
|
||||
::@help dbgeng#svrcx
|
||||
::@env OPT_PYTHON_EXE:file!="python" "Python command" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@@ -17,25 +17,16 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from ghidradbg import util
|
||||
@@ -59,20 +50,25 @@ def main():
|
||||
flags = 2
|
||||
args = os.getenv('OPT_KCONNECT_STRING')
|
||||
cmd.ghidra_trace_attach_kernel(args, flags, start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
except KeyboardInterrupt as ki:
|
||||
dbg.interrupt()
|
||||
|
||||
#cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
|
||||
# cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
|
||||
cmd.ghidra_trace_start("System")
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -18,25 +18,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -51,7 +41,7 @@ def main():
|
||||
flags = os.getenv('OPT_ATTACH_FLAGS')
|
||||
cmd.ghidra_trace_attach(
|
||||
os.getenv('OPT_TARGET_PID'), flags, start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
@@ -60,10 +50,15 @@ def main():
|
||||
|
||||
cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -18,25 +18,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -56,17 +46,17 @@ def main():
|
||||
print("dbgeng requires a target image - please try again.")
|
||||
cmd.ghidra_trace_disconnect()
|
||||
return
|
||||
|
||||
|
||||
cmd.ghidra_trace_create_ext(
|
||||
target + args,
|
||||
target + args,
|
||||
os.getenv('OPT_TARGET_DIR'),
|
||||
os.getenv('OPT_TARGET_ENV'),
|
||||
os.getenv('OPT_CREATE_FLAGS'),
|
||||
os.getenv('OPT_CREATE_ENGFLAGS'),
|
||||
os.getenv('OPT_VERIFIER_FLAGS'),
|
||||
os.getenv('OPT_ENG_OPTIONS'),
|
||||
os.getenv('OPT_VERIFIER_FLAGS'),
|
||||
os.getenv('OPT_ENG_OPTIONS'),
|
||||
start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
@@ -75,10 +65,15 @@ def main():
|
||||
|
||||
cmd.ghidra_trace_start(target)
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -18,25 +18,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -73,4 +63,8 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -18,25 +18,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -56,9 +46,9 @@ def main():
|
||||
print("dbgeng requires a target image - please try again.")
|
||||
cmd.ghidra_trace_disconnect()
|
||||
return
|
||||
|
||||
|
||||
cmd.ghidra_trace_create(target + args, start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
@@ -67,10 +57,15 @@ def main():
|
||||
|
||||
cmd.ghidra_trace_start(target)
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -18,25 +18,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -53,10 +43,15 @@ def main():
|
||||
cmd.ghidra_trace_start("Remote")
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
dbg.interrupt()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -20,25 +20,15 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -60,9 +50,9 @@ def main():
|
||||
print("dbgeng requires a target image - please try again.")
|
||||
cmd.ghidra_trace_disconnect()
|
||||
return
|
||||
|
||||
|
||||
cmd.ghidra_trace_create(target + args, start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
@@ -71,10 +61,15 @@ def main():
|
||||
|
||||
cmd.ghidra_trace_start(target)
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -1,42 +1,32 @@
|
||||
## ###
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
|
||||
if os.path.isdir(f'{home}\\ghidra\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\ghidra\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
elif os.path.isdir(f'{home}\\.git'):
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\build\\pypkg\\src')
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\build\\pypkg\\src')
|
||||
else:
|
||||
sys.path.append(
|
||||
f'{home}\\Ghidra\\Debug\\Debugger-agent-dbgeng\\pypkg\\src')
|
||||
sys.path.append(f'{home}\\Ghidra\\Debug\\Debugger-rmi-trace\\pypkg\\src')
|
||||
def append_paths():
|
||||
sys.path.append("../../../Debugger-rmi-trace/data/support")
|
||||
from gmodutils import ghidra_module_pypath
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-rmi-trace"))
|
||||
sys.path.append(ghidra_module_pypath("Debug/Debugger-agent-dbgeng"))
|
||||
|
||||
|
||||
def main():
|
||||
append_paths()
|
||||
# Delay these imports until sys.path is patched
|
||||
from ghidradbg import commands as cmd
|
||||
from pybag.dbgeng import core as DbgEng
|
||||
@@ -55,7 +45,7 @@ def main():
|
||||
img = os.getenv('OPT_TARGET_IMG')
|
||||
if img is not None and img != "":
|
||||
cmd.ghidra_trace_create(img + args, start_trace=False)
|
||||
|
||||
|
||||
# TODO: HACK
|
||||
try:
|
||||
dbg.wait()
|
||||
@@ -64,10 +54,15 @@ def main():
|
||||
|
||||
cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
|
||||
cmd.ghidra_trace_sync_enable()
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)
|
||||
|
||||
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS,
|
||||
DbgEng.DEBUG_STATUS_BREAK)
|
||||
cmd.repl()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except SystemExit as x:
|
||||
if x.code != 0:
|
||||
print(f"Exited with code {x.code}")
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
# limitations under the License.
|
||||
##
|
||||
|
||||
# NOTE: libraries must precede EVERYTHING, esp pybag and DbgMod
|
||||
try:
|
||||
import pybag
|
||||
except Exception as e:
|
||||
from ghidratrace.setuputils import prompt_and_mitigate_dependencies
|
||||
prompt_and_mitigate_dependencies("Debug/Debugger-agent-dbgeng")
|
||||
|
||||
# NOTE: libraries must precede EVERYTHING, esp pybag and DbgMod
|
||||
from . import libraries, util, commands, methods, hooks
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title drgn-core
|
||||
#@title drgn core
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>drgn-core</tt></h3>
|
||||
#@desc <p>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title drgn-kernel
|
||||
#@title drgn kernel
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>drgn-kernel</tt></h3>
|
||||
#@desc <p>
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
##MODULE IP: JSch License
|
||||
Module.manifest||GHIDRA||||END|
|
||||
README.md||GHIDRA||||END|
|
||||
data/debugger-launchers/local-gdb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/qemu-sys-gdb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/local-gdb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/qemu-sys-gdb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/remote-gdb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-gdb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-gdbserver.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-gdb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-gdbserver.ps1||GHIDRA||||END|
|
||||
data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END|
|
||||
data/scripts/fallback_maintenance_info_sections.gdb||GHIDRA||||END|
|
||||
data/scripts/getpid-linux-i386.gdb||GHIDRA||||END|
|
||||
data/scripts/wine32_info_proc_mappings.gdb||GHIDRA||||END|
|
||||
data/support/gdbsetuputils.ps1||GHIDRA||||END|
|
||||
src/main/help/help/TOC_Source.xml||GHIDRA||||END|
|
||||
src/main/help/help/topics/gdb/gdb.html||GHIDRA||||END|
|
||||
src/main/help/help/topics/gdb/images/GdbLauncher.png||GHIDRA||||END|
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
::@title gdb
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with <tt>gdb</tt></h3>
|
||||
::@desc <p>
|
||||
::@desc This will launch the target on the local machine using <tt>gdb</tt>.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@icon icon.debugger
|
||||
::@help gdb#local
|
||||
::@enum StartCmd:str run start starti
|
||||
::@enum Endian:str auto big little
|
||||
::@env OPT_TARGET_IMG:file="" "Image" "The target binary executable image"
|
||||
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
::@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_START_CMD:StartCmd="starti" "Run command" "The gdb command to actually run the target."
|
||||
::@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
::@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
:: NB: This works - a lot of things do not. Don't change unless you know what you're doing!
|
||||
set OPT_TARGET_ARGS=%OPT_TARGET_ARGS:"=\"%
|
||||
set OPT_TARGET_ARGS=%OPT_TARGET_ARGS:)=^)%
|
||||
:: NB: This seems stupid, but there doesn't seem to be a logical way to test before the previous lines
|
||||
if %OPT_TARGET_ARGS%=="=\" (
|
||||
set OPT_TARGET_ARGS=\"\"
|
||||
)
|
||||
|
||||
IF "%OPT_TARGET_IMG%"=="" (
|
||||
"%OPT_GDB_PATH%" ^
|
||||
-q ^
|
||||
-ex "set pagination off" ^
|
||||
-ex "set confirm off" ^
|
||||
-ex "show version" ^
|
||||
-ex "python import ghidragdb" ^
|
||||
-ex "set architecture %OPT_ARCH%" ^
|
||||
-ex "set endian %OPT_ENDIAN%" ^
|
||||
-ex "ghidra trace connect '%GHIDRA_TRACE_RMI_ADDR%'" ^
|
||||
-ex "ghidra trace start" ^
|
||||
-ex "ghidra trace sync-enable" ^
|
||||
-ex "set confirm on" ^
|
||||
-ex "set pagination on"
|
||||
) ELSE (
|
||||
"%OPT_GDB_PATH%" ^
|
||||
-q ^
|
||||
-ex "set pagination off" ^
|
||||
-ex "set confirm off" ^
|
||||
-ex "show version" ^
|
||||
-ex "python import ghidragdb" ^
|
||||
-ex "set architecture %OPT_ARCH%" ^
|
||||
-ex "set endian %OPT_ENDIAN%" ^
|
||||
-ex "target exec %OPT_TARGET_IMG%" ^
|
||||
-ex "set args %OPT_TARGET_ARGS%" ^
|
||||
-ex "ghidra trace connect '%GHIDRA_TRACE_RMI_ADDR%'" ^
|
||||
-ex "ghidra trace start" ^
|
||||
-ex "ghidra trace sync-enable" ^
|
||||
-ex "%OPT_START_CMD%" ^
|
||||
-ex "set confirm on" ^
|
||||
-ex "set pagination on"
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
#@title gdb
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>gdb</tt></h3>
|
||||
#@desc <p>
|
||||
#@desc This will launch the target on the local machine using <tt>gdb</tt>.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#local
|
||||
#@enum StartCmd:str run start starti
|
||||
#@enum Endian:str auto big little
|
||||
#@arg :file "Image" "The target binary executable image"
|
||||
#@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
#@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="starti" "Run command" "The gdb command to actually run the target."
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
. ..\support\gdbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathGdb = Ghidra-Module-PyPath "Debug/Debugger-agent-gdb"
|
||||
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = Compute-Gdb-Usermode-Args `
|
||||
-TargetImage $args[0] `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] `
|
||||
-NoNewWindow -Wait
|
||||
@@ -23,7 +23,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group local
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#local
|
||||
#@enum StartCmd:str run start starti
|
||||
@@ -37,57 +37,19 @@
|
||||
#@env OPT_EXTRA_TTY:bool=false "Inferior TTY" "Provide a separate terminal emulator for the target."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
target_args="$@"
|
||||
|
||||
# Ghidra will leave TTY_TARGET empty when OPT_EXTRA_TTY is false. Gdb takes empty to mean the same terminal.
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-usermode-args "$target_image" "$GHIDRA_TRACE_RMI_ADDR" "$@"
|
||||
|
||||
if [ -z "$target_image" ]
|
||||
then
|
||||
"$OPT_GDB_PATH" \
|
||||
-q \
|
||||
-ex "set pagination off" \
|
||||
-ex "set confirm off" \
|
||||
-ex "show version" \
|
||||
-ex "python import ghidragdb" \
|
||||
-ex "set architecture $OPT_ARCH" \
|
||||
-ex "set endian $OPT_ENDIAN" \
|
||||
-ex "set inferior-tty $TTY_TARGET" \
|
||||
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-ex "ghidra trace start" \
|
||||
-ex "ghidra trace sync-enable" \
|
||||
-ex "set confirm on" \
|
||||
-ex "set pagination on"
|
||||
else
|
||||
"$OPT_GDB_PATH" \
|
||||
-q \
|
||||
-ex "set pagination off" \
|
||||
-ex "set confirm off" \
|
||||
-ex "show version" \
|
||||
-ex "python import ghidragdb" \
|
||||
-ex "set architecture $OPT_ARCH" \
|
||||
-ex "set endian $OPT_ENDIAN" \
|
||||
-ex "file \"$target_image\"" \
|
||||
-ex "set args $target_args" \
|
||||
-ex "set inferior-tty $TTY_TARGET" \
|
||||
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-ex "ghidra trace start" \
|
||||
-ex "ghidra trace sync-enable" \
|
||||
-ex "$OPT_START_CMD" \
|
||||
-ex "set confirm on" \
|
||||
-ex "set pagination on"
|
||||
fi
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group local
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#rr
|
||||
#@enum StartCmd:str run start starti
|
||||
@@ -34,20 +34,13 @@
|
||||
#@env OPT_EXTRA_TTY:bool=false "Inferior TTY" "Provide a separate terminal emulator for the target."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
target_image="$1"
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_trace="$1"
|
||||
|
||||
# Ghidra will leave TTY_TARGET empty when OPT_EXTRA_TTY is false. Gdb takes empty to mean the same terminal.
|
||||
|
||||
@@ -68,5 +61,5 @@ set confirm on
|
||||
set pagination on
|
||||
' > $RRINIT
|
||||
|
||||
"$OPT_RR_PATH" replay -x $RRINIT "$target_image"
|
||||
"$OPT_RR_PATH" replay -x $RRINIT "$target_trace"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title qemu + gdb
|
||||
#@title gdb + qemu
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>qemu</tt> and connect with <tt>gdb</tt></h3>
|
||||
@@ -24,7 +24,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group cross
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#qemu
|
||||
#@enum Endian:str auto big little
|
||||
@@ -40,53 +40,33 @@
|
||||
#@env OPT_PULL_ALL_SECTIONS:bool=false "Pull all section mappings" "Force gdb to send all mappings to Ghidra. This can be costly (see help)."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
|
||||
# No need to put QEMU_GDB on command line. It's already a recognized environment variable.
|
||||
if [ -z "$TTY_TARGET" ]
|
||||
then
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu" $OPT_EXTRA_QEMU_ARGS $@ &
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu" $OPT_EXTRA_QEMU_ARGS "$@" &
|
||||
else
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu" $OPT_EXTRA_QEMU_ARGS $@ <$TTY_TARGET >$TTY_TARGET 2>&1 &
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu" $OPT_EXTRA_QEMU_ARGS "$@" <$TTY_TARGET >$TTY_TARGET 2>&1 &
|
||||
fi
|
||||
|
||||
# Give QEMU a moment to open the socket
|
||||
sleep 0.1
|
||||
|
||||
declare -a args
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-remote-args "$target_image" "remote localhost:$QEMU_GDB" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]; then
|
||||
args+=(-ex "ghidra trace tx-open 'Put Sections' 'ghidra trace put-sections -all-objects'")
|
||||
fi
|
||||
|
||||
args+=(-q)
|
||||
args+=(-ex "set pagination off")
|
||||
args+=(-ex "set confirm off")
|
||||
args+=(-ex "show version")
|
||||
args+=(-ex "python import ghidragdb")
|
||||
args+=(-ex "set architecture $OPT_ARCH")
|
||||
args+=(-ex "set endian $OPT_ENDIAN")
|
||||
args+=(-ex "file '$target_image'")
|
||||
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
|
||||
args+=(-ex "ghidra trace start")
|
||||
args+=(-ex "ghidra trace sync-enable")
|
||||
args+=(-ex "target remote localhost:$QEMU_GDB")
|
||||
if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]
|
||||
then
|
||||
args+=(-ex "ghidra trace tx-start put-all-sections")
|
||||
args+=(-ex "ghidra trace put-sections -all-objects")
|
||||
args+=(-ex "ghidra trace tx-commit")
|
||||
fi
|
||||
args+=(-ex "set confirm on")
|
||||
args+=(-ex "set pagination on")
|
||||
|
||||
"$OPT_GDB_PATH" "${args[@]}"
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
::@title qemu-system + gdb
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with <tt>qemu-system</tt> and connect with <tt>gdb</tt></h3>
|
||||
::@desc <p>
|
||||
::@desc This will launch the target on the local machine using <tt>qemu-system</tt>.
|
||||
::@desc Then in a second terminal, it will connect <tt>gdb</tt> to QEMU's GDBstub.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group cross
|
||||
::@icon icon.debugger
|
||||
::@help gdb#qemu
|
||||
::@enum Endian:str auto big little
|
||||
::@env OPT_TARGET_IMG:file!="" "Image" "The target binary executable image"
|
||||
::@env GHIDRA_LANG_EXTTOOL_qemu_system:file="" "QEMU command" "The path to qemu-system for the target architecture."
|
||||
::@env QEMU_GDB:int=1234 "QEMU Port" "Port for gdb connection to qemu"
|
||||
::@env OPT_EXTRA_QEMU_ARGS:str="" "Extra qemu arguments" "Extra arguments to pass to qemu. Use with care."
|
||||
::@env OPT_GDB_PATH:file="gdb-multiarch" "gdb command" "The path to gdb. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
::@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
::@env OPT_EXTRA_TTY:bool=false "QEMU TTY" "Provide a separate terminal emulator for qemu."
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
IF "%OPT_EXTRA_TTY%"=="true" (
|
||||
start "qemu" "%GHIDRA_LANG_EXTTOOL_qemu_system%" %OPT_EXTRA_QEMU_ARGS% -gdb tcp::%QEMU_GDB% -S "%OPT_TARGET_IMG%"
|
||||
) ELSE (
|
||||
start /B "qemu" "%GHIDRA_LANG_EXTTOOL_qemu_system%" %OPT_EXTRA_QEMU_ARGS% -gdb tcp::%QEMU_GDB% -S "%OPT_TARGET_IMG%"
|
||||
)
|
||||
|
||||
:: Give QEMU a moment to open the socket
|
||||
powershell -nop -c "& {sleep -m 100}"
|
||||
|
||||
"%OPT_GDB_PATH%" ^
|
||||
-q ^
|
||||
-ex "set pagination off" ^
|
||||
-ex "set confirm off" ^
|
||||
-ex "show version" ^
|
||||
-ex "python import ghidragdb" ^
|
||||
ex "set architecture %OPT_ARCH%" ^
|
||||
ex "set endian %OPT_ENDIAN%" ^
|
||||
-ex "target exec '%OPT_TARGET_IMG%'" ^
|
||||
-ex "ghidra trace connect '%GHIDRA_TRACE_RMI_ADDR%'" ^
|
||||
-ex "ghidra trace start" ^
|
||||
-ex "ghidra trace sync-enable" ^
|
||||
-ex "target remote localhost:%QEMU_GDB%" ^
|
||||
-ex "set confirm on" ^
|
||||
-ex "set pagination on"
|
||||
@@ -0,0 +1,52 @@
|
||||
#@title gdb + qemu-system
|
||||
#@image-opt env:OPT_TARGET_IMG
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>qemu-system</tt> and connect with <tt>gdb</tt></h3>
|
||||
#@desc <p>
|
||||
#@desc This will launch the target on the local machine using <tt>qemu-system</tt>.
|
||||
#@desc Then in a second terminal, it will connect <tt>gdb</tt> to QEMU's GDBstub.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#qemu
|
||||
#@enum Endian:str auto big little
|
||||
#@env OPT_TARGET_IMG:file!="" "Image" "The target binary executable image"
|
||||
#@env GHIDRA_LANG_EXTTOOL_qemu_system:file="" "QEMU command" "The path to qemu-system for the target architecture."
|
||||
#@env QEMU_GDB:int=1234 "QEMU Port" "Port for gdb connection to qemu"
|
||||
#@env OPT_EXTRA_QEMU_ARGS:str="" "Extra qemu arguments" "Extra arguments to pass to qemu. Use with care."
|
||||
#@env OPT_GDB_PATH:file="gdb-multiarch" "gdb command" "The path to gdb. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
#@env OPT_EXTRA_TTY:bool=false "QEMU TTY" "Provide a separate terminal emulator for qemu."
|
||||
|
||||
. ..\support\gdbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathGdb = Ghidra-Module-PyPath "Debug/Debugger-agent-gdb"
|
||||
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$qemuargs = @("`"$Env:GHIDRA_LANG_EXTTOOL_qemu_system`"")
|
||||
if ("$Env:OPT_EXTRA_QEMU_ARGS" -ne "") {
|
||||
$qemuargs+=("$Env:OPT_EXTRA_QEMU_ARGS")
|
||||
}
|
||||
$qemuargs+=("-gdb", "tcp::$Env:QEMU_GDB", "-S")
|
||||
$qemuargs+=("`"$Env:OPT_TARGET_IMG`"")
|
||||
|
||||
if ("$Env:OPT_EXTRA_TTY" -eq "true") {
|
||||
Start-Process -FilePath $qemuargs[0] -ArgumentList $qemuargs[1..$qemuargs.Count]
|
||||
}
|
||||
else {
|
||||
Start-Process -FilePath $qemuargs[0] -ArgumentList $qemuargs[1..$qemuargs.Count] -NoNewWindow
|
||||
}
|
||||
|
||||
# Give QEMU a moment to open the socket
|
||||
sleep -m 100
|
||||
|
||||
$arglist = Compute-Gdb-Remote-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetCx "remote localhost:$Env:QEMU_GDB" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title qemu-system + gdb
|
||||
#@title gdb + qemu-system
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>qemu-system</tt> and connect with <tt>gdb</tt></h3>
|
||||
@@ -24,7 +24,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group cross
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#qemu
|
||||
#@enum Endian:str auto big little
|
||||
@@ -39,57 +39,32 @@
|
||||
#@env OPT_PULL_ALL_SECTIONS:bool=false "Pull all section mappings" "Force gdb to send all mappings to Ghidra. This can be costly (see help)."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
|
||||
if [ -z "$TTY_TARGET" ]
|
||||
then
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu_system" $OPT_EXTRA_QEMU_ARGS -gdb tcp::$QEMU_GDB -S $1 &
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu_system" $OPT_EXTRA_QEMU_ARGS -gdb tcp::$QEMU_GDB -S $target_image &
|
||||
else
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu_system" $OPT_EXTRA_QEMU_ARGS -gdb tcp::$QEMU_GDB -S $1 <$TTY_TARGET >$TTY_TARGET 2>&1 &
|
||||
"$GHIDRA_LANG_EXTTOOL_qemu_system" $OPT_EXTRA_QEMU_ARGS -gdb tcp::$QEMU_GDB -S $target_image <$TTY_TARGET >$TTY_TARGET 2>&1 &
|
||||
fi
|
||||
|
||||
# Give QEMU a moment to open the socket
|
||||
sleep 0.1
|
||||
|
||||
gdb_args=(
|
||||
-q
|
||||
-ex "set pagination off"
|
||||
-ex "set confirm off"
|
||||
-ex "show version"
|
||||
-ex "python import ghidragdb"
|
||||
-ex "set architecture $OPT_ARCH"
|
||||
-ex "set endian $OPT_ENDIAN"
|
||||
-ex "file \"$target_image\""
|
||||
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\""
|
||||
-ex "ghidra trace start"
|
||||
-ex "ghidra trace sync-enable"
|
||||
-ex "target remote localhost:$QEMU_GDB"
|
||||
-ex "set confirm on"
|
||||
-ex "set pagination on"
|
||||
)
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-remote-args "$target_image" "remote localhost:$QEMU_GDB" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
# If using OPT_PULL_ALL_SECTIONS, append instructions to push all sections from qemu
|
||||
if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]
|
||||
then
|
||||
gdb_args+=(
|
||||
-ex "ghidra trace tx-start put-all-sections"
|
||||
-ex "ghidra trace put-sections -all-objects"
|
||||
-ex "ghidra trace tx-commit"
|
||||
)
|
||||
fi
|
||||
if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]; then
|
||||
args+=(-ex "ghidra trace tx-open 'Put Sections' 'ghidra trace put-sections -all-objects'")
|
||||
fi
|
||||
|
||||
IFS=""
|
||||
"$OPT_GDB_PATH" ${gdb_args[*]}
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#@title remote gdb
|
||||
#@title gdb remote
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
@@ -7,7 +7,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#remote
|
||||
#@enum TargetType:str remote extended-remote
|
||||
@@ -20,42 +20,15 @@
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture override"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
[IO.DirectoryInfo] $repo = "$Env:GHIDRA_HOME\.git"
|
||||
[IO.DirectoryInfo] $repoParent = "$Env:GHIDRA_HOME\ghidra\.git"
|
||||
if ($repo.Exists) {
|
||||
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
|
||||
}
|
||||
elseif ($repoParent.Exists) {
|
||||
$pypathGdb = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
|
||||
}
|
||||
else {
|
||||
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\pypkg\src"
|
||||
}
|
||||
. ..\support\gdbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathGdb = Ghidra-Module-PyPath "Debug/Debugger-agent-gdb"
|
||||
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = @()
|
||||
$arglist = Compute-Gdb-Remote-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetCx "$Env:OPT_TARGET_TYPE $Env:OPT_HOST`:$Env:OPT_PORT" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
$arglist+=("-q")
|
||||
$arglist+=("-ex", "`"set pagination off`"")
|
||||
$arglist+=("-ex", "`"set confirm off`"")
|
||||
$arglist+=("-ex", "`"show version`"")
|
||||
$arglist+=("-ex", "`"python import ghidragdb`"")
|
||||
$arglist+=("-ex", "`"set architecture $Env:OPT_ARCH`"")
|
||||
$arglist+=("-ex", "`"set endian $Env:OPT_ENDIAN`"")
|
||||
if ("$($args[0])" -ne "") {
|
||||
$image = $args[0] -replace "\\", "\\\\"
|
||||
$arglist+=("-ex", "`"file '$image'`"")
|
||||
}
|
||||
$arglist+=("-ex", "`"echo Connecting to $Env:OPT_HOST`:$Env:OPT_PORT... `"")
|
||||
$arglist+=("-ex", "`"target $Env:OPT_TARGET_TYPE $Env:OPT_HOST`:$Env:OPT_PORT`"")
|
||||
$arglist+=("-ex", "`"ghidra trace connect '$Env:GHIDRA_TRACE_RMI_ADDR'`"")
|
||||
$arglist+=("-ex", "`"ghidra trace start`"")
|
||||
$arglist+=("-ex", "`"ghidra trace sync-enable`"")
|
||||
$arglist+=("-ex", "`"ghidra trace sync-synth-stopped`"")
|
||||
$arglist+=("-ex", "`"set confirm on`"")
|
||||
$arglist+=("-ex", "`"set pagination on`"")
|
||||
|
||||
Start-Process -FilePath $Env:OPT_GDB_PATH -ArgumentList $arglist -NoNewWindow -Wait
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title remote gdb
|
||||
#@title gdb remote
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
@@ -23,7 +23,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#remote
|
||||
#@enum TargetType:str remote extended-remote
|
||||
@@ -36,39 +36,18 @@
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture override"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
declare -a args
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
args+=(-q)
|
||||
args+=(-ex "set pagination off")
|
||||
args+=(-ex "set confirmation off")
|
||||
args+=(-ex "show version")
|
||||
args+=(-ex "python import ghidragdb")
|
||||
args+=(-ex "set architecture $OPT_ARCH")
|
||||
args+=(-ex "set endian $OPT_ENDIAN")
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
args+=(-ex "file '$1'")
|
||||
fi
|
||||
args+=(-ex "echo Connecting to $OPT_HOST:$OPT_PORT...")
|
||||
args+=(-ex "target $OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT")
|
||||
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
|
||||
args+=(-ex "ghidra trace start")
|
||||
args+=(-ex "ghidra trace sync-enable")
|
||||
args+=(-ex "ghidra trace sync-synth-stopped")
|
||||
args+=(-ex "set confirm on")
|
||||
args+=(-ex "set pagination on")
|
||||
target_image="$1"
|
||||
|
||||
"$OPT_GDB_PATH" "${args[@]}"
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-remote-args "$target_image" "$OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
::@timeout 60000
|
||||
::@title gdb via ssh
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with <tt>gdb</tt> via <tt>ssh</tt></h3>
|
||||
::@desc <p>
|
||||
::@desc This will launch the target on a remote machine using <tt>gdb</tt> via <tt>ssh</tt>.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group remote
|
||||
::@icon icon.debugger
|
||||
::@help gdb#ssh
|
||||
::@enum StartCmd:str run start starti
|
||||
::@enum Endian:str auto big little
|
||||
::@env OPT_TARGET_IMG:str="" "Image" "The target binary executable image on the remote system"
|
||||
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
::@env OPT_SSH_PATH:file="ssh" "ssh command" "The path to ssh on the local system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_HOST:str="localhost" "[User@]Host" "The hostname or user@host"
|
||||
::@env OPT_REMOTE_PORT:int=12345 "Remote Trace RMI Port" "A free port on the remote end to receive and forward the Trace RMI connection."
|
||||
::@env OPT_EXTRA_SSH_ARGS:str="" "Extra ssh arguments" "Extra arguments to pass to ssh. Use with care."
|
||||
::@env OPT_GDB_PATH:str="gdb" "gdb command" "The path to gdb on the remote system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_START_CMD:StartCmd="starti" "Run command" "The gdb command to actually run the target."
|
||||
::@env OPT_ARCH:str="i386:x86-64" "Architecture" "Target architecture"
|
||||
::@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
@echo off
|
||||
|
||||
IF "%OPT_TARGET_IMG%" == "" (
|
||||
set cmd=TERM='%TERM%' '%OPT_GDB_PATH%' ^
|
||||
-q ^
|
||||
-ex 'set pagination off' ^
|
||||
-ex 'set confirm off' ^
|
||||
-ex 'show version' ^
|
||||
-ex 'python import ghidragdb' ^
|
||||
-ex 'set architecture %OPT_ARCH%' ^
|
||||
ex 'set endian %OPT_ENDIAN%' ^
|
||||
-ex 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
|
||||
-ex 'ghidra trace start' ^
|
||||
-ex 'ghidra trace sync-enable' ^
|
||||
-ex 'set confirm on' ^
|
||||
-ex 'set pagination on'
|
||||
) ELSE (
|
||||
set cmd=TERM='%TERM%' '%OPT_GDB_PATH%' ^
|
||||
-q ^
|
||||
-ex 'set pagination off' ^
|
||||
-ex 'set confirm off' ^
|
||||
-ex 'show version' ^
|
||||
-ex 'python import ghidragdb' ^
|
||||
-ex 'set architecture %OPT_ARCH%' ^
|
||||
ex 'set endian %OPT_ENDIAN%' ^
|
||||
-ex 'file \"%OPT_TARGET_IMG%\"' ^
|
||||
-ex 'set args %OPT_TARGET_ARGS%' ^
|
||||
-ex 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
|
||||
-ex 'ghidra trace start' ^
|
||||
-ex 'ghidra trace sync-enable' ^
|
||||
-ex '%OPT_START_CMD%' ^
|
||||
-ex 'set confirm on' ^
|
||||
-ex 'set pagination on'
|
||||
)
|
||||
|
||||
"%OPT_SSH_PATH%" "-R%OPT_REMOTE_PORT%:%GHIDRA_TRACE_RMI_ADDR%" -t %OPT_EXTRA_SSH_ARGS% "%OPT_HOST%" "%cmd%"
|
||||
@@ -0,0 +1,70 @@
|
||||
#@timeout 60000
|
||||
#@title gdb via ssh
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>gdb</tt> via <tt>ssh</tt></h3>
|
||||
#@desc <p>
|
||||
#@desc This will launch the target on a remote machine using <tt>gdb</tt> via <tt>ssh</tt>.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#ssh
|
||||
#@enum StartCmd:str run start starti
|
||||
#@enum Endian:str auto big little
|
||||
#@arg :str "Image" "The target binary executable image on the remote system"
|
||||
#@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
#@env OPT_SSH_PATH:file="ssh" "ssh command" "The path to ssh on the local system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_HOST:str="localhost" "[User@]Host" "The hostname or user@host"
|
||||
#@env OPT_REMOTE_PORT:int=12345 "Remote Trace RMI Port" "A free port on the remote end to receive and forward the Trace RMI connection."
|
||||
#@env OPT_EXTRA_SSH_ARGS:str="" "Extra ssh arguments" "Extra arguments to pass to ssh. Use with care."
|
||||
#@env OPT_GDB_PATH:str="gdb" "gdb command" "The path to gdb on the remote system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="starti" "Run command" "The gdb command to actually run the target."
|
||||
#@env OPT_ARCH:str="i386:x86-64" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
. ..\support\gdbsetuputils.ps1
|
||||
|
||||
$arglist = Compute-Gdb-Usermode-Args -TargetImage $args[0] -RmiAddress "localhost:$Env:OPT_REMOTE_PORT"
|
||||
$sshargs = Compute-Ssh-Args $arglist True
|
||||
|
||||
$sshproc = Start-Process -FilePath $sshargs[0] -ArgumentList $sshargs[1..$sshargs.Count] -NoNewWindow -Wait -PassThru
|
||||
|
||||
$version = Get-Ghidra-Version
|
||||
$answer = Check-Result-And-Prompt-Mitigation $sshproc @"
|
||||
It appears ghidragdb is missing from the remote system. This can happen if you
|
||||
forgot to install the required package. This can also happen if you installed
|
||||
the packages to a different Python environment than is being used by the
|
||||
remote's gdb.
|
||||
|
||||
This script is about to offer automatic resolution. If you'd like to resolve
|
||||
this manually, answer no to the next question and then see Ghidra's help by
|
||||
pressing F1 in the dialog of launch parameters.
|
||||
|
||||
WARNING: Answering yes to the next question will invoke pip to try to install
|
||||
missing or incorrectly-versioned dependencies. It may attempt to find packages
|
||||
from the PyPI mirror configured on the REMOTE system. If you have not configured
|
||||
one, it will connect to the official one.
|
||||
|
||||
WARNING: We invoke pip with the --break-system-packages flag, because some
|
||||
debuggers that embed Python (gdb, lldb) may not support virtual environments,
|
||||
and so the packages must be installed to your user environment.
|
||||
|
||||
NOTE: This will copy Python wheels into the HOME directory of the user on the
|
||||
remote system. You may be prompted to authenticate a few times while packages
|
||||
are copied and installed.
|
||||
|
||||
NOTE: Automatic resolution will cause this session to terminate. When it has
|
||||
finished, try launching again.
|
||||
"@ "Would you like to install 'ghidragdb==$version'?"
|
||||
|
||||
if ($answer) {
|
||||
Write-Host "Copying Wheels to $Env:OPT_HOST"
|
||||
Mitigate-Scp-PyModules "Debug/Debugger-rmi-trace" "Debug/Debugger-agent-gdb"
|
||||
|
||||
Write-Host "Installing Wheels into GDB's embedded Python"
|
||||
$arglist = Compute-Gdb-PipInstall-Args "'-f'" "os.environ['HOME']" "'ghidragdb==$version'"
|
||||
$sshargs = Compute-Ssh-Args $arglist False
|
||||
Start-Process -FilePath $sshargs[0] -ArgumentList $sshargs[1..$sshargs.Count] -NoNewWindow -Wait
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#ssh
|
||||
#@enum StartCmd:str run start starti
|
||||
@@ -40,40 +40,61 @@
|
||||
#@env OPT_ARCH:str="i386:x86-64" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
target_args="$@"
|
||||
|
||||
if [ -z "$target_image" ]
|
||||
then
|
||||
"$OPT_SSH_PATH" "-R$OPT_REMOTE_PORT:$GHIDRA_TRACE_RMI_ADDR" -t $OPT_EXTRA_SSH_ARGS "$OPT_HOST" "TERM='$TERM' '$OPT_GDB_PATH' \
|
||||
-q \
|
||||
-ex 'set pagination off' \
|
||||
-ex 'set confirm off' \
|
||||
-ex 'show version' \
|
||||
-ex 'python import ghidragdb' \
|
||||
-ex 'set architecture $OPT_ARCH' \
|
||||
-ex 'set endian $OPT_ENDIAN' \
|
||||
-ex 'ghidra trace connect \"localhost:$OPT_REMOTE_PORT\"' \
|
||||
-ex 'ghidra trace start' \
|
||||
-ex 'ghidra trace sync-enable' \
|
||||
-ex 'set confirm on' \
|
||||
-ex 'set pagination on'"
|
||||
else
|
||||
"$OPT_SSH_PATH" "-R$OPT_REMOTE_PORT:$GHIDRA_TRACE_RMI_ADDR" -t $OPT_EXTRA_SSH_ARGS "$OPT_HOST" "TERM='$TERM' '$OPT_GDB_PATH' \
|
||||
-q \
|
||||
-ex 'set pagination off' \
|
||||
-ex 'set confirm off' \
|
||||
-ex 'show version' \
|
||||
-ex 'python import ghidragdb' \
|
||||
-ex 'set architecture $OPT_ARCH' \
|
||||
-ex 'set endian $OPT_ENDIAN' \
|
||||
-ex 'file \"$target_image\"' \
|
||||
-ex 'set args $target_args' \
|
||||
-ex 'ghidra trace connect \"localhost:$OPT_REMOTE_PORT\"' \
|
||||
-ex 'ghidra trace start' \
|
||||
-ex 'ghidra trace sync-enable' \
|
||||
-ex '$OPT_START_CMD' \
|
||||
-ex 'set confirm on' \
|
||||
-ex 'set pagination on'"
|
||||
function launch-gdb-ssh() {
|
||||
local -a args
|
||||
compute-gdb-usermode-args "$target_image" "localhost:$OPT_REMOTE_PORT" "$@"
|
||||
local -a sshargs
|
||||
compute-ssh-args true "${args[@]}"
|
||||
|
||||
"${sshargs[@]}"
|
||||
}
|
||||
version=$(get-ghidra-version)
|
||||
|
||||
function do-installation() {
|
||||
local -a pipargs
|
||||
compute-gdb-pipinstall-args "'-f'" "os.environ['HOME']" "'ghidragdb==$version'"
|
||||
local -a sshargs
|
||||
compute-ssh-args false "${pipargs[@]}"
|
||||
|
||||
"${sshargs[@]}"
|
||||
}
|
||||
|
||||
launch-gdb-ssh
|
||||
if check-result-and-prompt-mitigation $? "
|
||||
It appears ghidragdb is missing from the remote system. This can happen if you
|
||||
forgot to install the required package. This can also happen if you installed
|
||||
the packages to a different Python environment than is being used by the
|
||||
remote's gdb.
|
||||
|
||||
This script is about to offer automatic resolution. If you'd like to resolve
|
||||
this manually, answer no to the next question and then see Ghidra's help by
|
||||
pressing F1 in the dialog of launch parameters.
|
||||
|
||||
WARNING: Answering yes to the next question will invoke pip to try to install
|
||||
missing or incorrectly-versioned dependencies. It may attempt to find packages
|
||||
from the PyPI mirror configured on the REMOTE system. If you have not configured
|
||||
one, it will connect to the official one.
|
||||
|
||||
WARNING: We invoke pip with the --break-system-packages flag, because some
|
||||
debuggers that embed Python (gdb, lldb) may not support virtual environments,
|
||||
and so the packages must be installed to your user environment.
|
||||
|
||||
NOTE: This will copy Python wheels into the HOME directory of the user on the
|
||||
remote system. You may be prompted to authenticate a few times while packages
|
||||
are copied and installed.
|
||||
|
||||
NOTE: Automatic resolution will cause this session to terminate. When it has
|
||||
finished, try launching again.
|
||||
" "Would you like to install 'ghidragdb==$version'?"; then
|
||||
|
||||
echo "Copying Wheels to $OPT_HOST"
|
||||
mitigate-scp-pymodules "Debug/Debugger-rmi-trace" "Debug/Debugger-agent-gdb"
|
||||
|
||||
echo "Installing Wheels into GDB's embedded Python"
|
||||
do-installation
|
||||
fi
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
::@timeout 60000
|
||||
::@title gdb + gdbserver via ssh
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with local <tt>gdb</tt> and <tt>gdbserver</tt> via <tt>ssh</tt></h3>
|
||||
::@desc <p>
|
||||
::@desc This will start <tt>gdb</tt> on the local system and then use it to connect and launch the target in <tt>gdbserver</tt> on the remote system via <tt>ssh</tt>.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group remote
|
||||
::@icon icon.debugger
|
||||
::@help gdb#gdbserver_ssh
|
||||
::@enum Endian:str auto big little
|
||||
::@env OPT_TARGET_IMG:str!="" "Image" "The target binary executable image on the remote system"
|
||||
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
::@env OPT_SSH_PATH:file="ssh" "ssh command" "The path to ssh on the local system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_HOST:str="localhost" "[User@]Host" "The hostname or user@host"
|
||||
::@env OPT_EXTRA_SSH_ARGS:str="" "Extra ssh arguments" "Extra arguments to pass to ssh. Use with care."
|
||||
::@env OPT_GDBSERVER_PATH:str="gdbserver" "gdbserver command (remote)" "The path to gdbserver on the remote system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_EXTRA_GDBSERVER_ARGS:str="" "Extra gdbserver arguments" "Extra arguments to pass to gdbserver. Use with care."
|
||||
::@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb on the local system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
::@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
"%OPT_GDB_PATH%" ^
|
||||
-q ^
|
||||
-ex "set pagination off" ^
|
||||
-ex "set confirm off" ^
|
||||
-ex "show version" ^
|
||||
-ex "python import ghidragdb" ^
|
||||
-ex "set architecture %OPT_ARCH%" ^
|
||||
ex "set endian %OPT_ENDIAN%" ^
|
||||
-ex "target remote | '%OPT_SSH_PATH%' %OPT_EXTRA_SSH_ARGS% '%OPT_HOST%' '%OPT_GDBSERVER_PATH%' %OPT_EXTRA_GDBSERVER_ARGS% - '%OPT_TARGET_IMG%' %OPT_TARGET_ARGS%" ^
|
||||
-ex "ghidra trace connect '%GHIDRA_TRACE_RMI_ADDR%'" ^
|
||||
-ex "ghidra trace start" ^
|
||||
-ex "ghidra trace sync-enable" ^
|
||||
-ex "ghidra trace sync-synth-stopped" ^
|
||||
-ex "set confirm on" ^
|
||||
-ex "set pagination on"
|
||||
@@ -0,0 +1,37 @@
|
||||
#@timeout 60000
|
||||
#@title gdb + gdbserver via ssh
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>gdb</tt> and <tt>gdbserver</tt> via <tt>ssh</tt></h3>
|
||||
#@desc <p>
|
||||
#@desc This will start <tt>gdb</tt> on the local system and then use it to connect and launch the target in <tt>gdbserver</tt> on the remote system via <tt>ssh</tt>.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#gdbserver_ssh
|
||||
#@enum Endian:str auto big little
|
||||
#@arg :str! "Image" "The target binary executable image on the remote system"
|
||||
#@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
#@env OPT_SSH_PATH:file="ssh" "ssh command" "The path to ssh on the local system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_HOST:str="localhost" "[User@]Host" "The hostname or user@host"
|
||||
#@env OPT_EXTRA_SSH_ARGS:str="" "Extra ssh arguments" "Extra arguments to pass to ssh. Use with care."
|
||||
#@env OPT_GDBSERVER_PATH:str="gdbserver" "gdbserver command (remote)" "The path to gdbserver on the remote system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_EXTRA_GDBSERVER_ARGS:str="" "Extra gdbserver arguments" "Extra arguments to pass to gdbserver. Use with care."
|
||||
#@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb on the local system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
. ..\support\gdbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathGdb = Ghidra-Module-PyPath "Debug/Debugger-agent-gdb"
|
||||
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = Compute-Gdb-Remote-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetCx "remote | '$Env:OPT_SSH_PATH' $Env:OPT_EXTRA_SSH_ARGS '$Env:OPT_HOST' '$Env:OPT_GDBSERVER_PATH' $Env:OPT_EXTRA_GDBSERVER_ARGS - '$($args[0])' $Env:OPT_TARGET_ARGS" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
@@ -24,7 +24,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#gdbserver_ssh
|
||||
#@enum Endian:str auto big little
|
||||
@@ -39,31 +39,19 @@
|
||||
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture"
|
||||
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
"$OPT_GDB_PATH" \
|
||||
-q \
|
||||
-ex "set pagination off" \
|
||||
-ex "set confirm off" \
|
||||
-ex "show version" \
|
||||
-ex "python import ghidragdb" \
|
||||
-ex "set architecture $OPT_ARCH" \
|
||||
-ex "set endian $OPT_ENDIAN" \
|
||||
-ex "target remote | '$OPT_SSH_PATH' $OPT_EXTRA_SSH_ARGS '$OPT_HOST' '$OPT_GDBSERVER_PATH' $OPT_EXTRA_GDBSERVER_ARGS - $@" \
|
||||
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-ex "ghidra trace start" \
|
||||
-ex "ghidra trace sync-enable" \
|
||||
-ex "ghidra trace sync-synth-stopped" \
|
||||
-ex "set confirm on" \
|
||||
-ex "set pagination on"
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-remote-args "$target_image" "remote | '$OPT_SSH_PATH' $OPT_EXTRA_SSH_ARGS '$OPT_HOST' '$OPT_GDBSERVER_PATH' $OPT_EXTRA_GDBSERVER_ARGS - '$target_image' $@" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title wine + gdb
|
||||
#@title gdb + wine
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>gdb</tt> and <tt>wine</tt></h3>
|
||||
@@ -23,7 +23,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group cross
|
||||
#@menu-group gdb
|
||||
#@icon icon.debugger
|
||||
#@help gdb#wine
|
||||
#@enum Endian:str auto big little
|
||||
@@ -36,37 +36,20 @@
|
||||
#@env OPT_EXTRA_TTY:bool=false "Inferior TTY" "Provide a separate terminal emulator for the target."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
|
||||
# NOTE: Ghidra will leave TTY_TARGET empty, which gdb takes for the same terminal.
|
||||
. ../support/gdbsetuputils.sh
|
||||
|
||||
"$OPT_GDB_PATH" \
|
||||
-q \
|
||||
-ex "set pagination off" \
|
||||
-ex "set confirm off" \
|
||||
-ex "show version" \
|
||||
-ex "python import ghidragdb.wine" \
|
||||
-ex "set architecture $OPT_ARCH" \
|
||||
-ex "set endian $OPT_ENDIAN" \
|
||||
-ex "file \"$OPT_WINE_PATH\"" \
|
||||
-ex "set args $@" \
|
||||
-ex "set inferior-tty $TTY_TARGET" \
|
||||
-ex "starti" \
|
||||
-ex "ghidra wine run-to-image \"$1\"" \
|
||||
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-ex "ghidra trace start \"$1\"" \
|
||||
-ex "ghidra trace sync-enable" \
|
||||
-ex "ghidra trace sync-synth-stopped" \
|
||||
-ex "set confirm on" \
|
||||
-ex "set pagination on"
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathGdb=$(ghidra-module-pypath "Debug/Debugger-agent-gdb")
|
||||
export PYTHONPATH=$pypathGdb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
|
||||
function launch-gdb() {
|
||||
local -a args
|
||||
compute-gdb-wine-args "$target_image" "$GHIDRA_TRACE_RMI_ADDR" "$@"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-gdb
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
. ..\..\..\Debugger-rmi-trace\data\support\setuputils.ps1
|
||||
|
||||
function Add-Gdb-Init-Args {
|
||||
param([ref]$ArgList)
|
||||
|
||||
$ArgList.Value+=("-q")
|
||||
$ArgList.Value+=("-ex", "`"set pagination off`"")
|
||||
$ArgList.Value+=("-ex", "`"set confirm off`"")
|
||||
$ArgList.Value+=("-ex", "`"show version`"")
|
||||
$ArgList.Value+=("-ex", "`"python import ghidragdb`"")
|
||||
$ArgList.Value+=("-ex", "`"python if not 'ghidragdb' in locals(): exit(253)`"")
|
||||
$ArgList.Value+=("-ex", "`"set architecture $Env:OPT_ARCH`"")
|
||||
$ArgList.Value+=("-ex", "`"set endian $Env:OPT_ENDIAN`"")
|
||||
}
|
||||
|
||||
function Add-Gdb-Image-And-Args {
|
||||
param([ref]$ArgList, $TargetImage, $TargetArgs)
|
||||
|
||||
if ("$TargetImage" -ne "") {
|
||||
$image = $TargetImage -replace "\\", "\\\\"
|
||||
$ArgList.Value+=("-ex", "`"file '$image'`"")
|
||||
}
|
||||
if ("$TargetArgs" -ne "") {
|
||||
$tgtargs = $TargetArgs -replace "`"", "\`""
|
||||
# Escaping parentheses in the arguments is no longer necessary in powershell vs cmd
|
||||
$ArgList.Value+=("-ex", "`"set args $tgtargs`"")
|
||||
}
|
||||
}
|
||||
|
||||
function Add-Gdb-Connect-And-Sync {
|
||||
param([ref]$ArgList, $Address)
|
||||
|
||||
$ArgList.Value+=("-ex", "`"ghidra trace connect '$Address'`"")
|
||||
$ArgList.Value+=("-ex", "`"ghidra trace start`"")
|
||||
$ArgList.Value+=("-ex", "`"ghidra trace sync-enable`"")
|
||||
}
|
||||
|
||||
function Add-Gdb-Start-If-Image {
|
||||
param([ref]$ArgList, $TargetImage)
|
||||
|
||||
if ("$TargetImage" -ne "") {
|
||||
$ArgList.Value+=("-ex", "`"$Env:OPT_START_CMD`"")
|
||||
}
|
||||
}
|
||||
|
||||
function Add-Gdb-Tail-Args {
|
||||
param([ref]$ArgList)
|
||||
|
||||
$ArgList.Value+=("-ex", "`"set confirm on`"")
|
||||
$ArgList.Value+=("-ex", "`"set pagination on`"")
|
||||
}
|
||||
|
||||
function Compute-Gdb-Usermode-Args {
|
||||
param($TargetImage, $RmiAddress)
|
||||
|
||||
$arglist = @("`"$Env:OPT_GDB_PATH`"")
|
||||
Add-Gdb-Init-Args -ArgList ([ref]$arglist)
|
||||
Add-Gdb-Image-And-Args -ArgList ([ref]$arglist) -TargetImage $TargetImage -TargetArgs $Env:OPT_TARGET_ARGS
|
||||
Add-Gdb-Connect-And-Sync -ArgList ([ref]$arglist) -Address $RmiAddress
|
||||
Add-Gdb-Start-If-Image -ArgList ([ref]$arglist) -TargetImage $TargetImage
|
||||
Add-Gdb-Tail-Args -ArgList ([ref]$arglist)
|
||||
|
||||
return $arglist
|
||||
}
|
||||
|
||||
function Compute-Gdb-Remote-Args {
|
||||
param($TargetImage, $TargetCx, $RmiAddress)
|
||||
|
||||
$arglist = @("`"$Env:OPT_GDB_PATH`"")
|
||||
Add-Gdb-Init-Args -ArgList ([ref]$arglist)
|
||||
Add-Gdb-Image-And-Args -ArgList ([ref]$arglist) -TargetImge $TargetImage -TargetArgs ""
|
||||
$arglist+=("-ex", "`"echo Connecting to $TargetCx\n`"")
|
||||
$arglist+=("-ex", "`"target $TargetCx`"")
|
||||
Add-Gdb-Connect-And-Sync -ArgList ([ref]$arglist) -Address $RmiAddress
|
||||
$arglist+=("-ex", "`"ghidra trace sync-synth-stopped`"")
|
||||
Add-Gdb-Tail-Args -ArgList ([ref]$arglist)
|
||||
|
||||
return $arglist
|
||||
}
|
||||
|
||||
function Compute-Gdb-PipInstall-Args {
|
||||
$argvpart = $args -join ", "
|
||||
$arglist = @("`"$Env:OPT_GDB_PATH`"")
|
||||
$arglist+=("-ex", "`"set pagination off`"")
|
||||
$arglist+=("-ex", "`"python import os, sys, runpy`"")
|
||||
$arglist+=("-ex", "`"python sys.argv=['pip', 'install', '--force-reinstall', $argvpart]`"")
|
||||
$arglist+=("-ex", "`"python os.environ['PIP_BREAK_SYSTEM_PACKAGE']='1'`"")
|
||||
$arglist+=("-ex", "`"python runpy.run_module('pip', run_name='__main__')`"")
|
||||
|
||||
return $arglist
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
## ###
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
. ../../../Debugger-rmi-trace/data/support/setuputils.sh
|
||||
|
||||
add-gdb-init-args() {
|
||||
args+=(-q)
|
||||
args+=(-ex "set pagination off")
|
||||
args+=(-ex "set confirm off")
|
||||
args+=(-ex "show version")
|
||||
args+=(-ex "python import ghidragdb")
|
||||
args+=(-ex "python if not 'ghidragdb' in locals(): exit(253)")
|
||||
args+=(-ex "set architecture $OPT_ARCH")
|
||||
args+=(-ex "set endian $OPT_ENDIAN")
|
||||
}
|
||||
|
||||
add-gdb-image-and-args() {
|
||||
target_image=$1
|
||||
target_args=$2
|
||||
|
||||
if [ -n "$target_image" ]; then
|
||||
args+=(-ex "file '$target_image'")
|
||||
fi
|
||||
if [ -n "$target_args" ]; then
|
||||
args+=(-ex "set args $target_args")
|
||||
fi
|
||||
}
|
||||
|
||||
add-gdb-inferior-tty() {
|
||||
# Ghidra will leave TTY_TARGET empty when OPT_EXTRA_TTY is false.
|
||||
# Gdb takes empty to mean the same terminal.
|
||||
args+=(-ex "set inferior-tty $TTY_TARGET")
|
||||
}
|
||||
|
||||
add-gdb-connect-and-sync() {
|
||||
address=$1
|
||||
|
||||
args+=(-ex "ghidra trace connect '$address'")
|
||||
args+=(-ex "ghidra trace start")
|
||||
args+=(-ex "ghidra trace sync-enable")
|
||||
}
|
||||
|
||||
add-gdb-start-if-image() {
|
||||
target_image=$1
|
||||
|
||||
if [ -n "$target_image" ]; then
|
||||
args+=(-ex "$OPT_START_CMD")
|
||||
fi
|
||||
}
|
||||
|
||||
add-gdb-tail-args() {
|
||||
args+=(-ex "set confirm on")
|
||||
args+=(-ex "set pagination on")
|
||||
}
|
||||
|
||||
compute-gdb-usermode-args() {
|
||||
target_image=$1
|
||||
rmi_address=$2
|
||||
shift
|
||||
shift
|
||||
|
||||
args+=("$OPT_GDB_PATH")
|
||||
add-gdb-init-args
|
||||
add-gdb-image-and-args "$target_image" "$@"
|
||||
add-gdb-inferior-tty
|
||||
add-gdb-connect-and-sync "$rmi_address"
|
||||
add-gdb-start-if-image "$target_image"
|
||||
add-gdb-tail-args
|
||||
}
|
||||
|
||||
compute-gdb-wine-args() {
|
||||
target_image=$1
|
||||
rmi_address=$2
|
||||
shift
|
||||
shift
|
||||
|
||||
args+=("$OPT_GDB_PATH")
|
||||
add-gdb-init-args
|
||||
add-gdb-image-and-args "$OPT_WINE_PATH" "$target_image" "$@"
|
||||
add-gdb-inferior-tty
|
||||
gdb+=(-ex "starti")
|
||||
gdb+=(-ex "ghidra wine run-to-image '$target_image'")
|
||||
add-gdb-connect-and-sync "$rmi_address"
|
||||
gdb+=(-ex "ghidra trace sync-synth-stopped")
|
||||
add-gdb-tail-args
|
||||
}
|
||||
|
||||
compute-gdb-remote-args() {
|
||||
target_image=$1
|
||||
target_cx=$2
|
||||
rmi_address=$3
|
||||
|
||||
args+=("$OPT_GDB_PATH")
|
||||
add-gdb-init-args
|
||||
add-gdb-image-and-args "$target_image" ""
|
||||
args+=(-ex "echo Connecting to $target_cx\n")
|
||||
args+=(-ex "target $target_cx")
|
||||
add-gdb-connect-and-sync "$rmi_address"
|
||||
args+=(-ex "ghidra trace sync-synth-stopped")
|
||||
add-gdb-tail-args
|
||||
}
|
||||
|
||||
compute-gdb-pipinstall-args() {
|
||||
local argvpart
|
||||
printf -v argvpart ", %s" "$@"
|
||||
pipargs=("$OPT_GDB_PATH")
|
||||
pipargs+=(-q)
|
||||
pipargs+=(-ex "set pagination off")
|
||||
pipargs+=(-ex "python import os, sys, runpy")
|
||||
pipargs+=(-ex "python sys.argv=['pip', 'install', '--force-reinstall'$argvpart]")
|
||||
pipargs+=(-ex "python os.environ['PIP_BREAK_SYSTEM_PACKAGE']='1'")
|
||||
pipargs+=(-ex "python runpy.run_module('pip', run_name='__main__')")
|
||||
}
|
||||
@@ -4,11 +4,12 @@
|
||||
Module.manifest||GHIDRA||||END|
|
||||
README.md||GHIDRA||||END|
|
||||
build.gradle||GHIDRA||||END|
|
||||
data/debugger-launchers/android-lldb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/kernel-lldb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/local-lldb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/android-lldb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/kernel-lldb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/local-lldb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/remote-lldb.ps1||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-lldb.bat||GHIDRA||||END|
|
||||
data/debugger-launchers/ssh-lldb.ps1||GHIDRA||||END|
|
||||
data/support/lldbsetuputils.ps1||GHIDRA||||END|
|
||||
src/main/help/help/TOC_Source.xml||GHIDRA||||END|
|
||||
src/main/help/help/topics/lldb/lldb.html||GHIDRA||||END|
|
||||
src/main/py/LICENSE||GHIDRA||||END|
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
::@title android lldb
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
::@desc <p>
|
||||
::@desc This will start <tt>lldb</tt> on the local system and then use it to connect to the remote system.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group remote
|
||||
::@icon icon.debugger
|
||||
::@help lldb#android
|
||||
::@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
::@env OPT_TARGET_IMG:file="" "Image" "The target binary executable image"
|
||||
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
::@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
|
||||
::@env OPT_PORT:str="9999" "Port" "The host's listening port"
|
||||
::@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
::@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
:: NB: This works - a lot of things do not. Don't change unless you know what you're doing!
|
||||
set OPT_TARGET_IMG="%OPT_TARGET_IMG%"
|
||||
set OPT_TARGET_ARGS="%OPT_TARGET_ARGS%"
|
||||
|
||||
IF %OPT_ARCH%=="" (
|
||||
IF "%OPT_TARGET_ARGS%"=="" (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "platform select remote-android" ^
|
||||
-o "platform connect connect://%OPT_HOST%:%OPT_PORT%" ^
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
) ELSE (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "platform select remote-android" ^
|
||||
-o "platform connect connect://%OPT_HOST%:%OPT_PORT%" ^
|
||||
-o "settings set target.default-arch %OPT_ARCH%"
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "settings set target.run-args %OPT_TARGET_ARGS%" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
)
|
||||
) ELSE (
|
||||
if %OPT_TARGET_ARGS=="" (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "platform select remote-android" ^
|
||||
-o "platform connect connect://%OPT_HOST%:%OPT_PORT%" ^
|
||||
-o "settings set target.default-arch %OPT_ARCH%"
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
) ELSE (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "platform select remote-android" ^
|
||||
-o "platform connect connect://%OPT_HOST%:%OPT_PORT%" ^
|
||||
-o "settings set target.default-arch %OPT_ARCH%"
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "settings set target.run-args %OPT_TARGET_ARGS%" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
#@title lldb Android
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
#@desc <p>
|
||||
#@desc This will start <tt>lldb</tt> on the local system and then use it to connect to the remote system.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#android
|
||||
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
#@arg :file "Image" "The target binary executable image"
|
||||
#@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
|
||||
#@env OPT_PORT:str="9999" "Port" "The host's listening port"
|
||||
#@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
|
||||
|
||||
. ..\support\lldbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathLldb = Ghidra-Module-PyPath "Debug/Debugger-agent-lldb"
|
||||
$Env:PYTHONPATH = "$pypathLldb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = Compute-Lldb-Platform-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetType "remote-android" `
|
||||
-TargetUrl "connect://$Env:OPT_HOST`:$Env:OPT_PORT" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
@@ -14,16 +14,16 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title android lldb
|
||||
#@title lldb Android
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to an Android target.</h3>
|
||||
#@desc <p>
|
||||
#@desc This will start <tt>lldb</tt> on the local system and then use it to connect to the remote system.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#android
|
||||
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
@@ -35,48 +35,20 @@
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/lldbsetuputils.sh
|
||||
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathLldb=$(ghidra-module-pypath "Debug/Debugger-agent-lldb")
|
||||
export PYTHONPATH=$pypathLldb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
target_args="$@"
|
||||
|
||||
if [ -z "$target_args" ]
|
||||
then
|
||||
argspart=
|
||||
else
|
||||
argspart=("-o" "settings set target.run-args $target_args")
|
||||
fi
|
||||
|
||||
if [ -z "$OPT_ARCH" ]
|
||||
then
|
||||
archcmd=
|
||||
else
|
||||
archcmd=("-o" "settings set target.default-arch $OPT_ARCH")
|
||||
fi
|
||||
|
||||
"$OPT_LLDB_PATH" \
|
||||
-o "version" \
|
||||
-o "script import ghidralldb" \
|
||||
-o "platform select remote-android" \
|
||||
-o "platform connect connect://$OPT_HOST:$OPT_PORT" \
|
||||
"${archcmd[@]}" \
|
||||
-o "target create \"$target_image\"" \
|
||||
"${argspart[@]}" \
|
||||
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-o "ghidra trace start" \
|
||||
-o "ghidra trace sync-enable" \
|
||||
-o "ghidra trace sync-synth-stopped" \
|
||||
-o "$OPT_START_CMD"
|
||||
function launch-lldb() {
|
||||
local -a args
|
||||
compute-lldb-platform-args "$target_image" remote-android "connect://$OPT_HOST:$OPT_PORT" "$GHIDRA_TRACE_RMI_ADDR" "$@"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-lldb
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
::@title kernel lldb
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with local <tt>lldb</tt> and connect to a remote kernel</h3>
|
||||
::@desc <p>
|
||||
::@desc This will start <tt>lldb</tt> on the local system and then use it to connect to the remote system.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group remote
|
||||
::@icon icon.debugger
|
||||
::@help lldb#macos_kernel
|
||||
::@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
|
||||
::@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
::@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
IF "%OPT_ARCH%"=="" (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "kdp-remote %OPT_HOST%" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped"
|
||||
) ELSE (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "settings set target.default-arch %OPT_ARCH%"
|
||||
-o "kdp-remote %OPT_HOST%" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "ghidra trace sync-synth-stopped"
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
#@title lldb kernel (kdp)
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a remote kernel</h3>
|
||||
#@desc <p>
|
||||
#@desc This will start <tt>lldb</tt> on the local system and then use it to connect to the remote system.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#macos_kernel
|
||||
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
|
||||
#@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
|
||||
. ..\support\lldbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathLldb = Ghidra-Module-PyPath "Debug/Debugger-agent-lldb"
|
||||
$Env:PYTHONPATH = "$pypathLldb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = Compute-Lldb-Remote-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetCx "kdp-remote $Env:OPT_HOST" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title kernel lldb
|
||||
#@title lldb kernel (kdp)
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a remote kernel</h3>
|
||||
#@desc <p>
|
||||
@@ -22,39 +22,23 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#macos_kernel
|
||||
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
|
||||
#@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/lldbsetuputils.sh
|
||||
|
||||
if [ -z "$OPT_ARCH" ]
|
||||
then
|
||||
archcmd=
|
||||
else
|
||||
archcmd=("-o" "settings set target.default-arch $OPT_ARCH")
|
||||
fi
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathLldb=$(ghidra-module-pypath "Debug/Debugger-agent-lldb")
|
||||
export PYTHONPATH=$pypathLldb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
"$OPT_LLDB_PATH" \
|
||||
-o "version" \
|
||||
-o "script import ghidralldb" \
|
||||
"${archcmd[@]}" \
|
||||
-o "kdp-remote $OPT_HOST" \
|
||||
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-o "ghidra trace start" \
|
||||
-o "ghidra trace sync-enable" \
|
||||
-o "ghidra trace sync-synth-stopped"
|
||||
function launch-lldb() {
|
||||
local -a args
|
||||
compute-lldb-remote-args "" "kdp-remote $OPT_HOST" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-lldb
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
::@title lldb
|
||||
::@image-opt env:OPT_TARGET_IMG
|
||||
::@desc <html><body width="300px">
|
||||
::@desc <h3>Launch with <tt>lldb</tt></h3>
|
||||
::@desc <p>
|
||||
::@desc This will launch the target on the local machine using <tt>lldb</tt>.
|
||||
::@desc For setup instructions, press <b>F1</b>.
|
||||
::@desc </p>
|
||||
::@desc </body></html>
|
||||
::@menu-group local
|
||||
::@icon icon.debugger
|
||||
::@help lldb#local
|
||||
::@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
::@env OPT_TARGET_IMG:file="" "Image" "The target binary executable image"
|
||||
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
::@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb. Omit the full path to resolve using the system PATH."
|
||||
::@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
|
||||
|
||||
@echo off
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
|
||||
IF EXIST %GHIDRA_HOME%\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
IF EXIST %GHIDRA_HOME%\ghidra\.git (
|
||||
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src
|
||||
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
|
||||
)
|
||||
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
|
||||
|
||||
:: NB: This works - a lot of things do not. Don't change unless you know what you're doing!
|
||||
set OPT_TARGET_IMG="%OPT_TARGET_IMG%"
|
||||
set OPT_TARGET_ARGS="%OPT_TARGET_ARGS%"
|
||||
|
||||
IF %OPT_TARGET_IMG%=="" (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable"
|
||||
) ELSE (
|
||||
IF "%OPT_TARGET_ARGS%"=="" (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
) ELSE (
|
||||
"%OPT_LLDB_PATH%" ^
|
||||
-o "version" ^
|
||||
-o "script import ghidralldb" ^
|
||||
-o "target create "%OPT_TARGET_IMG%"" ^
|
||||
-o "settings set target.run-args %OPT_TARGET_ARGS%" ^
|
||||
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
|
||||
-o "ghidra trace start" ^
|
||||
-o "ghidra trace sync-enable" ^
|
||||
-o "%OPT_START_CMD%"
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
#@title lldb
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>lldb</tt></h3>
|
||||
#@desc <p>
|
||||
#@desc This will launch the target on the local machine using <tt>lldb</tt>.
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#local
|
||||
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
#@arg :file "Image" "The target binary executable image"
|
||||
#@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
|
||||
|
||||
. ..\support\lldbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathLldb = Ghidra-Module-PyPath "Debug/Debugger-agent-lldb"
|
||||
$Env:PYTHONPATH = "$pypathLldb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = Compute-Lldb-Usermode-Args `
|
||||
-TargetImage $args[0] `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] `
|
||||
-NoNewWindow -Wait
|
||||
@@ -23,7 +23,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group local
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#local
|
||||
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
|
||||
@@ -34,55 +34,19 @@
|
||||
#@env OPT_EXTRA_TTY:bool=false "Target TTY" "Provide a separate terminal emulator for the target."
|
||||
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/lldbsetuputils.sh
|
||||
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathLldb=$(ghidra-module-pypath "Debug/Debugger-agent-lldb")
|
||||
export PYTHONPATH=$pypathLldb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
target_args="$@"
|
||||
|
||||
if [ -z "$target_args" ]
|
||||
then
|
||||
argspart=
|
||||
else
|
||||
argspart=("-o" "settings set target.run-args $target_args")
|
||||
fi
|
||||
function launch-lldb() {
|
||||
local -a args
|
||||
compute-lldb-usermode-args "$target_image" "$GHIDRA_TRACE_RMI_ADDR" "$@"
|
||||
|
||||
if [ -z "$TARGET_TTY" ]
|
||||
then
|
||||
ttypart=
|
||||
else
|
||||
ttypart=("-o" "settings set target.output-path $TTY_TARGET" "-o" "settings set target.input-path $TTY_TARGET")
|
||||
fi
|
||||
|
||||
if [ -z "$target_image" ]
|
||||
then
|
||||
"$OPT_LLDB_PATH" \
|
||||
-o "version" \
|
||||
-o "script import ghidralldb" \
|
||||
"${ttypart[@]}" \
|
||||
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-o "ghidra trace start" \
|
||||
-o "ghidra trace sync-enable"
|
||||
else
|
||||
"$OPT_LLDB_PATH" \
|
||||
-o "version" \
|
||||
-o "script import ghidralldb" \
|
||||
-o "target create \"$target_image\"" \
|
||||
"${argspart[@]}" \
|
||||
"${ttypart[@]}" \
|
||||
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
|
||||
-o "ghidra trace start" \
|
||||
-o "ghidra trace sync-enable" \
|
||||
-o "$OPT_START_CMD"
|
||||
fi
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-lldb
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#@title remote lldb
|
||||
#@title lldb remote (gdb)
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
@@ -7,7 +7,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#remote
|
||||
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
|
||||
@@ -16,37 +16,15 @@
|
||||
#@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
|
||||
[IO.DirectoryInfo] $repo = "$Env:GHIDRA_HOME\.git"
|
||||
[IO.DirectoryInfo] $repoParent = "$Env:GHIDRA_HOME\ghidra\.git"
|
||||
if ($repo.Exists) {
|
||||
$pypathLldb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
|
||||
}
|
||||
elseif ($repoParent.Exists) {
|
||||
$pypathLldb = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-agent-lldb\build\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
|
||||
}
|
||||
else {
|
||||
$pypathLldb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-lldb\pypkg\src"
|
||||
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\pypkg\src"
|
||||
}
|
||||
. ..\support\lldbsetuputils.ps1
|
||||
|
||||
$pypathTrace = Ghidra-Module-PyPath "Debug/Debugger-rmi-trace"
|
||||
$pypathLldb = Ghidra-Module-PyPath "Debug/Debugger-agent-lldb"
|
||||
$Env:PYTHONPATH = "$pypathLldb;$pypathTrace;$Env:PYTHONPATH"
|
||||
|
||||
$arglist = @()
|
||||
$arglist = Compute-Lldb-Remote-Args `
|
||||
-TargetImage $args[0] `
|
||||
-TargetCx "gdb-remote $Env:OPT_HOST`:$Env:OPT_PORT" `
|
||||
-RmiAddress "$Env:GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
$arglist+=("-o", "`"version`"")
|
||||
$arglist+=("-o", "`"script import ghidralldb`"")
|
||||
if ("$Env:OPT_ARCH" -ne "") {
|
||||
$arglist+=("-o", "`"settings set target.default-arch $Env:OPT_ARCH`"")
|
||||
}
|
||||
if ("$($args[0])" -ne "") {
|
||||
$image = $args[0]
|
||||
$arglist+=("-o", "`"file '$image'`"")
|
||||
}
|
||||
$arglist+=("-o", "`"gdb-remote $Env:OPT_HOST`:$Env:OPT_PORT`"")
|
||||
$arglist+=("-o", "`"ghidra trace connect '$Env:GHIDRA_TRACE_RMI_ADDR'`"")
|
||||
$arglist+=("-o", "`"ghidra trace start`"")
|
||||
$arglist+=("-o", "`"ghidra trace sync-enable`"")
|
||||
$arglist+=("-o", "`"ghidra trace sync-synth-stopped`"")
|
||||
|
||||
Start-Process -FilePath $Env:OPT_LLDB_PATH -ArgumentList $arglist -NoNewWindow -Wait
|
||||
Start-Process -FilePath $arglist[0] -ArgumentList $arglist[1..$arglist.Count] -NoNewWindow -Wait
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#@title remote lldb
|
||||
#@title lldb remote (gdb)
|
||||
#@image-opt arg:1
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
|
||||
@@ -23,7 +23,7 @@
|
||||
#@desc For setup instructions, press <b>F1</b>.
|
||||
#@desc </p>
|
||||
#@desc </body></html>
|
||||
#@menu-group remote
|
||||
#@menu-group lldb
|
||||
#@icon icon.debugger
|
||||
#@help lldb#remote
|
||||
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
|
||||
@@ -32,35 +32,18 @@
|
||||
#@env OPT_ARCH:str="" "Architecture" "Target architecture override"
|
||||
#@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb on the local system. Omit the full path to resolve using the system PATH."
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/build/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-lldb/pypkg/src:$PYTHONPATH
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
. ../support/lldbsetuputils.sh
|
||||
|
||||
declare -a args
|
||||
pypathTrace=$(ghidra-module-pypath "Debug/Debugger-rmi-trace")
|
||||
pypathLldb=$(ghidra-module-pypath "Debug/Debugger-agent-lldb")
|
||||
export PYTHONPATH=$pypathLldb:$pypathTrace:$PYTHONPATH
|
||||
|
||||
args+=(-o version)
|
||||
args+=(-o "script import ghidralldb")
|
||||
if [ -n "$OPT_ARCH" ]
|
||||
then
|
||||
args+=(-o "settings set target.default-arch $OPT_ARCH")
|
||||
fi
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
args+=(-o "file '$1'")
|
||||
fi
|
||||
args+=(-o "gdb-remote $OPT_HOST:$OPT_PORT")
|
||||
args+=(-o "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
|
||||
args+=(-o "ghidra trace start")
|
||||
args+=(-o "ghidra trace sync-enable")
|
||||
args+=(-o "ghidra trace sync-synth-stopped")
|
||||
target_image="$1"
|
||||
|
||||
"$OPT_LLDB_PATH" "${args[@]}"
|
||||
function launch-lldb() {
|
||||
local -a args
|
||||
compute-lldb-remote-args "$target_image" "gdb-remote $OPT_HOST:$OPT_PORT" "$GHIDRA_TRACE_RMI_ADDR"
|
||||
|
||||
"${args[@]}"
|
||||
}
|
||||
launch-lldb
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user