当前位置: 首页>>代码示例>>Python>>正文


Python frida.TransportError方法代码示例

本文整理汇总了Python中frida.TransportError方法的典型用法代码示例。如果您正苦于以下问题:Python frida.TransportError方法的具体用法?Python frida.TransportError怎么用?Python frida.TransportError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frida的用法示例。


在下文中一共展示了frida.TransportError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def run(self):
        """ thread func
        """
        if self.device is not None:
            try:
                apps = self.device.enumerate_applications()
                for app in sorted(apps, key=lambda x: x.name):
                    self.add_spawn.emit([app.name, app.identifier])
            except frida.ServerNotRunningError:
                self.is_error.emit('unable to connect to remote frida server: not started')
            except frida.TransportError:
                self.is_error.emit('unable to connect to remote frida server: closed')
            except frida.TimedOutError:
                self.is_error.emit('unable to connect to remote frida server: timedout')
            except Exception as e:  # pylint: disable=broad-except
                self.is_error.emit('something was wrong...\n' + str(e))

        self.is_finished.emit() 
开发者ID:iGio90,项目名称:Dwarf,代码行数:20,代码来源:spawns_list.py

示例2: run

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def run(self):
        """ run
        """
        if self.device is not None:
            if isinstance(self.device, frida.core.Device):
                try:
                    procs = self.device.enumerate_processes()

                    for proc in procs:
                        proc_item = {'pid': proc.pid, 'name': proc.name}
                        self.add_proc.emit(proc_item)
                # ServerNotRunningError('unable to connect to remote frida-server: closed')
                except frida.ServerNotRunningError:
                    self.is_error.emit(
                        'Frida ServerNotRunningError: Server not running')
                except frida.TransportError:
                    self.is_error.emit('Frida TransportError: Server closed')
                except frida.TimedOutError:
                    self.is_error.emit('Frida TimedOutError: Server timedout')
                except Exception as e:  # pylint: disable=broad-except
                    self.is_error.emit('something was wrong...\n' + str(e))

        self.is_finished.emit() 
开发者ID:iGio90,项目名称:Dwarf,代码行数:25,代码来源:process_list.py

示例3: _shutdown_sockfd

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def _shutdown_sockfd(pid, sockfd):
  """Injects into a process a call to shutdown() a socket file descriptor.

  Injects into a process a call to shutdown()
  (http://man7.org/linux/man-pages/man2/shutdown.2.html) a socket file
  descriptor, thereby shutting down its associated TCP connection.

  Args:
    pid: The process ID (as an int) of the target process.
    sockfd: The socket file descriptor (as an int) in the context of the target
      process to be shutdown.

  Raises:
    RuntimeError: Error during execution of JavaScript injected into process.
  """

  js_error = {}  # Using dictionary since Python 2.7 doesn't support "nonlocal".
  event = threading.Event()

  def on_message(message, data):  # pylint: disable=unused-argument
    if message["type"] == "error":
      js_error["error"] = message["description"]
    event.set()

  session = frida.attach(pid)
  script = session.create_script(_FRIDA_SCRIPT % sockfd)
  script.on("message", on_message)
  closed = False

  try:
    script.load()
  except frida.TransportError as e:
    if str(e) != "the connection is closed":
      raise
    closed = True

  if not closed:
    event.wait()
    session.detach()
  if "error" in js_error:
    raise RuntimeError(js_error["error"]) 
开发者ID:google,项目名称:tcp_killer,代码行数:43,代码来源:tcp_killer.py

示例4: kill_frida_servers

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def kill_frida_servers(self):
        try:
            apps = self.device.enumerate_processes()
        except (frida.ServerNotRunningError, frida.TransportError, frida.InvalidOperationError):
            # frida server has not been started, no need to start
            return

        for app in apps:
            if app.name == self.server_name:
                self.adb.unsafe_shell('kill -9 {}'.format(app.pid), root=True, quiet=True) 
开发者ID:Margular,项目名称:frida-skeleton,代码行数:12,代码来源:frida_thread.py

示例5: run_frida_server

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def run_frida_server(self):
        self.adb.unsafe_shell('chmod +x /data/local/tmp/' + self.server_name)
        self.server_executor.submit(self.adb.unsafe_shell, '/data/local/tmp/{} -D'.format(self.server_name), True)

        # waiting for frida server
        while True:
            try:
                time.sleep(0.5)
                if not self._terminate:
                    self.device.enumerate_processes()
                break
            except (frida.ServerNotRunningError, frida.TransportError, frida.InvalidOperationError):
                continue 
开发者ID:Margular,项目名称:frida-skeleton,代码行数:15,代码来源:frida_thread.py

示例6: connect

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def connect(self):
        """Connect to Frida Server."""
        session = None
        try:
            env = Environment()
            self.clean_up()
            env.run_frida_server()
            device = frida.get_device(get_device(), settings.FRIDA_TIMEOUT)
            pid = device.spawn([self.package])
            device.resume(pid)
            logger.info('Spawning %s', self.package)
            time.sleep(2)
            session = device.attach(pid)
        except frida.ServerNotRunningError:
            logger.warning('Frida server is not running')
            self.connect()
        except frida.TimedOutError:
            logger.error('Timed out while waiting for device to appear')
        except (frida.ProcessNotFoundError,
                frida.TransportError,
                frida.InvalidOperationError):
            pass
        except Exception:
            logger.exception('Error Connecting to Frida')
        try:
            if session:
                script = session.create_script(self.get_script())
                script.on('message', self.frida_response)
                script.load()
                sys.stdin.read()
                script.unload()
                session.detach()
        except Exception:
            logger.exception('Error Connecting to Frida') 
开发者ID:MobSF,项目名称:Mobile-Security-Framework-MobSF,代码行数:36,代码来源:frida_core.py

示例7: attach

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def attach(self, pid, script=None, print_debug_error=True):
        """ Attach to pid
        """
        if self.device is None:
            raise self.NoDeviceAssignedError('No Device assigned')

        if self._process is not None:
            self.detach()

        was_error = False
        error_msg = ''

        # for commandline arg
        if isinstance(pid, str):
            try:
                process = self.device.get_process(pid)
                pid = [process.pid, process.name]
            except frida.ProcessNotFoundError as error:
                raise Exception('Frida Error: ' + str(error))

        if isinstance(pid, list):
            if len(pid) > 1:
                name = pid[1]
            else:
                name = ''
            pid = pid[0]
        else:
            name = ''

        if not isinstance(pid, int):
            raise Exception('Error pid!=int')

        try:
            self._process = self.device.attach(pid)
            self._process.on('detached', self._on_detached)
            self._pid = pid
        except frida.ProcessNotFoundError:
            error_msg = 'Process not found (ProcessNotFoundError)'
            was_error = True
        except frida.ProcessNotRespondingError:
            error_msg = 'Process not responding (ProcessNotRespondingError)'
            was_error = True
        except frida.TimedOutError:
            error_msg = 'Frida timeout (TimedOutError)'
            was_error = True
        except frida.ServerNotRunningError:
            error_msg = 'Frida not running (ServerNotRunningError)'
            was_error = True
        except frida.TransportError:
            error_msg = 'Frida timeout was reached (TransportError)'
            was_error = True
        # keep for debug
        except Exception as error:  # pylint: disable=broad-except
            error_msg = error
            was_error = True

        if was_error:
            raise Exception(error_msg)

        self.onProcessAttached.emit([self.pid, name])
        self.load_script(script=script) 
开发者ID:iGio90,项目名称:Dwarf,代码行数:63,代码来源:core.py

示例8: attach

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def attach(args, device, user_script):
    """ Attach to pid
    """

    _process = None
    was_error = False
    error_msg = ''
    pid = args.pid

    # for commandline arg
    if isinstance(pid, str):
        try:
            process = device.get_process(pid)
            pid = [process.pid, process.name]
        except frida.ProcessNotFoundError as error:
            raise Exception('Frida Error: ' + str(error))

    if isinstance(pid, list):
        pid = pid[0]

    if not isinstance(pid, int):
        raise Exception('Error pid!=int')

    try:
        _process = device.attach(pid)
        _pid = pid
    except frida.ProcessNotFoundError:
        error_msg = 'Process not found (ProcessNotFoundError)'
        was_error = True
    except frida.ProcessNotRespondingError:
        error_msg = 'Process not responding (ProcessNotRespondingError)'
        was_error = True
    except frida.TimedOutError:
        error_msg = 'Frida timeout (TimedOutError)'
        was_error = True
    except frida.ServerNotRunningError:
        error_msg = 'Frida not running (ServerNotRunningError)'
        was_error = True
    except frida.TransportError:
        error_msg = 'Frida timeout was reached (TransportError)'
        was_error = True
    # keep for debug
    except Exception as error:  # pylint: disable=broad-except
        error_msg = error
        was_error = True

    if was_error:
        raise Exception(error_msg)

    load_script(args, _process, user_script) 
开发者ID:iGio90,项目名称:Dwarf,代码行数:52,代码来源:glue.py

示例9: load_script

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def load_script(args, proc, user_script, spawned=False):
    try:
        if not os.path.exists(utils.resource_path('lib/core.js')):
            print('core.js not found!')
            exit(0)

        with open(utils.resource_path('lib/core.js'), 'r') as core_script:
            script_content = core_script.read()

        _script = proc.create_script(script_content, runtime='v8')
        _script.on('message', on_message)
        # _script.on('destroyed', _on_script_destroyed)
        _script.load()

        try:
            is_debug = args.debug_script
        except:
            is_debug = False
        try:
            break_start = args.break_start
        except:
            break_start = False
        # this break_at_start have same behavior from args or from the checkbox i added
        _script.exports.init(break_start, is_debug, spawned)

        plugin_manager.reload_plugins()

        for plugin in plugin_manager.plugins:
            plugin_instance = plugin_manager.plugins[plugin]
            try:
                _script.exports.api(0, 'evaluateFunction', [plugin_instance.__get_agent__()])
                plugin_instance.set_script(_script)
            except Exception as e:
                pass

        if user_script is not None:
            _script.exports.api(0, 'evaluateFunction', [user_script])
        return 0
    except frida.ProcessNotFoundError:
        error_msg = 'Process not found (ProcessNotFoundError)'
        was_error = True
    except frida.ProcessNotRespondingError:
        error_msg = 'Process not responding (ProcessNotRespondingError)'
        was_error = True
    except frida.TimedOutError:
        error_msg = 'Frida timeout (TimedOutError)'
        was_error = True
    except frida.ServerNotRunningError:
        error_msg = 'Frida not running (ServerNotRunningError)'
        was_error = True
    except frida.TransportError:
        error_msg = 'Frida timeout was reached (TransportError)'
        was_error = True

    if was_error:
        utils.show_message_box(error_msg)
    return 1 
开发者ID:iGio90,项目名称:Dwarf,代码行数:59,代码来源:glue.py

示例10: run_instrumentation

# 需要导入模块: import frida [as 别名]
# 或者: from frida import TransportError [as 别名]
def run_instrumentation(self):

        """
        Select and run instrumentation function using the
        Frida instrumentation toolkit
        """

        while True:
            print(t.green("[{0}] ".format(datetime.now()) +
                          t.cyan("Enter 'quit' to exit Frida module!")))

            print(t.green("[{0}] ".format(datetime.now()) +
                          t.yellow("Available Frida functions: ") +
                          "activities, webview"))

            function = raw_input(t.green("[{0}] ".format(datetime.now())
                                         + t.yellow("Enter Frida function: ")))

            if function == "quit":
                break

            try:
                if function == "activities":
                    # adb forward just
                    # in case
                    #
                    Popen("adb forward tcp:27042 tcp:27042", shell=True).wait()
                    process = frida.get_device_manager().enumerate_devices()[-1].attach(self.apk.get_package())
                    script = process.create_script(self.do_activities())
                    script.on('message', self.on_message)
                    script.load()
                    sys.stdin.read()

                elif function == "webview":
                    # adb forward just
                    # in case
                    #
                    Popen("adb forward tcp:27042 tcp:27042", shell=True).wait()
                    process = frida.get_device_manager().enumerate_devices()[-1].attach(self.apk.get_package())
                    script = process.create_script(self.do_webview())
                    script.on('message', self.on_message)
                    script.load()
                    sys.stdin.read()

            except frida.ProcessNotFoundError as e:
                print(t.red("[{0}] ".format(datetime.now()) +
                            "Could not connect to target process!"))
                Logger.run_logger(e.message)
            except frida.ServerNotRunningError as e:
                print(t.red("[{0}] ".format(datetime.now()) +
                            "The frida-server is not running!"))
                Logger.run_logger(e.message)
            except frida.TransportError as e:
                print(t.red("[{0}] ".format(datetime.now()) +
                            "Connection was closed!"))
                Logger.run_logger(e.message)
            except KeyboardInterrupt:
                pass 
开发者ID:AndroidSecurityTools,项目名称:lobotomy,代码行数:60,代码来源:instrumentation.py


注:本文中的frida.TransportError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。