Compare commits

...

11 Commits

Author SHA1 Message Date
Ole André Vadla Ravnås 86d4b4b4bf subprojects: Prepare for release 2026-03-27 11:36:40 +01:00
Ole André Vadla Ravnås b5808d7b27 subprojects: Bump outdated 2026-03-27 11:35:06 +01:00
Ole André Vadla Ravnås 5466050755 subprojects: Prepare for release 2026-03-26 20:43:48 +01:00
Ole André Vadla Ravnås 4db854a02c subprojects: Bump outdated 2026-03-26 20:42:58 +01:00
Ole André Vadla Ravnås cc9a78ef19 device: Add override_option()
Expose Device.override_option() for overriding backend-specific
options on a device.

Overrides apply when establishing a host session. If one already
exists, changes take effect on the next connection.
2026-03-26 20:30:10 +01:00
Ole André Vadla Ravnås 22ed1fac3c examples: Add a spawn gating example 2026-03-26 15:27:31 +01:00
Ole André Vadla Ravnås 9b15bde24e examples: Fix the child gating example 2026-03-25 21:04:14 +01:00
Ole André Vadla Ravnås a613d87b08 subprojects: Prepare for release 2026-03-24 15:40:55 +01:00
Ole André Vadla Ravnås 9ef240eff4 subprojects: Bump outdated 2026-03-24 15:39:30 +01:00
Ole André Vadla Ravnås 43a443f582 subprojects: Prepare for release 2026-03-14 11:52:06 +01:00
Ole André Vadla Ravnås dcc95216fd subprojects: Bump outdated 2026-03-14 11:51:33 +01:00
5 changed files with 121 additions and 4 deletions
+3 -3
View File
@@ -44,11 +44,11 @@ class Application:
print("✔ create_script()")
script = session.create_script(
"""\
Interceptor.attach(Module.getExportByName(null, 'open'), {
onEnter: function (args) {
Interceptor.attach(Module.getGlobalExportByName('open'), {
onEnter(args) {
send({
type: 'open',
path: Memory.readUtf8String(args[0])
path: args[0].readUtf8String()
});
}
});
+80
View File
@@ -0,0 +1,80 @@
import threading
from frida_tools.application import Reactor
import frida
class Application:
def __init__(self):
self._stop_requested = threading.Event()
self._reactor = Reactor(run_until_return=lambda reactor: self._stop_requested.wait())
self._device = frida.get_usb_device()
self._sessions = set()
self._sessions_lock = threading.Lock()
self._device.on("spawn-added", lambda spawn: self._reactor.schedule(lambda: self._on_spawn_added(spawn)))
self._device.on("spawn-removed", lambda spawn: self._reactor.schedule(lambda: self._on_spawn_removed(spawn)))
def run(self):
self._reactor.schedule(lambda: self._start())
self._reactor.run()
def _start(self):
self._device.enable_spawn_gating()
def _instrument(self, pid):
print(f"✔ attach(pid={pid})")
session = self._device.attach(pid)
session.on("detached", lambda reason: self._reactor.schedule(lambda: self._on_detached(pid, session, reason)))
print("✔ create_script()")
script = session.create_script(
"""\
const puts = new NativeFunction(Module.getGlobalExportByName('puts'), 'int', ['pointer']);
puts(Memory.allocUtf8String('Hello from Frida agent'));
Interceptor.attach(Module.getGlobalExportByName('open'), {
onEnter(args) {
send({
type: 'open',
path: args[0].readUtf8String()
});
}
});
"""
)
script.on("message", lambda message, data: self._reactor.schedule(lambda: self._on_message(pid, message)))
print("✔ load()")
script.load()
print(f"✔ resume(pid={pid})")
self._device.resume(pid)
with self._sessions_lock:
self._sessions.add(session)
def _on_spawn_added(self, spawn):
print(f"⚡ spawn_added: {spawn}")
t = threading.Thread(target=self._handle_spawn, args=(spawn,))
t.start()
def _handle_spawn(self, spawn):
if "/bin/ls" in spawn.identifier:
self._instrument(spawn.pid)
else:
pid = spawn.pid
print(f"✔ resume(pid={pid})")
self._device.resume(pid)
def _on_spawn_removed(self, spawn):
print(f"⚡ spawn_removed: {spawn}")
def _on_detached(self, pid, session, reason):
print(f"⚡ detached: pid={pid}, reason='{reason}'")
with self._sessions_lock:
self._sessions.remove(session)
def _on_message(self, pid, message):
print(f"⚡ message: pid={pid}, payload={message['payload']}")
app = Application()
app.run()
+29
View File
@@ -404,6 +404,7 @@ static void PyDevice_init_from_handle (PyDevice * self, FridaDevice * handle);
static void PyDevice_dealloc (PyDevice * self);
static PyObject * PyDevice_repr (PyDevice * self);
static PyObject * PyDevice_is_lost (PyDevice * self);
static PyObject * PyDevice_override_option (PyDevice * self, PyObject * args, PyObject * kw);
static PyObject * PyDevice_query_system_parameters (PyDevice * self);
static PyObject * PyDevice_get_frontmost_application (PyDevice * self, PyObject * args, PyObject * kw);
static PyObject * PyDevice_enumerate_applications (PyDevice * self, PyObject * args, PyObject * kw);
@@ -620,6 +621,7 @@ static PyMethodDef PyDeviceManager_methods[] =
static PyMethodDef PyDevice_methods[] =
{
{ "is_lost", (PyCFunction) PyDevice_is_lost, METH_NOARGS, "Query whether the device has been lost." },
{ "override_option", (PyCFunction) PyDevice_override_option, METH_VARARGS | METH_KEYWORDS, "Override a backend-specific option." },
{ "query_system_parameters", (PyCFunction) PyDevice_query_system_parameters, METH_NOARGS, "Returns a dictionary of information about the host system." },
{ "get_frontmost_application", (PyCFunction) PyDevice_get_frontmost_application, METH_VARARGS | METH_KEYWORDS, "Get details about the frontmost application." },
{ "enumerate_applications", (PyCFunction) PyDevice_enumerate_applications, METH_VARARGS | METH_KEYWORDS, "Enumerate applications." },
@@ -2521,6 +2523,33 @@ PyDevice_is_lost (PyDevice * self)
return PyBool_FromLong (is_lost);
}
static PyObject *
PyDevice_override_option (PyDevice * self, PyObject * args, PyObject * kw)
{
static char * keywords[] = { "name", "value", NULL };
const char * name;
PyObject * value;
GVariant * raw_value;
GError * error = NULL;
if (!PyArg_ParseTupleAndKeywords (args, kw, "sO", keywords, &name, &value))
return NULL;
if (!PyGObject_unmarshal_variant (value, &raw_value))
return NULL;
Py_BEGIN_ALLOW_THREADS
frida_device_override_option (PY_GOBJECT_HANDLE (self), name, raw_value, &error);
Py_END_ALLOW_THREADS
g_variant_unref (raw_value);
if (error != NULL)
return PyFrida_raise (error);
PyFrida_RETURN_NONE;
}
static PyObject *
PyDevice_query_system_parameters (PyDevice * self)
{
+8
View File
@@ -883,6 +883,14 @@ class Device:
return self._impl.is_lost()
@cancellable
def override_option(self, name: str, value: Any) -> None:
"""
Override a backend-specific option
"""
self._impl.override_option(name, value)
@cancellable
def query_system_parameters(self) -> Dict[str, Any]:
"""
+1 -1
View File
@@ -1,6 +1,6 @@
[wrap-git]
url = https://github.com/frida/frida-core.git
revision = 17.8.1
revision = 17.9.1
depth = 1
[provide]