<filename>sandbox_run.py
import os
import logging
import argparse
from malware.sandbox import Win32Sandbox

logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s',)


parser = argparse.ArgumentParser(description='''This is a automatic script
                                 which record malware network behavior in
                                 the isolation environment.''')
parser.add_argument("-n", "--name", type=str,
                    help="Specify a VM name.")
parser.add_argument("-t", "--time", type=int,
                    help='''Specify a time in seconds
                    for recording network traffic.''')
parser.add_argument("-d", "--malware", type=str,
                    help='''Specify a path which place
                    malware will be copy into sandbox.''')
args = parser.parse_args()


def get_malware_table(path):
    malware_table = {}
    dirs = os.listdir(path)
    dirs.sort()
    uuid = 0
    for malware in dirs:
        uuid += 1
        malware_table[uuid] = malware
    return malware_table


def show_times(times):
    logging.info("#" * 80)
    logging.info("#" + " " * 39 + str(times) + " " * 38 + "#")
    logging.info("#" * 80)

if __name__ == "__main__":
    malware_table = get_malware_table(args.malware)

    for uuid in malware_table.keys():
        malware_path = './{path}/{malware}'.format(path=args.malware,
                                                   malware=malware_table[uuid])
        show_times(uuid)
        winxp = Win32Sandbox(args.name)
        winxp.start()
        winxp.login('john', 'john')
        winxp.copy_malware_in(malware_path)
        winxp.active_capture_parallel(args.time)
        winxp.power_off()
        winxp.restore_snapshot('Origin')

<filename>sandbox_run.py
import os
import logging
import argparse
from malware.sandbox import Win32Sandbox

logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s',)


parser = argparse.ArgumentParser(description='''This is a automatic script
                                 which record malware network behavior in
                                 the isolation environment.''')
parser.add_argument("-n", "--name", type=str,
                    help="Specify a VM name.")
parser.add_argument("-t", "--time", type=int,
                    help='''Specify a time in seconds
                    for recording network traffic.''')
parser.add_argument("-d", "--malware", type=str,
                    help='''Specify a path which place
                    malware will be copy into sandbox.''')
args = parser.parse_args()


def get_malware_table(path):
    malware_table = {}
    dirs = os.listdir(path)
    dirs.sort()
    uuid = 0
    for malware in dirs:
        uuid += 1
        malware_table[uuid] = malware
    return malware_table


def show_times(times):
    logging.info("#" * 80)
    logging.info("#" + " " * 39 + str(times) + " " * 38 + "#")
    logging.info("#" * 80)

if __name__ == "__main__":
    malware_table = get_malware_table(args.malware)

    for uuid in malware_table.keys():
        malware_path = './{path}/{malware}'.format(path=args.malware,
                                                   malware=malware_table[uuid])
        show_times(uuid)
        winxp = Win32Sandbox(args.name)
        winxp.start()
        winxp.login('john', 'john')
        winxp.copy_malware_in(malware_path)
        winxp.active_capture_parallel(args.time)
        winxp.power_off()
        winxp.restore_snapshot('Origin')

This is a automatic script                                  which record malware network behavior in                                  the isolation environment. Specify a time in seconds                     for recording network traffic. Specify a path which place                     malware will be copy into sandbox.