Ejemplo n.º 1
0
    def handle_reconnect(self, document: str) -> bool:
        """
            Handles a reconnection attempt to a device.

            A reconnection means that the current agent will be unloaded
            and reloaded again.

            :param document:
            :return:
        """

        if document.strip() in ('reconnect', 'reset'):

            click.secho('Reconnecting...', dim=True)

            try:
                state_connection.agent.unload()

                agent = Agent()
                agent.inject()
                state_connection.agent = agent

                self.set_prompt_tokens(get_device_info())
                click.secho('Reconnection successful!', fg='green')

            except (frida.ServerNotRunningError, frida.TimedOutError) as e:
                click.secho('Failed to reconnect with error: {0}'.format(e),
                            fg='red')

            return True

        return False
Ejemplo n.º 2
0
    def test_agent_loads_from_disk_successfully_without_debug(self, mock_app_state):
        mock_app_state.should_debug.return_value = False

        agent = Agent()
        source = agent._get_agent_source()

        self.assertTrue(mock_app_state.should_debug.called)
        self.assertTrue('rpc.exports' in source)
Ejemplo n.º 3
0
    def test_agent_loads_from_disk_successfully_with_debug(self, mock_app_state):
        mock_app_state.should_debug.return_value = True

        agent = Agent()
        source = agent._get_agent_source()

        self.assertTrue(mock_app_state.should_debug.called)
        self.assertTrue('rpc.exports' in source)
        self.assertTrue('application/json;charset=utf-8;base64' in source.split(':')[-1])
Ejemplo n.º 4
0
def get_agent() -> Agent:
    """ get_agent bootstraps an agent instance """

    agent = Agent(
        AgentConfig(name=state_connection.name,
                    host=state_connection.host,
                    port=state_connection.port,
                    device_type=state_connection.device_type,
                    device_id=state_connection.device_id,
                    spawn=state_connection.spawn,
                    foremost=state_connection.foremost,
                    debugger=state_connection.debugger,
                    pause=not state_connection.no_pause))

    agent.run()

    return agent
Ejemplo n.º 5
0
    def test_agent_fails_to_load_throws_error(self, mock_os):
        mock_os.path.exists.return_value = False

        with self.assertRaises(Exception) as _:
            agent = Agent()
            agent._get_agent_source()
Ejemplo n.º 6
0
from objection.state.connection import state_connection
from objection.utils.agent import Agent

state_connection.gadget_name = "{appPackageName}"
state_connection.agent = Agent()
state_connection.agent.inject()
api = state_connection.get_api()
api.android_ssl_pinning_disable(False)

inputCommand = input("input any word to quit!!!")