當前位置: 首頁>>代碼示例>>Python>>正文


Python Engine.add_files_from_urls方法代碼示例

本文整理匯總了Python中Engine.Engine.add_files_from_urls方法的典型用法代碼示例。如果您正苦於以下問題:Python Engine.add_files_from_urls方法的具體用法?Python Engine.add_files_from_urls怎麽用?Python Engine.add_files_from_urls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Engine.Engine的用法示例。


在下文中一共展示了Engine.add_files_from_urls方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from Engine import Engine [as 別名]
# 或者: from Engine.Engine import add_files_from_urls [as 別名]
def main(args):
    # **************************************************************************
    # Initialization of the vault mechanisms
    # and objects.
    # **************************************************************************
    vt_api = args.vtapikey.strip()
    vault_base = args.base.strip()
    debug = args.verbose
    password = args.password

    signal.signal(signal.SIGINT, KeyboardInterruptHandler)

    main_logger = Logger(_output=sys.stdout, _debug=debug)

    global engine
    engine = Engine(_base=vault_base, _vtapi=vt_api, _password=password, _logger=main_logger)

    # **************************************************************************
    # Verify if the vault already exists at the
    # given base.
    # **************************************************************************
    if not engine.vault_is_created():
        # If the vault is not created, confirm if the user want
        # to create it.
        main_logger.print_warning(ERR_NO_VAULT_FOUND.format(vault_base))
        user_answer = main_logger.get_input(ASK_CREATE_VAULT)
        do_create = user_answer == YES
        if do_create:
            try:
                engine.create_vault()
                main_logger.print_success(INFO_VAULT_CREATED)
            except Exception as e:
                main_logger.print_error(ERR_VAULT_CREATION.format(e.message))
                sys.exit(1)
        else:
            sys.exit(1)

            # **************************************************************************
            # Check if we have a connection to the Internet
            # if not, leave.
            # **************************************************************************
    if not engine.can_connect_internet():
        main_logger.print_error(ERR_FAILED_CONNECT)
        sys.exit(1)
    main_logger.print_success(INFO_CONNECTED_NET)

    try:
        # **************************************************************************
        # Functions
        # **************************************************************************
        #
        # Add new item to vault:
        #
        # **************************************************************************
        if args.newfile:
            newfile = args.newfile.strip()
            if os.path.isfile(newfile):
                engine.add_single_file_virus(newfile)
            elif os.path.isdir(newfile):
                engine.add_single_dir_virus(newfile)
            elif newfile[0:4].lower() == "http":
                engine.add_http_file_virus(newfile)
            else:
                raise FileNotFoundException(newfile)
                # **************************************************************************
                # Import all malware from the given directory:
                # **************************************************************************
        elif args.import_dir:
            source_dir = args.import_dir
            #
            # If the user specified a file rather than a directory,
            # add the file.
            #
            if os.path.isfile(source_dir):
                engine.add_single_file_virus(source_dir)
            elif os.path.isdir(source_dir):
                engine.add_multiple_virii_from_dir(source_dir)
            else:
                raise FileNotFoundException(source_dir)
                # **************************************************************************
                # Import malware from URLs contained in files
                # **************************************************************************
        elif args.urlsfile:
            source_urls = [args.urlsfile]
            engine.add_files_from_urls(source_urls)
        elif args.hunt_mode:
            engine.start_malware_hunt()
            #
            # **************************************************************************
            #
    except Exception as e:
        main_logger.print_error(e.message)
        traceback.print_exc()

        # **************************************************************************
        # Clean up
        # **************************************************************************
    main_logger.print_warning(INFO_PROGRAM_TERMINATE)
    engine.shutdown()
開發者ID:InfectedPacket,項目名稱:VxVault,代碼行數:101,代碼來源:vxvault.py


注:本文中的Engine.Engine.add_files_from_urls方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。