示例#1
0
def scan(input_file, output_file, uuid, drop=True, interactive=False):

    context = {}
    context['scan_id'] = uuid
    context['drop_database'] = True
    context['resource_path'] = RESOURCE_PATH
    context['input_file'] = path.abspath(input_file)
    context['output_file'] = path.abspath(output_file)
    tmpl = TEMPLATE_ENV.get_template(TEMPLATE_FILE)
    fd = tempfile.NamedTemporaryFile(prefix='scan')
    fd.write(tmpl.render(context))
    fd.flush()
    # TODO If there is an error in the script then this will just keep
    # running.  We need to either prevent metasploit from dropping to
    # interactive console or detect the prompt.
    args = [METASPLOIT,
            '-m', MODULE_PATH,
            '-r', fd.name]

    if not interactive:
        # TODO this file needs to be saved somewhere or read back to
        # the user for logging.
        fd1 = tempfile.NamedTemporaryFile(prefix='scan-output')
        args.extend(['-o', fd1.name])

    subprocess.call(" ".join(args), shell=True)
示例#2
0
文件: nova.py 项目: NeCTAR-RC/zoran
def export_servers(servers, fd):
    context = {'hosts': servers,
               'now': datetime.now(pytz.timezone("UTC"))}
    tmpl = TEMPLATE_ENV.get_template(TEMPLATE_FILE)
    fd.write(tmpl.render(context))