mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
6284b97c37
This introduces the -U/--usb switch for using a USB-tethered device instead of the local system. Only iOS devices are supported for now (PR for completing Android support in frida-core is most appreciated!).
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import platform
|
|
import subprocess
|
|
import threading
|
|
try:
|
|
import unittest2 as unittest
|
|
except:
|
|
import unittest
|
|
|
|
import frida
|
|
from frida.application import Reactor
|
|
from frida.tracer import Tracer, TracerProfileBuilder, MemoryRepository, UI
|
|
|
|
|
|
class TestTracer(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
system = platform.system()
|
|
if system == 'Windows':
|
|
cls.target = subprocess.Popen([r"C:\Windows\notepad.exe"])
|
|
else:
|
|
cls.target = subprocess.Popen(["/bin/cat"])
|
|
cls.process = frida.attach(cls.target.pid)
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
cls.process.detach()
|
|
cls.target.terminate()
|
|
|
|
def test_basics(self):
|
|
never = threading.Event()
|
|
reactor = Reactor(never.wait)
|
|
def start():
|
|
tp = TracerProfileBuilder().include("open*")
|
|
t = Tracer(reactor, MemoryRepository(), tp.build())
|
|
targets = t.start_trace(self.process, UI())
|
|
t.stop()
|
|
reactor.stop()
|
|
reactor.schedule(start)
|
|
reactor.run()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|