(args, device, user_script)
Attach to pid
Attach to pid
Attach to pid
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)
def attach ( args , device , user_script ) : _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 )