mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-781_jpleasu_scriptPath_parser--SQUASHED' into patch
This commit is contained in:
commit
0429e754c8
2 changed files with 27 additions and 12 deletions
|
@ -293,9 +293,10 @@ public class HeadlessAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GhidraScriptUtil.initialize(new BundleHost(), options.scriptPaths);
|
List<String> parsedScriptPaths = parseScriptPaths(options.scriptPaths);
|
||||||
|
GhidraScriptUtil.initialize(new BundleHost(), parsedScriptPaths);
|
||||||
try {
|
try {
|
||||||
initializeScriptPaths();
|
showConfiguredScriptPaths();
|
||||||
compileScripts();
|
compileScripts();
|
||||||
|
|
||||||
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
||||||
|
@ -400,9 +401,10 @@ public class HeadlessAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GhidraScriptUtil.initialize(new BundleHost(), options.scriptPaths);
|
List<String> parsedScriptPaths = parseScriptPaths(options.scriptPaths);
|
||||||
|
GhidraScriptUtil.initialize(new BundleHost(), parsedScriptPaths);
|
||||||
try {
|
try {
|
||||||
initializeScriptPaths();
|
showConfiguredScriptPaths();
|
||||||
compileScripts();
|
compileScripts();
|
||||||
|
|
||||||
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
Msg.info(HeadlessAnalyzer.class, "HEADLESS: execution starts");
|
||||||
|
@ -668,10 +670,23 @@ public class HeadlessAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private List<String> parseScriptPaths(List<String> scriptPaths) {
|
||||||
* Gather paths where scripts may be found.
|
List<String> parsedScriptPaths = new ArrayList<>();
|
||||||
*/
|
for (String path : scriptPaths) {
|
||||||
private void initializeScriptPaths() {
|
ResourceFile pathFile = Path.fromPathString(path);
|
||||||
|
String absPath = pathFile.getAbsolutePath();
|
||||||
|
if (pathFile.exists()) {
|
||||||
|
parsedScriptPaths.add(absPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Msg.warn(this, "REPORT: Could not find -scriptPath entry, skipping: " + absPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parsedScriptPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showConfiguredScriptPaths() {
|
||||||
StringBuffer buf = new StringBuffer("HEADLESS Script Paths:");
|
StringBuffer buf = new StringBuffer("HEADLESS Script Paths:");
|
||||||
for (ResourceFile dir : GhidraScriptUtil.getScriptSourceDirectories()) {
|
for (ResourceFile dir : GhidraScriptUtil.getScriptSourceDirectories()) {
|
||||||
buf.append("\n ");
|
buf.append("\n ");
|
||||||
|
@ -856,8 +871,8 @@ public class HeadlessAnalyzer {
|
||||||
Class<?> c = Class.forName(className, true, classLoaderForDotClassScripts);
|
Class<?> c = Class.forName(className, true, classLoaderForDotClassScripts);
|
||||||
|
|
||||||
// Get parent folder to pass to GhidraScript
|
// Get parent folder to pass to GhidraScript
|
||||||
File parentFile = new File(
|
File parentFile = new File(c.getResource(c.getSimpleName() + ".class").toURI())
|
||||||
c.getResource(c.getSimpleName() + ".class").toURI()).getParentFile();
|
.getParentFile();
|
||||||
|
|
||||||
currScript = (GhidraScript) c.getConstructor().newInstance();
|
currScript = (GhidraScript) c.getConstructor().newInstance();
|
||||||
currScript.setScriptArgs(scriptArgs);
|
currScript.setScriptArgs(scriptArgs);
|
||||||
|
|
|
@ -313,7 +313,7 @@ The Headless Analyzer uses the command-line parameters discussed below. See <a h
|
||||||
<LI>
|
<LI>
|
||||||
<a name="scriptPath"><typewriter>-scriptPath "<path1>[;<path2>...]"</typewriter></a>
|
<a name="scriptPath"><typewriter>-scriptPath "<path1>[;<path2>...]"</typewriter></a>
|
||||||
<br>Specifies the search path(s) for scripts, including secondary scripts (a script invoked from
|
<br>Specifies the search path(s) for scripts, including secondary scripts (a script invoked from
|
||||||
another script). A path may start with <typewriter>$GHIDRA_SCRIPT</typewriter>, which corresponds
|
another script). A path may start with <typewriter>$GHIDRA_HOME</typewriter>, which corresponds
|
||||||
to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which corresponds
|
to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which corresponds
|
||||||
to the user's home directory. On Unix systems, these home variables must be escaped using a
|
to the user's home directory. On Unix systems, these home variables must be escaped using a
|
||||||
'<typewriter>\</typewriter>' (backslash) character.
|
'<typewriter>\</typewriter>' (backslash) character.
|
||||||
|
@ -344,7 +344,7 @@ The Headless Analyzer uses the command-line parameters discussed below. See <a h
|
||||||
<LI>
|
<LI>
|
||||||
<a name="propertiesPath"><typewriter>-propertiesPath "<path1>[;<path2>…]"</typewriter></a>
|
<a name="propertiesPath"><typewriter>-propertiesPath "<path1>[;<path2>…]"</typewriter></a>
|
||||||
<br>Specifies path(s) that contain <typewriter>.properties</typewriter> files used by scripts or
|
<br>Specifies path(s) that contain <typewriter>.properties</typewriter> files used by scripts or
|
||||||
secondary/subscripts. A path may start with <typewriter>$GHIDRA_SCRIPT</typewriter>, which
|
secondary/subscripts. A path may start with <typewriter>$GHIDRA_HOME</typewriter>, which
|
||||||
corresponds to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which
|
corresponds to the Ghidra installation directory, or <typewriter>$USER_HOME</typewriter>, which
|
||||||
corresponds to the user's home directory. On Unix systems these home variables must be
|
corresponds to the user's home directory. On Unix systems these home variables must be
|
||||||
escaped with a '\' character.
|
escaped with a '\' character.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue