Skip to content

Commit 8441563

Browse files
committed
Merge remote-tracking branch
'origin/GP-5538_Dan_addImageFieldToRemotes--SQUASHED' (Closes NationalSecurityAgency#7955)
2 parents ba0fb6a + b7570e1 commit 8441563

File tree

22 files changed

+339
-169
lines changed

22 files changed

+339
-169
lines changed

Ghidra/Debug/Debugger-agent-gdb/certification.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Module.manifest||GHIDRA||||END|
44
README.md||GHIDRA||||END|
55
data/debugger-launchers/local-gdb.bat||GHIDRA||||END|
66
data/debugger-launchers/qemu-sys-gdb.bat||GHIDRA||||END|
7-
data/debugger-launchers/remote-gdb.bat||GHIDRA||||END|
7+
data/debugger-launchers/remote-gdb.ps1||GHIDRA||||END|
88
data/debugger-launchers/ssh-gdb.bat||GHIDRA||||END|
99
data/debugger-launchers/ssh-gdbserver.bat||GHIDRA||||END|
1010
data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END|

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-rr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-gdb.sh

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#
@@ -66,32 +66,27 @@ fi
6666
# Give QEMU a moment to open the socket
6767
sleep 0.1
6868

69-
gdb_args=(
70-
-q
71-
-ex "set pagination off"
72-
-ex "set confirm off"
73-
-ex "show version"
74-
-ex "python import ghidragdb"
75-
-ex "set architecture $OPT_ARCH"
76-
-ex "set endian $OPT_ENDIAN"
77-
-ex "file \"$target_image\""
78-
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\""
79-
-ex "ghidra trace start"
80-
-ex "ghidra trace sync-enable"
81-
-ex "target remote localhost:$QEMU_GDB"
82-
-ex "set confirm on"
83-
-ex "set pagination on"
84-
)
69+
declare -a args
8570

86-
# If using OPT_PULL_ALL_SECTIONS, append instructions to push all sections from qemu
71+
args+=(-q)
72+
args+=(-ex "set pagination off")
73+
args+=(-ex "set confirm off")
74+
args+=(-ex "show version")
75+
args+=(-ex "python import ghidragdb")
76+
args+=(-ex "set architecture $OPT_ARCH")
77+
args+=(-ex "set endian $OPT_ENDIAN")
78+
args+=(-ex "file '$target_image'")
79+
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
80+
args+=(-ex "ghidra trace start")
81+
args+=(-ex "ghidra trace sync-enable")
82+
args+=(-ex "target remote localhost:$QEMU_GDB")
8783
if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]
8884
then
89-
gdb_args+=(
90-
-ex "ghidra trace tx-start put-all-sections"
91-
-ex "ghidra trace put-sections -all-objects"
92-
-ex "ghidra trace tx-commit"
93-
)
85+
args+=(-ex "ghidra trace tx-start put-all-sections")
86+
args+=(-ex "ghidra trace put-sections -all-objects")
87+
args+=(-ex "ghidra trace tx-commit")
9488
fi
89+
args+=(-ex "set confirm on")
90+
args+=(-ex "set pagination on")
9591

96-
IFS=""
97-
"$OPT_GDB_PATH" ${gdb_args[*]}
92+
"$OPT_GDB_PATH" "${args[@]}"

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-sys-gdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.bat

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#@title remote gdb
2+
#@image-opt arg:1
3+
#@desc <html><body width="300px">
4+
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
5+
#@desc <p>
6+
#@desc This will start <tt>gdb</tt> on the local system and then use it to connect to the remote system.
7+
#@desc For setup instructions, press <b>F1</b>.
8+
#@desc </p>
9+
#@desc </body></html>
10+
#@menu-group remote
11+
#@icon icon.debugger
12+
#@help gdb#remote
13+
#@enum TargetType:str remote extended-remote
14+
#@enum Endian:str auto big little
15+
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
16+
#@env OPT_TARGET_TYPE:TargetType="remote" "Target" "The type of remote target"
17+
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
18+
#@env OPT_PORT:int=9999 "Port" "The host's listening port"
19+
#@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."
20+
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture override"
21+
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
22+
23+
[IO.DirectoryInfo] $repo = "$Env:GHIDRA_HOME\.git"
24+
[IO.DirectoryInfo] $repoParent = "$Env:GHIDRA_HOME\ghidra\.git"
25+
if ($repo.Exists) {
26+
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
27+
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
28+
}
29+
elseif ($repoParent.Exists) {
30+
$pypathGdb = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
31+
$pypathTrace = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
32+
}
33+
else {
34+
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\pypkg\src"
35+
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\pypkg\src"
36+
}
37+
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
38+
39+
$arglist = @()
40+
41+
$arglist+=("-q")
42+
$arglist+=("-ex", "`"set pagination off`"")
43+
$arglist+=("-ex", "`"set confirm off`"")
44+
$arglist+=("-ex", "`"show version`"")
45+
$arglist+=("-ex", "`"python import ghidragdb`"")
46+
$arglist+=("-ex", "`"set architecture $Env:OPT_ARCH`"")
47+
$arglist+=("-ex", "`"set endian $Env:OPT_ENDIAN`"")
48+
if ("$($args[0])" -ne "") {
49+
$image = $args[0] -replace "\\", "\\\\"
50+
$arglist+=("-ex", "`"file '$image'`"")
51+
}
52+
$arglist+=("-ex", "`"echo Connecting to $Env:OPT_HOST`:$Env:OPT_PORT... `"")
53+
$arglist+=("-ex", "`"target $Env:OPT_TARGET_TYPE $Env:OPT_HOST`:$Env:OPT_PORT`"")
54+
$arglist+=("-ex", "`"ghidra trace connect '$Env:GHIDRA_TRACE_RMI_ADDR'`"")
55+
$arglist+=("-ex", "`"ghidra trace start`"")
56+
$arglist+=("-ex", "`"ghidra trace sync-enable`"")
57+
$arglist+=("-ex", "`"ghidra trace sync-synth-stopped`"")
58+
$arglist+=("-ex", "`"set confirm on`"")
59+
$arglist+=("-ex", "`"set pagination on`"")
60+
61+
Start-Process -FilePath $Env:OPT_GDB_PATH -ArgumentList $arglist -NoNewWindow -Wait

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.sh

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616
##
1717
#@title remote gdb
18+
#@image-opt arg:1
1819
#@desc <html><body width="300px">
1920
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
2021
#@desc <p>
@@ -27,6 +28,7 @@
2728
#@help gdb#remote
2829
#@enum TargetType:str remote extended-remote
2930
#@enum Endian:str auto big little
31+
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
3032
#@env OPT_TARGET_TYPE:TargetType="remote" "Target" "The type of remote target"
3133
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
3234
#@env OPT_PORT:int=9999 "Port" "The host's listening port"
@@ -47,19 +49,26 @@ else
4749
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
4850
fi
4951

50-
"$OPT_GDB_PATH" \
51-
-q \
52-
-ex "set pagination off" \
53-
-ex "set confirm off" \
54-
-ex "show version" \
55-
-ex "python import ghidragdb" \
56-
-ex "set architecture $OPT_ARCH" \
57-
-ex "set endian $OPT_ENDIAN" \
58-
-ex "echo Connecting to $OPT_HOST:$OPT_PORT... " \
59-
-ex "target $OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT" \
60-
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
61-
-ex "ghidra trace start" \
62-
-ex "ghidra trace sync-enable" \
63-
-ex "ghidra trace sync-synth-stopped" \
64-
-ex "set confirm on" \
65-
-ex "set pagination on"
52+
declare -a args
53+
54+
args+=(-q)
55+
args+=(-ex "set pagination off")
56+
args+=(-ex "set confirmation off")
57+
args+=(-ex "show version")
58+
args+=(-ex "python import ghidragdb")
59+
args+=(-ex "set architecture $OPT_ARCH")
60+
args+=(-ex "set endian $OPT_ENDIAN")
61+
if [ -n "$1" ]
62+
then
63+
args+=(-ex "file '$1'")
64+
fi
65+
args+=(-ex "echo Connecting to $OPT_HOST:$OPT_PORT...")
66+
args+=(-ex "target $OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT")
67+
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
68+
args+=(-ex "ghidra trace start")
69+
args+=(-ex "ghidra trace sync-enable")
70+
args+=(-ex "ghidra trace sync-synth-stopped")
71+
args+=(-ex "set confirm on")
72+
args+=(-ex "set pagination on")
73+
74+
"$OPT_GDB_PATH" "${args[@]}"

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#

Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdbserver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22
## ###
33
# IP: GHIDRA
44
#

0 commit comments

Comments
 (0)