本文整理匯總了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()