mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-2623: Improve connect dialog and factory descriptions
This commit is contained in:
@@ -21,17 +21,14 @@ import agent.frida.model.impl.FridaModelImpl;
|
||||
import ghidra.dbg.DebuggerModelFactory;
|
||||
import ghidra.dbg.DebuggerObjectModel;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.util.classfinder.ExtensionPointProperties;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
/**
|
||||
* Note this is in the testing source because it's not meant to be shipped in the release.... That
|
||||
* may change if it proves stable, though, no?
|
||||
*/
|
||||
@FactoryDescription( //
|
||||
brief = "IN-VM Frida local debugger", //
|
||||
htmlDetails = "Launch a Frida session in this same JVM" //
|
||||
)
|
||||
@ExtensionPointProperties(priority = 80)
|
||||
@FactoryDescription(
|
||||
brief = "PROTOTYPE: Frida",
|
||||
htmlDetails = """
|
||||
Connect to Frida.
|
||||
This is an experimental connector. Use at your own risk.
|
||||
This will access the native API, which may put Ghidra's JVM at risk.""")
|
||||
public class FridaInJvmDebuggerModelFactory implements DebuggerModelFactory {
|
||||
|
||||
@Override
|
||||
@@ -41,9 +38,18 @@ public class FridaInJvmDebuggerModelFactory implements DebuggerModelFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible() {
|
||||
String osname = System.getProperty("os.name");
|
||||
return osname.contains("Mac OS X") || osname.contains("Linux") || osname.contains("Windows");
|
||||
public int getPriority(Program program) {
|
||||
String osname = System.getProperty("os.name").toLowerCase();
|
||||
if (!(osname.contains("mac os x") || osname.contains("linux") ||
|
||||
osname.contains("windows"))) {
|
||||
return -1;
|
||||
}
|
||||
if (program != null) {
|
||||
String exe = program.getExecutablePath();
|
||||
if (exe == null || exe.isBlank()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/* ###
|
||||
* 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.
|
||||
*/
|
||||
package agent.frida.gadp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.dbg.gadp.server.AbstractGadpLocalDebuggerModelFactory;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
@FactoryDescription(
|
||||
brief = "PROTOTYPE: Frida via GADP",
|
||||
htmlDetails = """
|
||||
Connect to Frida.
|
||||
This is an experimental connector. Use at your own risk.
|
||||
This will protect Ghidra's JVM by using a subprocess to access the native API.""")
|
||||
public class FridaGadpDebuggerModelFactory extends AbstractGadpLocalDebuggerModelFactory {
|
||||
|
||||
@Override
|
||||
public int getPriority(Program program) {
|
||||
String osname = System.getProperty("os.name").toLowerCase();
|
||||
if (!(osname.contains("mac os x") || osname.contains("linux") ||
|
||||
osname.contains("windows"))) {
|
||||
return -1;
|
||||
}
|
||||
if (program != null) {
|
||||
String exe = program.getExecutablePath();
|
||||
if (exe == null || exe.isBlank()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getThreadName() {
|
||||
return "Local Frida Agent stdout";
|
||||
}
|
||||
|
||||
protected Class<?> getServerClass() {
|
||||
return FridaGadpServer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeCommandLine(List<String> cmd) {
|
||||
cmd.add(getServerClass().getCanonicalName());
|
||||
cmd.addAll(List.of("-H", host));
|
||||
cmd.addAll(List.of("-p", Integer.toString(port)));
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/* ###
|
||||
* 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.
|
||||
*/
|
||||
package agent.frida.gadp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.dbg.gadp.server.AbstractGadpLocalDebuggerModelFactory;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.util.classfinder.ExtensionPointProperties;
|
||||
|
||||
@FactoryDescription( //
|
||||
brief = "Frida local agent via GADP/TCP", //
|
||||
htmlDetails = "Launch a new agent using Frida." //
|
||||
)
|
||||
@ExtensionPointProperties(priority = 100)
|
||||
public class FridaLocalDebuggerModelFactory extends AbstractGadpLocalDebuggerModelFactory {
|
||||
|
||||
protected String remote = "none"; // Require user to start server
|
||||
@FactoryOption("DebugConnect options (.server)")
|
||||
public final Property<String> agentRemoteOption =
|
||||
Property.fromAccessors(String.class, this::getAgentRemote, this::setAgentRemote);
|
||||
|
||||
protected String transport = "none"; // Require user to start server
|
||||
@FactoryOption("Remote process server options (untested)")
|
||||
public final Property<String> agentTransportOption =
|
||||
Property.fromAccessors(String.class, this::getAgentTransport, this::setAgentTransport);
|
||||
|
||||
@Override
|
||||
public boolean isCompatible() {
|
||||
String osname = System.getProperty("os.name");
|
||||
return osname.contains("Mac OS X") || osname.contains("Linux") || osname.contains("Windows");
|
||||
}
|
||||
|
||||
public String getAgentTransport() {
|
||||
return transport;
|
||||
}
|
||||
|
||||
public void setAgentTransport(String transport) {
|
||||
this.transport = transport;
|
||||
}
|
||||
|
||||
public String getAgentRemote() {
|
||||
return remote;
|
||||
}
|
||||
|
||||
public void setAgentRemote(String remote) {
|
||||
this.remote = remote;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getThreadName() {
|
||||
return "Local Frida Agent stdout";
|
||||
}
|
||||
|
||||
protected Class<?> getServerClass() {
|
||||
return FridaGadpServer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeCommandLine(List<String> cmd) {
|
||||
cmd.add(getServerClass().getCanonicalName());
|
||||
cmd.addAll(List.of("-H", host));
|
||||
cmd.addAll(List.of("-p", Integer.toString(port)));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ package agent.frida.model.gadp;
|
||||
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
import agent.frida.gadp.FridaLocalDebuggerModelFactory;
|
||||
import agent.frida.gadp.FridaGadpDebuggerModelFactory;
|
||||
import agent.frida.model.AbstractFridaModelHost;
|
||||
import ghidra.dbg.DebuggerModelFactory;
|
||||
import ghidra.util.SystemUtilities;
|
||||
@@ -26,6 +26,6 @@ class GadpFridaModelHost extends AbstractFridaModelHost {
|
||||
@Override
|
||||
public DebuggerModelFactory getModelFactory() {
|
||||
assumeFalse("Not ready for CI", SystemUtilities.isInTestingBatchMode());
|
||||
return new FridaLocalDebuggerModelFactory();
|
||||
return new FridaGadpDebuggerModelFactory();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user