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


Python Engine.add_multiple_virii_from_dir方法代码示例

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


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

示例1: main

# 需要导入模块: from Engine import Engine [as 别名]
# 或者: from Engine.Engine import add_multiple_virii_from_dir [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_multiple_virii_from_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。