mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-3818: Create TraceRMI launcher framework. Launch script for gdb.
This commit is contained in:
parent
4561e8335d
commit
eea90f49c9
379 changed files with 5180 additions and 1487 deletions
58
Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh
Executable file
58
Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/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.
|
||||
##
|
||||
#@title gdb
|
||||
#@desc <html><body width="300px">
|
||||
#@desc <h3>Launch with <tt>gdb</tt></h3>
|
||||
#@desc <p>This will launch the target on the local machine using <tt>gdb</tt>. GDB must already
|
||||
#@desc be installed on your system, and it must embed the Python 3 interpreter. You will also
|
||||
#@desc need <tt>protobuf</tt> and <tt>psutil</tt> installed for Python 3.
|
||||
#@desc </body></html>
|
||||
#@menu-group local
|
||||
#@icon icon.debugger
|
||||
#@help TraceRmiLauncherServicePlugin#gdb
|
||||
#@enum StartCmd:str run start starti
|
||||
#@env OPT_GDB_PATH:str="gdb" "Path to gdb" "The path to gdb. Omit the full path to resolve using the system PATH."
|
||||
#@env OPT_START_CMD:StartCmd="start" "Run command" "The gdb command to actually run the target."
|
||||
#@arg :str "Image" "The target binary executable image"
|
||||
#@args "Arguments" "Command-line arguments to pass to the target"
|
||||
#@tty TTY_TARGET
|
||||
|
||||
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||
then
|
||||
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$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:$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
else
|
||||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||
fi
|
||||
|
||||
target_image="$1"
|
||||
shift
|
||||
target_args="$@"
|
||||
|
||||
"$OPT_GDB_PATH" \
|
||||
-ex "set pagination off" \
|
||||
-ex "python import ghidragdb" \
|
||||
-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 pagination on"
|
|
@ -24,7 +24,7 @@ class GhidraHookPrefix(gdb.Command):
|
|||
"""Commands for exporting data to a Ghidra trace"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('ghidra-hook', gdb.COMMAND_NONE, prefix=True)
|
||||
super().__init__('hooks-ghidra', gdb.COMMAND_NONE, prefix=True)
|
||||
|
||||
|
||||
GhidraHookPrefix()
|
||||
|
@ -386,7 +386,7 @@ def on_before_prompt():
|
|||
# This will be called by a catchpoint
|
||||
class GhidraTraceEventMemoryCommand(gdb.Command):
|
||||
def __init__(self):
|
||||
super().__init__('ghidra-hook event-memory', gdb.COMMAND_NONE)
|
||||
super().__init__('hooks-ghidra event-memory', gdb.COMMAND_NONE)
|
||||
|
||||
def invoke(self, argument, from_tty):
|
||||
self.dont_repeat()
|
||||
|
@ -401,10 +401,10 @@ def cmd_hook(name):
|
|||
class _ActiveCommand(gdb.Command):
|
||||
def __init__(self):
|
||||
# It seems we can't hook commands using the Python API....
|
||||
super().__init__(f"ghidra-hook def-{name}", gdb.COMMAND_USER)
|
||||
super().__init__(f"hooks-ghidra def-{name}", gdb.COMMAND_USER)
|
||||
gdb.execute(f"""
|
||||
define {name}
|
||||
ghidra-hook def-{name}
|
||||
hooks-ghidra def-{name}
|
||||
end
|
||||
""")
|
||||
|
||||
|
@ -474,7 +474,7 @@ def install_hooks():
|
|||
catch syscall group:memory
|
||||
commands
|
||||
silent
|
||||
ghidra-hook event-memory
|
||||
hooks-ghidra event-memory
|
||||
cont
|
||||
end
|
||||
""")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue