mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Compare commits
103 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dbe7868509 | |||
| a0867d30b9 | |||
| 0666e8d33c | |||
| 60c30102bf | |||
| d50d5cc6d0 | |||
| ddeaad5254 | |||
| c68cd908d3 | |||
| 5b6d9f378a | |||
| 0839e57d3b | |||
| 5215b5b2c8 | |||
| 54dca1d5da | |||
| 8eafeb24d9 | |||
| 1b75d93858 | |||
| c2145f3589 | |||
| 0a9995df51 | |||
| 0f3ffd4032 | |||
| 2da64cb7ca | |||
| f81c3183a1 | |||
| d2861db65b | |||
| 06210bec40 | |||
| 4934e18a0e | |||
| fe987827e9 | |||
| 0ef38236e8 | |||
| 0fab765f91 | |||
| a6c02cb7ee | |||
| 6033dd0904 | |||
| 77e94e24a1 | |||
| c97343dc83 | |||
| e1ffe5fd50 | |||
| c7314098c6 | |||
| 41d769fa4d | |||
| 044d23eef7 | |||
| 1641af6ca3 | |||
| e513eca572 | |||
| 15260bfa4a | |||
| dec8aca9ae | |||
| 8c69b9d032 | |||
| f57b0c1cfa | |||
| fd2c1f2424 | |||
| a9caf62a0c | |||
| 8bc4415f34 | |||
| e3eca3179c | |||
| ef190d9957 | |||
| 1e06ebe9a3 | |||
| 925378439c | |||
| 7ae323a3cd | |||
| 9c5985c254 | |||
| b469134be4 | |||
| 9933d916ae | |||
| 09cac4e2a5 | |||
| 6b49e14ce1 | |||
| 7711fa12ac | |||
| d468dc038c | |||
| 58ff000596 | |||
| 3652e985d8 | |||
| 210c56e1b2 | |||
| b3d6aa8ffe | |||
| 16eb645844 | |||
| b7b1fcf0ff | |||
| 978b756134 | |||
| 7b1fc43a42 | |||
| 244cf6926b | |||
| 24b941fb8a | |||
| e2b340eda1 | |||
| 2b306c6d30 | |||
| 57cee13b43 | |||
| 23aa442826 | |||
| 65236f3b05 | |||
| e52e7a95bd | |||
| 3b57222cfa | |||
| 319ac9e699 | |||
| 2e842a4e44 | |||
| f9bf571497 | |||
| 8f50f743e1 | |||
| 6da337df6f | |||
| e29d41806c | |||
| 8faf01dc2e | |||
| 4286667bc6 | |||
| 86d4b4b4bf | |||
| b5808d7b27 | |||
| 5466050755 | |||
| 4db854a02c | |||
| cc9a78ef19 | |||
| 22ed1fac3c | |||
| 9b15bde24e | |||
| a613d87b08 | |||
| 9ef240eff4 | |||
| 43a443f582 | |||
| dcc95216fd | |||
| 69e7c6c0ce | |||
| 3278173be8 | |||
| d8fa422062 | |||
| 3943d2eed2 | |||
| 8030b5aa68 | |||
| fa5f378176 | |||
| a814a4aa9b | |||
| a48ff22b6f | |||
| eb4f8d37f3 | |||
| 60a4a032d6 | |||
| 9f46dfaa80 | |||
| e57ca181f8 | |||
| 0fccd75bc7 | |||
| dea4ffb1c9 |
@@ -42,18 +42,16 @@ class Application:
|
|||||||
print("✔ enable_child_gating()")
|
print("✔ enable_child_gating()")
|
||||||
session.enable_child_gating()
|
session.enable_child_gating()
|
||||||
print("✔ create_script()")
|
print("✔ create_script()")
|
||||||
script = session.create_script(
|
script = session.create_script("""\
|
||||||
"""\
|
Interceptor.attach(Module.getGlobalExportByName('open'), {
|
||||||
Interceptor.attach(Module.getExportByName(null, 'open'), {
|
onEnter(args) {
|
||||||
onEnter: function (args) {
|
|
||||||
send({
|
send({
|
||||||
type: 'open',
|
type: 'open',
|
||||||
path: Memory.readUtf8String(args[0])
|
path: args[0].readUtf8String()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
script.on("message", lambda message, data: self._reactor.schedule(lambda: self._on_message(pid, message)))
|
script.on("message", lambda message, data: self._reactor.schedule(lambda: self._on_message(pid, message)))
|
||||||
print("✔ load()")
|
print("✔ load()")
|
||||||
script.load()
|
script.load()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def on_uninjected(id):
|
|||||||
print("on_uninjected id=%u" % id)
|
print("on_uninjected id=%u" % id)
|
||||||
|
|
||||||
|
|
||||||
(target, library_path) = sys.argv[1:]
|
target, library_path = sys.argv[1:]
|
||||||
|
|
||||||
device = frida.get_local_device()
|
device = frida.get_local_device()
|
||||||
device.on("uninjected", on_uninjected)
|
device.on("uninjected", on_uninjected)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def on_uninjected(id):
|
|||||||
print("on_uninjected id=%u" % id)
|
print("on_uninjected id=%u" % id)
|
||||||
|
|
||||||
|
|
||||||
(target, library_path) = sys.argv[1:]
|
target, library_path = sys.argv[1:]
|
||||||
|
|
||||||
device = frida.get_local_device()
|
device = frida.get_local_device()
|
||||||
device.on("uninjected", on_uninjected)
|
device.on("uninjected", on_uninjected)
|
||||||
|
|||||||
+2
-4
@@ -1,8 +1,7 @@
|
|||||||
import frida
|
import frida
|
||||||
|
|
||||||
session = frida.attach("Twitter")
|
session = frida.attach("Twitter")
|
||||||
script = session.create_script(
|
script = session.create_script("""\
|
||||||
"""\
|
|
||||||
rpc.exports = {
|
rpc.exports = {
|
||||||
hello: function () {
|
hello: function () {
|
||||||
return 'Hello';
|
return 'Hello';
|
||||||
@@ -11,8 +10,7 @@ rpc.exports = {
|
|||||||
oops;
|
oops;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
script.load()
|
script.load()
|
||||||
api = script.exports_sync
|
api = script.exports_sync
|
||||||
print("api.hello() =>", api.hello())
|
print("api.hello() =>", api.hello())
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ class Application:
|
|||||||
self._session = session
|
self._session = session
|
||||||
session.on("detached", lambda *args: self._reactor.schedule(lambda: self._on_detached(*args)))
|
session.on("detached", lambda *args: self._reactor.schedule(lambda: self._on_detached(*args)))
|
||||||
|
|
||||||
script = session.create_script(
|
script = session.create_script("""
|
||||||
"""
|
|
||||||
let _puts = null;
|
let _puts = null;
|
||||||
|
|
||||||
Interceptor.attach(DebugSymbol.getFunctionByName('f'), {
|
Interceptor.attach(DebugSymbol.getFunctionByName('f'), {
|
||||||
@@ -48,8 +47,7 @@ function puts(s) {
|
|||||||
}
|
}
|
||||||
_puts(Memory.allocUtf8String(s));
|
_puts(Memory.allocUtf8String(s));
|
||||||
}
|
}
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
self._script = script
|
self._script = script
|
||||||
script.on("message", lambda *args: self._reactor.schedule(lambda: self._on_message(*args)))
|
script.on("message", lambda *args: self._reactor.schedule(lambda: self._on_message(*args)))
|
||||||
script.load()
|
script.load()
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
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()
|
||||||
+19
-3
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import _frida
|
from . import _frida
|
||||||
@@ -86,14 +86,30 @@ def kill(target: core.ProcessTarget) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def attach(
|
def attach(
|
||||||
target: core.ProcessTarget, realm: Optional[str] = None, persist_timeout: Optional[int] = None
|
target: core.ProcessTarget,
|
||||||
|
realm: Optional[str] = None,
|
||||||
|
persist_timeout: Optional[int] = None,
|
||||||
|
exceptor: Optional[str] = None,
|
||||||
|
unwind_broker: Optional[bool] = None,
|
||||||
|
exit_monitor: Optional[bool] = None,
|
||||||
|
thread_suspend_monitor: Optional[bool] = None,
|
||||||
|
linker_notifier_offsets: Optional[Sequence[int]] = None,
|
||||||
) -> core.Session:
|
) -> core.Session:
|
||||||
"""
|
"""
|
||||||
Attach to a process
|
Attach to a process
|
||||||
:param target: the PID or name of the process
|
:param target: the PID or name of the process
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return get_local_device().attach(target, realm=realm, persist_timeout=persist_timeout)
|
return get_local_device().attach(
|
||||||
|
target,
|
||||||
|
realm=realm,
|
||||||
|
persist_timeout=persist_timeout,
|
||||||
|
exceptor=exceptor,
|
||||||
|
unwind_broker=unwind_broker,
|
||||||
|
exit_monitor=exit_monitor,
|
||||||
|
thread_suspend_monitor=thread_suspend_monitor,
|
||||||
|
linker_notifier_offsets=linker_notifier_offsets,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def inject_library_file(target: core.ProcessTarget, path: str, entrypoint: str, data: str) -> int:
|
def inject_library_file(target: core.ProcessTarget, path: str, entrypoint: str, data: str) -> int:
|
||||||
|
|||||||
@@ -256,7 +256,17 @@ class Device(Object):
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def attach(self, pid: int, realm: Optional[str] = None, persist_timeout: Optional[int] = None) -> "Session":
|
def attach(
|
||||||
|
self,
|
||||||
|
pid: int,
|
||||||
|
realm: Optional[str] = None,
|
||||||
|
persist_timeout: Optional[int] = None,
|
||||||
|
exceptor: Optional[str] = None,
|
||||||
|
unwind_broker: Optional[bool] = None,
|
||||||
|
exit_monitor: Optional[bool] = None,
|
||||||
|
thread_suspend_monitor: Optional[bool] = None,
|
||||||
|
linker_notifier_offsets: Optional[Sequence[int]] = None,
|
||||||
|
) -> "Session":
|
||||||
"""
|
"""
|
||||||
Attach to a PID.
|
Attach to a PID.
|
||||||
"""
|
"""
|
||||||
|
|||||||
+107
-6
@@ -404,6 +404,7 @@ static void PyDevice_init_from_handle (PyDevice * self, FridaDevice * handle);
|
|||||||
static void PyDevice_dealloc (PyDevice * self);
|
static void PyDevice_dealloc (PyDevice * self);
|
||||||
static PyObject * PyDevice_repr (PyDevice * self);
|
static PyObject * PyDevice_repr (PyDevice * self);
|
||||||
static PyObject * PyDevice_is_lost (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_query_system_parameters (PyDevice * self);
|
||||||
static PyObject * PyDevice_get_frontmost_application (PyDevice * self, PyObject * args, PyObject * kw);
|
static PyObject * PyDevice_get_frontmost_application (PyDevice * self, PyObject * args, PyObject * kw);
|
||||||
static PyObject * PyDevice_enumerate_applications (PyDevice * self, PyObject * args, PyObject * kw);
|
static PyObject * PyDevice_enumerate_applications (PyDevice * self, PyObject * args, PyObject * kw);
|
||||||
@@ -419,7 +420,7 @@ static PyObject * PyDevice_input (PyDevice * self, PyObject * args);
|
|||||||
static PyObject * PyDevice_resume (PyDevice * self, PyObject * args);
|
static PyObject * PyDevice_resume (PyDevice * self, PyObject * args);
|
||||||
static PyObject * PyDevice_kill (PyDevice * self, PyObject * args);
|
static PyObject * PyDevice_kill (PyDevice * self, PyObject * args);
|
||||||
static PyObject * PyDevice_attach (PyDevice * self, PyObject * args, PyObject * kw);
|
static PyObject * PyDevice_attach (PyDevice * self, PyObject * args, PyObject * kw);
|
||||||
static FridaSessionOptions * PyDevice_parse_session_options (const gchar * realm_value, guint persist_timeout);
|
static FridaSessionOptions * PyDevice_parse_session_options (const gchar * realm_value, guint persist_timeout, const gchar * exceptor_value, gint unwind_broker, gint exit_monitor, gint thread_suspend_monitor, PyObject * linker_notifier_offsets_value);
|
||||||
static PyObject * PyDevice_inject_library_file (PyDevice * self, PyObject * args);
|
static PyObject * PyDevice_inject_library_file (PyDevice * self, PyObject * args);
|
||||||
static PyObject * PyDevice_inject_library_blob (PyDevice * self, PyObject * args);
|
static PyObject * PyDevice_inject_library_blob (PyDevice * self, PyObject * args);
|
||||||
static PyObject * PyDevice_open_channel (PyDevice * self, PyObject * args);
|
static PyObject * PyDevice_open_channel (PyDevice * self, PyObject * args);
|
||||||
@@ -620,6 +621,7 @@ static PyMethodDef PyDeviceManager_methods[] =
|
|||||||
static PyMethodDef PyDevice_methods[] =
|
static PyMethodDef PyDevice_methods[] =
|
||||||
{
|
{
|
||||||
{ "is_lost", (PyCFunction) PyDevice_is_lost, METH_NOARGS, "Query whether the device has been lost." },
|
{ "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." },
|
{ "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." },
|
{ "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." },
|
{ "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);
|
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 *
|
static PyObject *
|
||||||
PyDevice_query_system_parameters (PyDevice * self)
|
PyDevice_query_system_parameters (PyDevice * self)
|
||||||
{
|
{
|
||||||
@@ -3052,21 +3081,43 @@ static PyObject *
|
|||||||
PyDevice_attach (PyDevice * self, PyObject * args, PyObject * kw)
|
PyDevice_attach (PyDevice * self, PyObject * args, PyObject * kw)
|
||||||
{
|
{
|
||||||
PyObject * result = NULL;
|
PyObject * result = NULL;
|
||||||
static char * keywords[] = { "pid", "realm", "persist_timeout", NULL };
|
static char * keywords[] = {
|
||||||
|
"pid",
|
||||||
|
"realm",
|
||||||
|
"persist_timeout",
|
||||||
|
"exceptor",
|
||||||
|
"unwind_broker",
|
||||||
|
"exit_monitor",
|
||||||
|
"thread_suspend_monitor",
|
||||||
|
"linker_notifier_offsets",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
long pid;
|
long pid;
|
||||||
char * realm_value = NULL;
|
char * realm_value = NULL;
|
||||||
unsigned int persist_timeout = 0;
|
unsigned int persist_timeout = 0;
|
||||||
|
char * exceptor_value = NULL;
|
||||||
|
int unwind_broker = -1;
|
||||||
|
int exit_monitor = -1;
|
||||||
|
int thread_suspend_monitor = -1;
|
||||||
|
PyObject * linker_notifier_offsets_value = NULL;
|
||||||
FridaSessionOptions * options = NULL;
|
FridaSessionOptions * options = NULL;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
FridaSession * handle;
|
FridaSession * handle;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "l|esI", keywords,
|
if (!PyArg_ParseTupleAndKeywords (args, kw, "l|esIespppO", keywords,
|
||||||
&pid,
|
&pid,
|
||||||
"utf-8", &realm_value,
|
"utf-8", &realm_value,
|
||||||
&persist_timeout))
|
&persist_timeout,
|
||||||
|
"utf-8", &exceptor_value,
|
||||||
|
&unwind_broker,
|
||||||
|
&exit_monitor,
|
||||||
|
&thread_suspend_monitor,
|
||||||
|
&linker_notifier_offsets_value))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
options = PyDevice_parse_session_options (realm_value, persist_timeout);
|
options = PyDevice_parse_session_options (realm_value, persist_timeout,
|
||||||
|
exceptor_value, unwind_broker, exit_monitor, thread_suspend_monitor,
|
||||||
|
linker_notifier_offsets_value);
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
@@ -3081,6 +3132,7 @@ PyDevice_attach (PyDevice * self, PyObject * args, PyObject * kw)
|
|||||||
beach:
|
beach:
|
||||||
g_clear_object (&options);
|
g_clear_object (&options);
|
||||||
|
|
||||||
|
PyMem_Free (exceptor_value);
|
||||||
PyMem_Free (realm_value);
|
PyMem_Free (realm_value);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -3088,7 +3140,12 @@ beach:
|
|||||||
|
|
||||||
static FridaSessionOptions *
|
static FridaSessionOptions *
|
||||||
PyDevice_parse_session_options (const gchar * realm_value,
|
PyDevice_parse_session_options (const gchar * realm_value,
|
||||||
guint persist_timeout)
|
guint persist_timeout,
|
||||||
|
const gchar * exceptor_value,
|
||||||
|
gint unwind_broker,
|
||||||
|
gint exit_monitor,
|
||||||
|
gint thread_suspend_monitor,
|
||||||
|
PyObject * linker_notifier_offsets_value)
|
||||||
{
|
{
|
||||||
FridaSessionOptions * options;
|
FridaSessionOptions * options;
|
||||||
|
|
||||||
@@ -3106,6 +3163,50 @@ PyDevice_parse_session_options (const gchar * realm_value,
|
|||||||
|
|
||||||
frida_session_options_set_persist_timeout (options, persist_timeout);
|
frida_session_options_set_persist_timeout (options, persist_timeout);
|
||||||
|
|
||||||
|
if (exceptor_value != NULL)
|
||||||
|
{
|
||||||
|
FridaExceptor exceptor;
|
||||||
|
|
||||||
|
if (!PyGObject_unmarshal_enum (exceptor_value, FRIDA_TYPE_EXCEPTOR, &exceptor))
|
||||||
|
goto propagate_error;
|
||||||
|
|
||||||
|
frida_session_options_set_exceptor (options, exceptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unwind_broker != -1)
|
||||||
|
frida_session_options_set_unwind_broker (options, unwind_broker);
|
||||||
|
|
||||||
|
if (exit_monitor != -1)
|
||||||
|
frida_session_options_set_exit_monitor (options, exit_monitor);
|
||||||
|
|
||||||
|
if (thread_suspend_monitor != -1)
|
||||||
|
frida_session_options_set_thread_suspend_monitor (options, thread_suspend_monitor);
|
||||||
|
|
||||||
|
if (linker_notifier_offsets_value != NULL)
|
||||||
|
{
|
||||||
|
gint n, i;
|
||||||
|
|
||||||
|
n = PySequence_Size (linker_notifier_offsets_value);
|
||||||
|
if (n == -1)
|
||||||
|
goto propagate_error;
|
||||||
|
|
||||||
|
for (i = 0; i != n; i++)
|
||||||
|
{
|
||||||
|
PyObject * element;
|
||||||
|
unsigned long offset;
|
||||||
|
|
||||||
|
element = PySequence_GetItem (linker_notifier_offsets_value, i);
|
||||||
|
if (element == NULL)
|
||||||
|
goto propagate_error;
|
||||||
|
offset = PyLong_AsUnsignedLong (element);
|
||||||
|
Py_DecRef (element);
|
||||||
|
if (offset == (unsigned long) -1 && PyErr_Occurred () != NULL)
|
||||||
|
goto propagate_error;
|
||||||
|
|
||||||
|
frida_session_options_add_linker_notifier_offset (options, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
|
||||||
propagate_error:
|
propagate_error:
|
||||||
|
|||||||
+23
-2
@@ -883,6 +883,14 @@ class Device:
|
|||||||
|
|
||||||
return self._impl.is_lost()
|
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
|
@cancellable
|
||||||
def query_system_parameters(self) -> Dict[str, Any]:
|
def query_system_parameters(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
@@ -1038,13 +1046,26 @@ class Device:
|
|||||||
target: ProcessTarget,
|
target: ProcessTarget,
|
||||||
realm: Optional[str] = None,
|
realm: Optional[str] = None,
|
||||||
persist_timeout: Optional[int] = None,
|
persist_timeout: Optional[int] = None,
|
||||||
|
exceptor: Optional[str] = None,
|
||||||
|
unwind_broker: Optional[bool] = None,
|
||||||
|
exit_monitor: Optional[bool] = None,
|
||||||
|
thread_suspend_monitor: Optional[bool] = None,
|
||||||
|
linker_notifier_offsets: Optional[Sequence[int]] = None,
|
||||||
) -> Session:
|
) -> Session:
|
||||||
"""
|
"""
|
||||||
Attach to a process
|
Attach to a process
|
||||||
:param target: the PID or name of the process
|
:param target: the PID or name of the process
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kwargs = {"realm": realm, "persist_timeout": persist_timeout}
|
kwargs = {
|
||||||
|
"realm": realm,
|
||||||
|
"persist_timeout": persist_timeout,
|
||||||
|
"exceptor": exceptor,
|
||||||
|
"unwind_broker": unwind_broker,
|
||||||
|
"exit_monitor": exit_monitor,
|
||||||
|
"thread_suspend_monitor": thread_suspend_monitor,
|
||||||
|
"linker_notifier_offsets": linker_notifier_offsets,
|
||||||
|
}
|
||||||
_filter_missing_kwargs(kwargs)
|
_filter_missing_kwargs(kwargs)
|
||||||
return Session(self._impl.attach(self._pid_of(target), **kwargs)) # type: ignore
|
return Session(self._impl.attach(self._pid_of(target), **kwargs)) # type: ignore
|
||||||
|
|
||||||
@@ -1310,7 +1331,7 @@ class EndpointParameters:
|
|||||||
_filter_missing_kwargs(kwargs)
|
_filter_missing_kwargs(kwargs)
|
||||||
|
|
||||||
if authentication is not None:
|
if authentication is not None:
|
||||||
(auth_scheme, auth_data) = authentication
|
auth_scheme, auth_data = authentication
|
||||||
if auth_scheme == "token":
|
if auth_scheme == "token":
|
||||||
kwargs["auth_token"] = auth_data
|
kwargs["auth_token"] = auth_data
|
||||||
elif auth_scheme == "callback":
|
elif auth_scheme == "callback":
|
||||||
|
|||||||
+1
-1
Submodule releng updated: 7ed66fe687...1442ae5a7a
@@ -1,6 +1,6 @@
|
|||||||
[wrap-git]
|
[wrap-git]
|
||||||
url = https://github.com/frida/frida-core.git
|
url = https://github.com/frida/frida-core.git
|
||||||
revision = 17.7.2
|
revision = 17.11.0
|
||||||
depth = 1
|
depth = 1
|
||||||
|
|
||||||
[provide]
|
[provide]
|
||||||
|
|||||||
Reference in New Issue
Block a user