mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
98733a3388
Because `/bin/cat` is now considered a system program we are no longer allowed to attach to it using `task_for_pid()`. Bundle our own test program for Mac as a workaround.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from .data import target_program
|
|
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()
|
|
cls.target = subprocess.Popen([target_program])
|
|
cls.session = frida.attach(cls.target.pid)
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
cls.session.detach()
|
|
cls.target.terminate()
|
|
|
|
def test_basics(self):
|
|
done = threading.Event()
|
|
reactor = Reactor(lambda reactor: done.wait())
|
|
def start():
|
|
tp = TracerProfileBuilder().include("open*")
|
|
t = Tracer(reactor, MemoryRepository(), tp.build())
|
|
targets = t.start_trace(self.session, UI())
|
|
t.stop()
|
|
reactor.stop()
|
|
done.set()
|
|
reactor.schedule(start)
|
|
reactor.run()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|