Merge remote-tracking branch 'origin/GP-5360_d-millar_bat_script_fixes'

(Closes #4977)
This commit is contained in:
Ryan Kurtz 2025-02-13 14:51:25 -05:00
commit c186ac2f41
15 changed files with 393 additions and 52 deletions

View file

@ -12,7 +12,7 @@
::@help TraceRmiLauncherServicePlugin#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."
:: Use env instead of args, because "all args except first" is terrible to implement in batch
::@env OPT_TARGET_IMG:file!="" "Image" "The target binary executable image"
::@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_USE_DBGMODEL:bool=true "Use dbgmodel" "Load and use dbgmodel.dll if it is available."
::@env WINDBG_DIR:dir="" "Path to dbgeng.dll directory" "Path containing dbgeng and associated DLLS (if not Windows Kits)."

View file

@ -12,7 +12,7 @@
::@help TraceRmiLauncherServicePlugin#dbgeng
::@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."
:: Use env instead of args, because "all args except first" is terrible to implement in batch
::@env OPT_TARGET_IMG:file!="" "Image" "The target binary executable image"
::@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_USE_DBGMODEL:bool=true "Use dbgmodel" "Load and use dbgmodel.dll if it is available."
::@env WINDBG_DIR:dir="" "Path to dbgeng.dll directory" "Path containing dbgeng and associated DLLS (if not Windows Kits)."

View file

@ -12,7 +12,7 @@
::@help TraceRmiLauncherServicePlugin#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."
:: Use env instead of args, because "all args except first" is terrible to implement in batch
::@env OPT_TARGET_IMG:str!="" "Image" "The target binary executable image"
::@env OPT_TARGET_IMG:str="" "Image" "The target binary executable image"
::@env OPT_TARGET_ARGS:str="" "Arguments" "Command-line arguments to pass to the target"
::@env OPT_CONNECT_STRING:str="" "Connection" "Connection-string arguments (a la dbgsrv args)"
::@env OPT_USE_DBGMODEL:bool=true "Use dbgmodel" "Load and use dbgmodel.dll if it is available."

View file

@ -51,8 +51,14 @@ def main():
args = os.getenv('OPT_TARGET_ARGS')
if args:
args = ' ' + args
target = os.getenv('OPT_TARGET_IMG')
if target is None or target == "":
print("dbgeng requires a target image - please try again.")
cmd.ghidra_trace_disconnect()
return
cmd.ghidra_trace_create_ext(
os.getenv('OPT_TARGET_IMG') + args,
target + args,
os.getenv('OPT_TARGET_DIR'),
os.getenv('OPT_TARGET_ENV'),
os.getenv('OPT_CREATE_FLAGS'),
@ -67,7 +73,7 @@ def main():
except KeyboardInterrupt as ki:
dbg.interrupt()
cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
cmd.ghidra_trace_start(target)
cmd.ghidra_trace_sync_enable()
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)

View file

@ -1,17 +1,17 @@
## ###
# IP: GHIDRA
# 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
# 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
# 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.
# 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
@ -51,8 +51,13 @@ def main():
args = os.getenv('OPT_TARGET_ARGS')
if args:
args = ' ' + args
cmd.ghidra_trace_create(
os.getenv('OPT_TARGET_IMG') + args, start_trace=False)
target = os.getenv('OPT_TARGET_IMG')
if target is None or target == "":
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:
@ -60,7 +65,7 @@ def main():
except KeyboardInterrupt as ki:
dbg.interrupt()
cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG'))
cmd.ghidra_trace_start(target)
cmd.ghidra_trace_sync_enable()
on_state_changed(DbgEng.DEBUG_CES_EXECUTION_STATUS, DbgEng.DEBUG_STATUS_BREAK)

View file

@ -33,6 +33,14 @@ IF EXIST %GHIDRA_HOME%\ghidra\.git (
)
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 ^

View file

@ -4,7 +4,11 @@
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/remote-lldb.bat||GHIDRA||||END|
data/debugger-launchers/ssh-lldb.bat||GHIDRA||||END|
src/main/py/LICENSE||GHIDRA||||END|
src/main/py/MANIFEST.in||GHIDRA||||END|
src/main/py/README.md||GHIDRA||||END|

View file

@ -0,0 +1,95 @@
::@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 TraceRmiLauncherServicePlugin#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%"
)
)

View file

@ -25,7 +25,7 @@
#@desc </body></html>
#@menu-group remote
#@icon icon.debugger
#@help TraceRmiLauncherServicePlugin#lldb_remote
#@help TraceRmiLauncherServicePlugin#lldb_android
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
#@arg :file "Image" "The target binary executable image"
#@args "Arguments" "Command-line arguments to pass to the target"

View file

@ -0,0 +1,48 @@
::@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 TraceRmiLauncherServicePlugin#lldb_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"
)

View file

@ -1,5 +1,5 @@
::@title lldb
::@image-opt arg:1
::@image-opt env:OPT_TARGET_IMG
::@desc <html><body width="300px">
::@desc <h3>Launch with <tt>lldb</tt></h3>
::@desc <p>
@ -11,8 +11,8 @@
::@icon icon.debugger
::@help TraceRmiLauncherServicePlugin#lldb
::@enum StartCmd:str "process launch" "process launch --stop-at-entry"
::@arg :file "Image" "The target binary executable image"
::@args "Arguments" "Command-line arguments to pass to the target"
::@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."
@ -29,38 +29,36 @@ IF EXIST %GHIDRA_HOME%\ghidra\.git (
)
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
set target_image=%1
shift
set target_args=<%*
:: 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 '%target_image%'=="" (
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"
)
IF NOT '%target_image%'=="" IF "%target_args%"=="" (
"%OPT_LLDB_PATH%" ^
-o "version" ^
-o "script import ghidralldb" ^
-o "target create "%target_image%"" ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
-o "%OPT_START_CMD%"
)
IF NOT '%target_image%'=="" IF NOT "%target_args%"=="" (
"%OPT_LLDB_PATH%" ^
-o "version" ^
-o "script import ghidralldb" ^
-o "target create "%target_image%"" ^
-o "settings set target.run-args %target_args%" ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
-o "%OPT_START_CMD%"
) 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%"
)
)

View file

@ -0,0 +1,49 @@
::@title remote 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 TraceRmiLauncherServicePlugin#lldb_remote
::@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."
@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 "gdb-remote %OPT_HOST%:%OPT_PORT%" ^
-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 "gdb-remote %OPT_HOST%:%OPT_PORT%" ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
-o "ghidra trace sync-synth-stopped"
)

View file

@ -0,0 +1,51 @@
::@timeout 60000
::@title lldb via ssh
::@image-opt env:OPT_TARGET_IMG
::@desc <html><body width="300px">
::@desc <h3>Launch with <tt>lldb</tt> via <tt>ssh</tt></h3>
::@desc <p>
::@desc This will launch the target on a remote machine using <tt>lldb</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 TraceRmiLauncherServicePlugin#lldb_ssh
::@enum StartCmd:str "process launch" "process launch --stop-at-entry"
::@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_LLDB_PATH:str="lldb" "lldb command" "The path to lldb on the remote 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."
::@env OPT_ARCH:str="x86_64" "Architecture" "Target architecture"
@echo off
IF "%OPT_TARGET_ARGS%" == "" (
set cmd=TERM='%TERM%' '%OPT_LLDB_PATH%' ^
-o 'version' ^
-o 'script import ghidralldb' ^
-o 'settings set target.default-arch %OPT_ARCH%' ^
-o 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
-o 'target create \"%OPT_TARGET_IMG%\"' ^
-o 'ghidra trace start' ^
-o 'ghidra trace sync-enable' ^
-o '%OPT_START_CMD%'
) ELSE (
set cmd=TERM='%TERM%' '%OPT_LLDB_PATH%' ^
-o 'version' ^
-o 'script import ghidralldb' ^
-o 'settings set target.default-arch %OPT_ARCH%' ^
-o 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
-o 'target create \"%OPT_TARGET_IMG%\"' ^
-o 'settings set target.run-args %OPT_TARGET_ARGS%' ^
-o 'ghidra trace start' ^
-o 'ghidra trace sync-enable' ^
-o '%OPT_START_CMD%'
)
"%OPT_SSH_PATH%" "-R%OPT_REMOTE_PORT%:%GHIDRA_TRACE_RMI_ADDR%" -t %OPT_EXTRA_SSH_ARGS% "%OPT_HOST%" "%cmd%"

View file

@ -0,0 +1,68 @@
#!/usr/bin/bash
## ###
# 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.
##
#@timeout 60000
#@title lldb via ssh
#@image-opt arg:1
#@desc <html><body width="300px">
#@desc <h3>Launch with <tt>lldb</tt> via <tt>ssh</tt></h3>
#@desc <p>
#@desc This will launch the target on a remote machine using <tt>lldb</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 TraceRmiLauncherServicePlugin#lldb_ssh
#@enum StartCmd:str "process launch" "process launch --stop-at-entry"
#@enum Endian:str auto big little
#@arg :str "Image" "The target binary executable image on the remote system"
#@args "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_LLDB_PATH:str="lldb" "lldb command" "The path to lldb on the remote 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."
#@env OPT_ARCH:str="x86_64" "Architecture" "Target architecture"
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_LLDB_PATH' \
-o 'version' ^
-o 'script import ghidralldb' ^
-o 'settings set target.default-arch %OPT_ARCH%' ^
-o 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
-o 'target create \"%OPT_TARGET_IMG%\"' ^
-o 'ghidra trace start' ^
-o 'ghidra trace sync-enable' ^
-o '%OPT_START_CMD%'
else
"$OPT_SSH_PATH" "-R$OPT_REMOTE_PORT:$GHIDRA_TRACE_RMI_ADDR" -t $OPT_EXTRA_SSH_ARGS "$OPT_HOST" "TERM='$TERM' '$OPT_LLDB_PATH' \
-o 'version' ^
-o 'script import ghidralldb' ^
-o 'settings set target.default-arch %OPT_ARCH%' ^
-o 'ghidra trace connect \"localhost:%OPT_REMOTE_PORT%\"' ^
-o 'target create \"%OPT_TARGET_IMG%\"' ^
-o 'settings set target.run-args %OPT_TARGET_ARGS%' ^
-o 'ghidra trace start' ^
-o 'ghidra trace sync-enable' ^
-o '%OPT_START_CMD%'
fi

View file

@ -703,6 +703,15 @@ perl -i -pe 's/(?<=pendingNMI\x00{4})\x00/\x01/' macOS_15-1234567.vmss
<LI><B><TT>lldb</TT> command</B>: This works the same as in LLDB.</LI>
</UL>
<H3><A name="lldb_ssh"></A>LLDB via SSH</H3>
<P>This works the same as the "GDB via SSH" launcher, but runs <TT>lldb</TT> on a remote system via <TT>ssh</TT>.
<H3><A name="lldb_android"></A>Android LLDB</H3>
<P>This has the same options as the "LLDB via SSH" launcher, which are necessary for connecting to the Android debugger,
but executes via the normal lldb mechanism.
<H2>Stock Windows Debugger (WinDbg) Launchers</H2>
<P>The following launchers based on Microsoft's <TT>dbgeng.dll</TT> are included out of the