Beispiel #1
0
    def __init__(self, device, install: bool, port: int, regexps: list, daemon: bool):
        super().__init__(daemon=daemon)

        self.device = device
        self.install = install
        self.port = port
        self.regexps = regexps if regexps else ['.*']

        self.adb = Adb(self.device.id)
        self.iptables = Iptables(self.adb)

        self.arch = self.adb.unsafe_shell("getprop ro.product.cpu.abi")['out']
        # maybe get 'arm64-v8a', 'arm-v7a' ...
        if 'arm64' in self.arch:
            self.arch = 'arm64'
        elif 'arm' in self.arch:
            self.arch = 'arm'
        elif 'x86_64' in self.arch:
            self.arch = 'x86_64'
        elif 'x86' in self.arch:
            self.arch = 'x86'
        else:
            raise RuntimeError('unknown arch: ' + self.arch)

        self.server_name = 'frida-server-{}-android-{}'.format(frida.__version__, self.arch)
Beispiel #2
0
    def __init__(self, device, install: bool, port: int, regexps: list):
        super().__init__()

        self.log = logging.getLogger(self.__class__.__name__ + '|' + device.id)

        if device.type == FakeDevice.type:
            # init remote device
            self.log.debug(
                'device {} does not support get_usb_device, changing to get_remote_device'
                .format(device.id))
            self.forward_port = port_manager.acquire_port(excludes=[port])
            self.device = frida.get_device_manager().add_remote_device(
                '127.0.0.1:{}'.format(self.forward_port))
            self.device.id = device.id
        else:
            self.device = device

        self.install = install
        self.port = port
        self.regexps = regexps if regexps else ['.*']

        self.adb = Adb(self.device.id)

        if device.type == FakeDevice.type:
            result = self.adb.forward(self.forward_port,
                                      FRIDA_SERVER_DEFAULT_PORT)
            # port has been used
            if len(result['err'].strip()) > 0:
                port_manager.release_port(self.forward_port)
                raise RuntimeError('port {} has been used'.format(
                    self.forward_port))

        if self.port:
            self.iptables = Iptables(self.adb, self.port)

        self.arch = self.adb.unsafe_shell("getprop ro.product.cpu.abi")['out']
        # maybe get 'arm64-v8a', 'arm-v7a' ...
        if 'arm64' in self.arch:
            self.arch = 'arm64'
        elif 'arm' in self.arch:
            self.arch = 'arm'
        elif 'x86_64' in self.arch:
            self.arch = 'x86_64'
        elif 'x86' in self.arch:
            self.arch = 'x86'
        else:
            raise RuntimeError('unknown arch: ' + self.arch)

        self.server_name = 'frida-server-{}-android-{}'.format(
            frida.__version__, self.arch)

        self.stop_flag = False

        thread_manager.add_thread(self)
Beispiel #3
0
    def __init__(self, device):
        super().__init__()

        self.server_executor = ThreadPoolExecutor(max_workers=1)
        self.log = logging.getLogger(self.__class__.__name__ + '|' + device.id)

        if device.type == FakeDevice.type:
            # init remote device
            self.log.debug(
                'device {} does not support get_usb_device, changing to get_remote_device method'
                .format(device.id))
            self.forward_port = port_manager.acquire_port(
                excludes=[options.port])
            self.device = frida.get_device_manager().add_remote_device(
                '127.0.0.1:{}'.format(self.forward_port))
            self.device.id = device.id
        else:
            self.device = device

        self.adb = Adb(self.device.id)

        if device.type == FakeDevice.type:
            result = self.adb.forward(self.forward_port,
                                      FRIDA_SERVER_DEFAULT_PORT)
            # port has been used
            if result.err:
                port_manager.release_port(self.forward_port)
                raise RuntimeError('port {} has been used'.format(
                    self.forward_port))

        if options.port:
            self.iptables = Iptables(self.adb, options.port)

        self.arch = self.adb.unsafe_shell("getprop ro.product.cpu.abi").out
        # maybe get 'arm64-v8a', 'arm-v7a' ...
        if 'arm64' in self.arch:
            self.arch = 'arm64'
        elif 'arm' in self.arch:
            self.arch = 'arm'
        elif 'x86_64' in self.arch:
            self.arch = 'x86_64'
        elif 'x86' in self.arch:
            self.arch = 'x86'
        else:
            raise RuntimeError('unknown arch: ' + self.arch)

        self.server_name = 'frida-server-{}-android-{}'.format(
            frida.__version__, self.arch)

        self._terminate = False