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


Python Database.add_exe方法代码示例

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


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

示例1: main

# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import add_exe [as 别名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("path", type=str, help="Path to the file to analyze")
    parser.add_argument("--package", type=str, action="store", default="", help="Specify an analysis package", required=False)
    parser.add_argument("--custom", type=str, action="store", default="", help="Specify any custom value", required=False)
    parser.add_argument("--timeout", type=int, action="store", default=0, help="Specify an analysis timeout", required=False)
    parser.add_argument("--options", type=str, action="store", default="", help="Specify options for the analysis package (e.g. \"name=value,name2=value2\")", required=False)
    parser.add_argument("--priority", type=int, action="store", default=1, help="Specify a priority for the analysis represented by an integer", required=False)
    parser.add_argument("--machine", type=str, action="store", default="", help="Specify the identifier of a machine you want to use", required=False)
    parser.add_argument("--platform", type=str, action="store", default="", help="Specify the operating system platform you want to use (windows/darwin/linux)", required=False)

    try:
        args = parser.parse_args()
    except IOError as e:
        parser.error(e.message)
        return False

    if not os.path.exists(args.path):
        print("ERROR: the specified file does not exist at path \"%s\"" % args.path)
        return False

    db = Database()
    # Add executable to db
    exe_id = db.add_exe(file_path=args.path,
                        md5=File(args.path).get_md5())
    print("SUCCESS: Created executable id: %d" % exe_id)
    # Create analysis
    anal_id = db.add_analysis("New analysis", exe_id)
    print("SUCCESS: Created new analysis with id: %d" % anal_id)
    # Add tasks for every machine
    for machine in args.machine.split(","):
        task_id = db.add(file_path=args.path,
                     anal_id=anal_id,
                     md5=File(args.path).get_md5(),
                     package=args.package,
                     timeout=args.timeout,
                     options=args.options,
                     priority=args.priority,
                     machine=machine,
                     platform=args.platform,
                     custom=args.custom)
        print("SUCCESS: Task added with id %d" % task_id)
        # Sleep needed for multiple VM startup with VMWare
        sleep(5)
        
    print("SUCCESS: All Tasks added to Analysis")
开发者ID:BwRy,项目名称:test-av,代码行数:48,代码来源:submit_analysis.py

示例2: store_and_submit_fileobj

# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import add_exe [as 别名]
def store_and_submit_fileobj(fobj, filename, desc, package="", 
                            options="", timeout=0, priority=1, machines="", platform=""):
    # Do everything in tmppath/TMPSUBDIR
    tmppath = tempfile.gettempdir()
    targetpath = os.path.join(tmppath, TMPSUBDIR)
    if not os.path.exists(targetpath): os.mkdir(targetpath)

    # Upload will be stored in a tmpdir with the original name
    tmpdir = tempfile.mkdtemp(prefix="upload_", dir=targetpath)
    tmpf = open(os.path.join(tmpdir, filename), "wb")
    t = fobj.read(BUFSIZE)

    # While reading from client also compute md5hash
    md5h = hashlib.md5()
    while t:
        md5h.update(t)
        tmpf.write(t)
        t = fobj.read(BUFSIZE)

    tmpf.close()

    # Submit task to cuckoo db
    db = Database()
    # Create executable record if needed
    exe_id = db.add_exe(file_path=tmpf.name,
                        md5=md5h.hexdigest())
    #print("EXE ID: %s, 0: %s" % (str(exe_id), exe_id[0]))
    # Create analysis record
    a_id = db.add_analysis(desc, exe_id)
    #print("ANALYSIS ID: %s" % anal_id)
    
    for machine in machines.split(","):
        task_id = db.add(file_path=tmpf.name,
                         a_id=a_id,
                         md5=md5h.hexdigest(),
                         package=package,
                         timeout=timeout,
                         options=options,
                         priority=priority,
                         machine=machine,
                         platform=platform)
        sleep(3)
        print("TASK ID: %s" % task_id)
        
    return a_id
开发者ID:BwRy,项目名称:test-av,代码行数:47,代码来源:web_analysis.py


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