mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Compare commits
37 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 |
+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.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -420,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);
|
||||||
@@ -3081,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;
|
||||||
|
|
||||||
@@ -3110,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;
|
||||||
@@ -3117,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;
|
||||||
|
|
||||||
@@ -3135,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:
|
||||||
|
|||||||
+14
-1
@@ -1046,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
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule releng updated: 10b201e27d...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.9.2
|
revision = 17.11.0
|
||||||
depth = 1
|
depth = 1
|
||||||
|
|
||||||
[provide]
|
[provide]
|
||||||
|
|||||||
Reference in New Issue
Block a user