本文整理汇总了Python中frida.attach方法的典型用法代码示例。如果您正苦于以下问题:Python frida.attach方法的具体用法?Python frida.attach怎么用?Python frida.attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frida
的用法示例。
在下文中一共展示了frida.attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _shutdown_sockfd
# 需要导入模块: import frida [as 别名]
# 或者: from frida import attach [as 别名]
def _shutdown_sockfd(pid, sockfd):
"""Injects into a process a call to shutdown() a socket file descriptor.
Injects into a process a call to shutdown()
(http://man7.org/linux/man-pages/man2/shutdown.2.html) a socket file
descriptor, thereby shutting down its associated TCP connection.
Args:
pid: The process ID (as an int) of the target process.
sockfd: The socket file descriptor (as an int) in the context of the target
process to be shutdown.
Raises:
RuntimeError: Error during execution of JavaScript injected into process.
"""
js_error = {} # Using dictionary since Python 2.7 doesn't support "nonlocal".
event = threading.Event()
def on_message(message, data): # pylint: disable=unused-argument
if message["type"] == "error":
js_error["error"] = message["description"]
event.set()
session = frida.attach(pid)
script = session.create_script(_FRIDA_SCRIPT % sockfd)
script.on("message", on_message)
closed = False
try:
script.load()
except frida.TransportError as e:
if str(e) != "the connection is closed":
raise
closed = True
if not closed:
event.wait()
session.detach()
if "error" in js_error:
raise RuntimeError(js_error["error"])
示例2: __init__
# 需要导入模块: import frida [as 别名]
# 或者: from frida import attach [as 别名]
def __init__(self, target_process):
# Attach to the target process.
self.session = frida.attach(target_process)
# Load the script in the target process.
self.script = self.session.create_script(script_code)
self.script.load()