修复 objection frida.TimedOutError: unexpectedly timed out while waiting for app to launch

 

🦉 [~] frida --version                                                                                                    
17.0.5
🦉 [~] objection version                                                                                                  
objection: 1.11.0

 

/Users/wzb/.pyenv/versions/3.11.10/lib/python3.11/site-packages/objection/utils/agent.py

 

    def get_session(self) -> frida.core.Session:
        """
            Attempt to get a Frida session on a device.
        """

        if self.session:
            return self.session

        self.device = self._get_device()

        # try and get the target process.
        try:

            debug_print('Attempting to attach to process: `{process}`'.format(
                process=state_connection.gadget_name))
            self.session = self.device.attach(state_connection.gadget_name)
            debug_print('Process attached!')
            self.resumed = True

            self.session.on('detached', self.on_detach)

            return self.session

        except frida.ProcessNotFoundError:
            debug_print('Unable to find process: `{process}`, attempting spawn'.format(
                process=state_connection.gadget_name))

        # TODO: Handle the fact that gadget mode can't spawn

        print(f"state_connection.gadget_name: {state_connection.gadget_name}")
        try:
            pid = self.device.spawn(state_connection.gadget_name)
            print(f"[+] 启动成功,PID: {pid}")
        except frida.TimedOutError:
            time.sleep(5)
            # 查找运行中的应用
            apps = self.device.enumerate_applications()
            maps_app = next((app for app in apps if app.identifier == state_connection.gadget_name), None)

            if maps_app and maps_app.pid != 0:
                pid = maps_app.pid
                print(f"[+] 启动成功,PID: {pid}")

        self.spawned_pid = pid
        debug_print('PID `{pid}` spawned, attaching...'.format(pid=self.spawned_pid))

        self.session = self.device.attach(self.spawned_pid)
        return self.session

 

posted @ 2025-05-27 17:36  🐳.城南  阅读(161)  评论(0)    收藏  举报