-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GP-4439: Add raw-gdb.sh and raw-python.sh. Add @no-image tag.
- Loading branch information
1 parent
523f6e4
commit f9bea77
Showing
17 changed files
with
651 additions
and
333 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/raw-gdb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env 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:https://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 raw gdb | ||
#@no-image | ||
#@desc <html><body width="300px"> | ||
#@desc <h3>Start <tt>gdb</tt></h3> | ||
#@desc <p>This will start <tt>gdb</tt> and connect to it. It will not launch | ||
#@desc a target, so you can (must) set up your target manually. | ||
#@desc 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.</p> | ||
#@desc </body></html> | ||
#@menu-group raw | ||
#@icon icon.debugger | ||
#@help TraceRmiLauncherServicePlugin#gdb | ||
#@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_ARCH:str="i386:x86-64" "Architecture" "Target architecture" | ||
|
||
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 | ||
|
||
"$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 "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \ | ||
-ex "ghidra trace start" \ | ||
-ex "ghidra trace sync-enable" \ | ||
-ex "set confirm on" \ | ||
-ex "set pagination on" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Ghidra/Debug/Debugger-rmi-trace/data/debugger-launchers/raw-python3.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env 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:https://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 raw python | ||
#@no-image | ||
#@desc <html><body width="300px"> | ||
#@desc <h3>Start <tt>gdb</tt></h3> | ||
#@desc <p>This will start <tt>python</tt>, import <tt>ghidratrace</tt> and connect to it. | ||
#@desc This connector is made for those wanting to explore the TraceRMI API and possibly develop | ||
#@desc a new connector. You will need <tt>protobuf</tt> installed for Python 3.</p> | ||
#@desc </body></html> | ||
#@menu-group raw | ||
#@icon icon.debugger | ||
#@help TraceRmiLauncherServicePlugin#gdb | ||
#@env OPT_PYTHON_EXE:str="python" "Path to python" "The path to the Python 3 interpreter. Omit the full path to resolve using the system PATH." | ||
#@env OPT_LANG:str="DATA:LE:64:default" "Ghidra Language" "The Ghidra LanguageID for the trace" | ||
#@env OPT_COMP:str="pointer64" "Ghidra Compiler" "The Ghidra CompilerSpecID for the trace" | ||
|
||
if [ -d ${GHIDRA_HOME}/ghidra/.git ] | ||
then | ||
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-rmi-trace/build/pypkg/src:$PYTHONPATH | ||
else | ||
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH | ||
fi | ||
|
||
"$OPT_PYTHON_EXE" -i ../support/raw-python3.py |
36 changes: 36 additions & 0 deletions
36
Ghidra/Debug/Debugger-rmi-trace/data/support/raw-python3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## ### | ||
# 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:https://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. | ||
## | ||
from concurrent.futures import ThreadPoolExecutor | ||
import os | ||
import socket | ||
import sys | ||
|
||
from ghidratrace import * | ||
from ghidratrace.client import * | ||
|
||
|
||
REGISTRY = MethodRegistry(ThreadPoolExecutor(max_workers=1)) | ||
|
||
host = os.getenv("GHIDRA_TRACE_RMI_HOST") | ||
port = int(os.getenv("GHIDRA_TRACE_RMI_PORT")) | ||
c = socket.socket() | ||
c.connect((host, port)) | ||
client = Client( | ||
c, f"python-{sys.version_info.major}.{sys.version_info.minor}", REGISTRY) | ||
print(f"Connected to {client.description} at {host}:{port}") | ||
|
||
trace = client.create_trace("noname", os.getenv( | ||
"OPT_LANG"), os.getenv("OPT_COMP")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.