예제 #1
0
    def test_cancellation_mid_request(self):
        script = self.session.create_script(name="test-rpc",
                                            source="""\
rpc.exports = {
    waitForever: function () {
        return new Promise(function () {});
    },
};
""")
        script.load()
        agent = script.exports

        def cancel_after_100ms():
            time.sleep(0.1)
            cancellable.cancel()

        cancellable = frida.Cancellable()
        threading.Thread(target=cancel_after_100ms).start()
        self.assertRaisesOperationCancelled(
            lambda: agent.wait_forever(cancellable=cancellable))
        self.assertEqual(script._pending, {})

        def call_wait_forever_with_cancellable():
            with cancellable:
                agent.wait_forever()

        cancellable = frida.Cancellable()
        threading.Thread(target=cancel_after_100ms).start()
        self.assertRaisesOperationCancelled(call_wait_forever_with_cancellable)
        self.assertEqual(script._pending, {})
예제 #2
0
    def __init__(self, run_until_return, on_stop=None):
        self._running = False
        self._run_until_return = run_until_return
        self._on_stop = on_stop
        self._pending = collections.deque([])
        self._lock = threading.Lock()
        self._cond = threading.Condition(self._lock)

        self.io_cancellable = frida.Cancellable()

        self.ui_cancellable = frida.Cancellable()
        self._ui_cancellable_fd = self.ui_cancellable.get_pollfd()
예제 #3
0
        def _stop(self):
            self._unload_script()
            with frida.Cancellable() as c:
                self._unmonitor_script()

            if self._logfile is not None:
                self._logfile.close()

            if not self._quiet:
                self._print("\nThank you for using Frida!")
예제 #4
0
        def _stop(self):
            if self._eternalize:
                self._eternalize_script()
            else:
                self._unload_script()

            with frida.Cancellable():
                self._demonitor_all()

            if self._logfile is not None:
                self._logfile.close()

            if not self._quiet:
                self._print("\nThank you for using Frida!")
예제 #5
0
    def test_cancel_wait_for_nonexistent_device(self):
        cancellable = frida.Cancellable()

        def wait_for_nonexistent():
            frida.get_device_manager().get_device_matching(
                lambda device: device.type == 'lol',
                timeout=-1,
                cancellable=cancellable)

        def cancel_after_100ms():
            time.sleep(0.1)
            cancellable.cancel()

        threading.Thread(target=cancel_after_100ms).start()
        self.assertRaisesMatching(frida.OperationCancelledError,
                                  "operation was cancelled",
                                  wait_for_nonexistent)
예제 #6
0
    def _deinit(self):
        logger.debug(f"FridaApplication deinit", tag="[✔]")

        utils.ignore_error(self.device.off, "spawn-added",
                           self._cb_spawn_added)
        utils.ignore_error(self.device.off, "spawn-removed",
                           self._cb_spawn_removed)
        utils.ignore_error(self.device.off, "child-added",
                           self._cb_child_added)
        utils.ignore_error(self.device.off, "child-removed",
                           self._cb_child_removed)
        utils.ignore_error(self.device.off, "output", self._cb_output)
        # utils.ignore_error(self.device.off, "process-crashed", self._cb_process_crashed)
        # utils.ignore_error(self.device.off, "uninjected", self._cb_uninjected)
        utils.ignore_error(self.device.off, "lost", self._cb_lost)

        with frida.Cancellable():
            self._demonitor_all()

        self._finished.set()
예제 #7
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.io_cancellable = frida.Cancellable()