mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
ad56d6b0e7
11 changed files with 148 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
##VERSION: 2.0
|
##VERSION: 2.0
|
||||||
##MODULE IP: JSch License
|
##MODULE IP: JSch License
|
||||||
Module.manifest||GHIDRA||||END|
|
Module.manifest||GHIDRA||||END|
|
||||||
|
data/debugger-launchers/local-gdb.bat||GHIDRA||||END|
|
||||||
data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END|
|
data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END|
|
||||||
data/scripts/fallback_maintenance_info_sections.gdb||GHIDRA||||END|
|
data/scripts/fallback_maintenance_info_sections.gdb||GHIDRA||||END|
|
||||||
data/scripts/getpid-linux-i386.gdb||GHIDRA||||END|
|
data/scripts/getpid-linux-i386.gdb||GHIDRA||||END|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
::@title gdb
|
||||||
|
::@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 TraceRmiLauncherServicePlugin#gdb
|
||||||
|
::@enum StartCmd:str run start starti
|
||||||
|
::@arg :file "Image" "The target binary executable image"
|
||||||
|
::@args "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_EXTRA_TTY:bool=false "Inferior TTY" "Provide a separate terminal emulator for the target."
|
||||||
|
::@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||||
|
|
||||||
|
@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%
|
||||||
|
|
||||||
|
set target_image=%1
|
||||||
|
shift
|
||||||
|
set target_args=%*
|
||||||
|
|
||||||
|
"%OPT_GDB_PATH%" ^
|
||||||
|
-q ^
|
||||||
|
-ex "set pagination off" ^
|
||||||
|
-ex "set confirm off" ^
|
||||||
|
-ex "show version" ^
|
||||||
|
-ex "python import ghidragdb" ^
|
||||||
|
-ex "target exec %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" ^
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ data64_compiler_map = {
|
||||||
|
|
||||||
x86_compiler_map = {
|
x86_compiler_map = {
|
||||||
'GNU/Linux': 'gcc',
|
'GNU/Linux': 'gcc',
|
||||||
'Windows': 'Visual Studio',
|
'Windows': 'windows',
|
||||||
# This may seem wrong, but Ghidra cspecs really describe the ABI
|
# This may seem wrong, but Ghidra cspecs really describe the ABI
|
||||||
'Cygwin': 'Visual Studio',
|
'Cygwin': 'windows',
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler_map = {
|
compiler_map = {
|
||||||
|
|
|
@ -19,9 +19,13 @@ import os.path
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
try:
|
||||||
|
import psutil
|
||||||
|
except ImportError:
|
||||||
|
print(f"Unable to import 'psutil' - check that it has been installed")
|
||||||
|
|
||||||
from ghidratrace import sch
|
from ghidratrace import sch
|
||||||
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
||||||
import psutil
|
|
||||||
|
|
||||||
import gdb
|
import gdb
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,14 @@ class InferiorState(object):
|
||||||
if first or hashable_frame not in self.visited:
|
if first or hashable_frame not in self.visited:
|
||||||
commands.putreg(
|
commands.putreg(
|
||||||
frame, util.get_register_descs(frame.architecture(), 'general'))
|
frame, util.get_register_descs(frame.architecture(), 'general'))
|
||||||
|
try:
|
||||||
commands.putmem("$pc", "1", from_tty=False)
|
commands.putmem("$pc", "1", from_tty=False)
|
||||||
|
except MemoryError as e:
|
||||||
|
print(f"Couldn't record page with PC: {e}")
|
||||||
|
try:
|
||||||
commands.putmem("$sp", "1", from_tty=False)
|
commands.putmem("$sp", "1", from_tty=False)
|
||||||
|
except MemoryError as e:
|
||||||
|
print(f"Couldn't record page with SP: {e}")
|
||||||
self.visited.add(hashable_frame)
|
self.visited.add(hashable_frame)
|
||||||
if first or self.regions or self.threads or self.modules:
|
if first or self.regions or self.threads or self.modules:
|
||||||
# Sections, memory syscalls, or stack allocations
|
# Sections, memory syscalls, or stack allocations
|
||||||
|
|
|
@ -28,6 +28,8 @@ def _compute_gdb_ver():
|
||||||
top = blurb.split('\n')[0]
|
top = blurb.split('\n')[0]
|
||||||
full = top.split(' ')[-1]
|
full = top.split(' ')[-1]
|
||||||
major, minor = full.split('.')[:2]
|
major, minor = full.split('.')[:2]
|
||||||
|
if '-' in minor:
|
||||||
|
minor = minor[:minor.find('-')]
|
||||||
return GdbVersion(full, int(major), int(minor))
|
return GdbVersion(full, int(major), int(minor))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
##MODULE IP: Apache License 2.0 with LLVM Exceptions
|
##MODULE IP: Apache License 2.0 with LLVM Exceptions
|
||||||
Module.manifest||GHIDRA||||END|
|
Module.manifest||GHIDRA||||END|
|
||||||
build.gradle||GHIDRA||||END|
|
build.gradle||GHIDRA||||END|
|
||||||
|
data/debugger-launchers/local-lldb.bat||GHIDRA||||END|
|
||||||
src/llvm-project/lldb/bindings/java/java-typemaps.swig||Apache License 2.0 with LLVM Exceptions||||END|
|
src/llvm-project/lldb/bindings/java/java-typemaps.swig||Apache License 2.0 with LLVM Exceptions||||END|
|
||||||
src/llvm-project/lldb/bindings/java/java.swig||Apache License 2.0 with LLVM Exceptions||||END|
|
src/llvm-project/lldb/bindings/java/java.swig||Apache License 2.0 with LLVM Exceptions||||END|
|
||||||
src/main/py/LICENSE||GHIDRA||||END|
|
src/main/py/LICENSE||GHIDRA||||END|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
::@title lldb
|
||||||
|
::@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 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_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."
|
||||||
|
::@env OPT_EXTRA_TTY:bool=false "Target TTY" "Provide a separate terminal emulator for the target."
|
||||||
|
::@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||||
|
|
||||||
|
@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%
|
||||||
|
|
||||||
|
set target_image=%1
|
||||||
|
shift
|
||||||
|
set target_args=%*
|
||||||
|
|
||||||
|
IF DEFINED target_args (
|
||||||
|
argspart=-o "settings set target.run-args %target_args%"
|
||||||
|
)
|
||||||
|
|
||||||
|
IF DEFINED TARGET_TTY (
|
||||||
|
ttypart=-o "settings set target.output-path %TTY_TARGET%" -o "settings set target.input-path $TTY_TARGET"
|
||||||
|
)
|
||||||
|
|
||||||
|
"%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%"
|
|
@ -23,7 +23,10 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import psutil
|
try:
|
||||||
|
import psutil
|
||||||
|
except ImportError:
|
||||||
|
print(f"Unable to import 'psutil' - check that it has been installed")
|
||||||
|
|
||||||
from ghidratrace import sch
|
from ghidratrace import sch
|
||||||
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
package ghidra.app.plugin.core.debug.gui.tracermi.launcher;
|
package ghidra.app.plugin.core.debug.gui.tracermi.launcher;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import generic.jar.ResourceFile;
|
import generic.jar.ResourceFile;
|
||||||
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
|
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
|
||||||
|
import ghidra.framework.OperatingSystem;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
|
@ -29,11 +31,14 @@ public class BatchScriptTraceRmiLaunchOpinion extends AbstractTraceRmiLaunchOpin
|
||||||
@Override
|
@Override
|
||||||
public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
|
public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
|
||||||
Program program) {
|
Program program) {
|
||||||
|
if (OperatingSystem.CURRENT_OPERATING_SYSTEM == OperatingSystem.WINDOWS) {
|
||||||
return getScriptPaths(plugin.getTool())
|
return getScriptPaths(plugin.getTool())
|
||||||
.flatMap(rf -> Stream.of(rf.listFiles(crf -> crf.getName().endsWith(".bat"))))
|
.flatMap(rf -> Stream.of(rf.listFiles(crf -> crf.getName().endsWith(".bat"))))
|
||||||
.flatMap(sf -> createOffer(plugin, program, sf))
|
.flatMap(sf -> createOffer(plugin, program, sf))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
protected Stream<TraceRmiLaunchOffer> createOffer(TraceRmiLauncherServicePlugin plugin,
|
protected Stream<TraceRmiLaunchOffer> createOffer(TraceRmiLauncherServicePlugin plugin,
|
||||||
Program program, ResourceFile scriptFile) {
|
Program program, ResourceFile scriptFile) {
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
package ghidra.app.plugin.core.debug.gui.tracermi.launcher;
|
package ghidra.app.plugin.core.debug.gui.tracermi.launcher;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import generic.jar.ResourceFile;
|
import generic.jar.ResourceFile;
|
||||||
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
|
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
|
||||||
|
import ghidra.framework.OperatingSystem;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
|
@ -29,11 +31,14 @@ public class UnixShellScriptTraceRmiLaunchOpinion extends AbstractTraceRmiLaunch
|
||||||
@Override
|
@Override
|
||||||
public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
|
public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
|
||||||
Program program) {
|
Program program) {
|
||||||
|
if (OperatingSystem.CURRENT_OPERATING_SYSTEM != OperatingSystem.WINDOWS) {
|
||||||
return getScriptPaths(plugin.getTool())
|
return getScriptPaths(plugin.getTool())
|
||||||
.flatMap(rf -> Stream.of(rf.listFiles(crf -> crf.getName().endsWith(".sh"))))
|
.flatMap(rf -> Stream.of(rf.listFiles(crf -> crf.getName().endsWith(".sh"))))
|
||||||
.flatMap(sf -> createOffer(plugin, program, sf))
|
.flatMap(sf -> createOffer(plugin, program, sf))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
protected Stream<TraceRmiLaunchOffer> createOffer(TraceRmiLauncherServicePlugin plugin,
|
protected Stream<TraceRmiLaunchOffer> createOffer(TraceRmiLauncherServicePlugin plugin,
|
||||||
Program program, ResourceFile scriptFile) {
|
Program program, ResourceFile scriptFile) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue