Example #1
0
def main():
    parser = argparse.ArgumentParser(description='A tool that hook all apps you need')

    parser.add_argument('regexps', type=str, nargs='*',
                        help=r'Regexps for the apps you want to hook such as "^com\.baidu\.", '
                             r'empty for hooking all apps')
    parser.add_argument('-i', '--install', action='store_true',
                        help='install frida server to /data/local/tmp automatically')
    parser.add_argument('-p', '--port', type=int,
                        help='reverse tcp port, if specified, manipulate iptables automatically')
    parser.add_argument('-v', action='store_true', help='verbose output')

    args = parser.parse_args()

    if args.v:
        LOGGER.setLevel(logging.DEBUG)

    # set log
    os.makedirs(LOG_DIR, mode=0o700, exist_ok=True)
    log_filename = time.strftime('%Y-%m-%d_%H-%M-%S.log')
    log_file = open(os.path.join(LOG_DIR, log_filename), 'a', encoding='utf-8')
    logger_handler = ColorizingStreamHandler(log_file)
    logger_handler.setFormatter(FORMATTER)
    LOGGER.addHandler(logger_handler)

    Adb.start_server()

    try:
        t = WatchThread(args.install, args.port, args.regexps, True)
        t.start()
        t.join()
    except KeyboardInterrupt:
        LOGGER.info('shutdown, thank you for using frida skeleton')
    except Exception as e:
        LOGGER.error(e)
Example #2
0
def setLoggingLevel(args):
    # Set FileHandler
    filename = os.path.join(paths.w9scan_Output_Path, "log" + "_" + str(int(time.time())) + ".txt")
    logger.info("The log file will be saved on: '%s'"%filename)
    FILE_HANDLER = logging.FileHandler(filename)   
    FORMATTER = logging.Formatter("\r[%(asctime)s] [%(levelname)s] %(message)s", "%H:%M:%S")
    FILE_HANDLER.setFormatter(FORMATTER)
    LOGGER.addHandler(FILE_HANDLER)
    
    if args.debug:
        LOGGER.setLevel(CUSTOM_LOGGING.DEBUG)
Example #3
0
def setLoggingLevel(args):
    #日志文件处理函数
    filename = os.path.join(paths.Ajatar_Output_PATH,
                            "log" + "_" + str(int(time.time())) + ".txt")

    logger.info("Log file saved on %s" % filename)
    FILE_HANDLER = logging.FileHandler(filename)  #日志设置文件为对象
    FORMATTER = logging.Formatter(
        "\r[%(asctime)s] [%(levelname)s] %(message)s", "%H:%M:%S")  #输出格式
    FILE_HANDLER.setFormatter(FORMATTER)
    LOGGER.addHandler(FILE_HANDLER)

    if args.debug:
        LOGGER.setLevel(CUSTOM_LOGGING.DEBUG)  #日志级别为DEBUG
Example #4
0
def main():
    parser = argparse.ArgumentParser(
        description='A tool that hook all apps you need')

    parser.add_argument(
        'regexps',
        type=str,
        nargs='*',
        help=r'Regexps for the apps you want to hook such as "^com\.baidu\.", '
        r'empty for hooking all apps')
    parser.add_argument(
        '-i',
        '--install',
        action='store_true',
        help='install frida server to /data/local/tmp automatically')
    parser.add_argument(
        '-p',
        '--port',
        type=int,
        help='reverse tcp port, if specified, manipulate iptables automatically'
    )
    parser.add_argument('-v', action='store_true', help='verbose output')

    args = parser.parse_args()

    try:
        if args.v:
            LOGGER.setLevel(logging.DEBUG)

        # set log
        os.makedirs(LOG_DIR, mode=0o700, exist_ok=True)
        log_filename = time.strftime('%Y-%m-%d_%H-%M-%S.log')
        log_file = open(os.path.join(LOG_DIR, log_filename),
                        'a',
                        encoding='utf-8')
        logger_handler = ColorizingStreamHandler(log_file)
        logger_handler.setFormatter(FORMATTER)
        LOGGER.addHandler(logger_handler)

        # set handling interrupt exceptions
        signal.signal(signal.SIGTERM, shutdown)
        signal.signal(signal.SIGINT, shutdown)

        Adb.start_server()

        watch_thread = WatchThread(args.install, args.port, args.regexps)
    except (KeyboardInterrupt, InterruptedError) as e:
        LOGGER.info(e)
        sys.exit(-1)

    try:
        watch_thread.start()
        while True:
            time.sleep(1)
    except MainExit:
        while True:
            try:
                LOGGER.info(
                    'shutdown command received, wait for clean up please...')
                watch_thread.cancel()
                break
            except MainExit:
                pass

    # waiting for sub threads
    while True:
        try:
            while True:
                should_we_exit()
                time.sleep(1)
        except MainExit:
            try:
                n = len(thread_manager.thread_map)
                if n > 0:
                    LOGGER.info(
                        'running sub threads: {}, wait a second please'.format(
                            n))
            except MainExit:
                pass