示例#1
0
def test_sort_mime():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    cfg.sort_mime = True
    r = requests.get('http://xwell.org/assets/docs/test.pdf')
    assert maltrieve.save_malware(r, cfg)
    assert os.access('archive-test/application_pdf/b9ff662486d448da7b60ba6234867c65', os.F_OK)
示例#2
0
def test_config_args():
    args = maltrieve.setup_args(['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/tmp/mwtest'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.logfile == 'testlog'
    test_proxy = {'http': '127.0.0.1:8080'}
    assert cmp(cfg.proxy, test_proxy) == 0
    assert cfg.dumpdir == '/tmp/mwtest'
示例#3
0
def test_config_args():
    args = maltrieve.setup_args(
        ['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/tmp/mwtest'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.logfile == 'testlog'
    test_proxy = {'http': '127.0.0.1:8080'}
    assert cmp(cfg.proxy, test_proxy) == 0
    assert cfg.dumpdir == '/tmp/mwtest'
示例#4
0
def test_sort_mime():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    cfg.sort_mime = True
    r = requests.get('http://xwell.org/assets/docs/test.pdf')
    assert maltrieve.save_malware(r, cfg)
    assert os.access(
        'archive-test/application_pdf/b9ff662486d448da7b60ba6234867c65',
        os.F_OK)
示例#5
0
def test_alt_config():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    assert cfg.dumpdir == 'archive-test'
    assert cfg.logfile == 'maltrieve-test.log'
    test_ua = {'User-Agent': 'Test-Agent'}
    assert cmp(cfg.useragent, test_ua) == 0
    test_proxy = {'http': '127.0.0.1:3128'}
    assert cmp(cfg.proxy, test_proxy) == 0
    assert cfg.black_list == ['text/html', 'text/plain']
    assert cfg.white_list == ['application/pdf', 'application/x-dosexec']
    assert cfg.crits == 'http://127.0.0.1:8080'
    assert cfg.crits_user == 'maltrieve'
    assert cfg.crits_key == 'YOUR_API_KEY_HERE'
    assert cfg.crits_source == 'maltrieve'
    assert cfg.inputfile is None
示例#6
0
def test_alt_config():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    assert cfg.dumpdir == 'archive-test'
    assert cfg.logfile == 'maltrieve-test.log'
    test_ua = {'User-Agent': 'Test-Agent'}
    assert cmp(cfg.useragent, test_ua) == 0
    test_proxy = {'http': '127.0.0.1:3128'}
    assert cmp(cfg.proxy, test_proxy) == 0
    assert cfg.black_list == ['text/html', 'text/plain']
    assert cfg.white_list == ['application/pdf', 'application/x-dosexec']
    assert cfg.crits == 'http://127.0.0.1:8080'
    assert cfg.crits_user == 'maltrieve'
    assert cfg.crits_key == 'YOUR_API_KEY_HERE'
    assert cfg.crits_source == 'maltrieve'
    assert cfg.inputfile is None
示例#7
0
def test_save_whitelist_pass():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org/assets/docs/test.pdf')
    assert maltrieve.save_malware(r, cfg)
    assert os.access('archive-test/b9ff662486d448da7b60ba6234867c65', os.F_OK)
示例#8
0
def test_save_whitelist_fail():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org/assets/images/dodecahedron.png')
    assert maltrieve.save_malware(r, cfg) is False
示例#9
0
def test_save_whitelist_fail():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org/assets/images/dodecahedron.png')
    assert maltrieve.save_malware(r, cfg) is False
示例#10
0
def test_create_default_dumpdir_when_specified_doesnt_exist():
    args = maltrieve.setup_args(['-d', '/_nope_'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
示例#11
0
def test_inputfile():
    args = maltrieve.setup_args(['-i', 'test-input'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.inputfile == 'test-input'
示例#12
0
def test_read_alt_config():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    assert args.config == "maltrieve-test.cfg"
示例#13
0
def test_saving_args():
    args = maltrieve.setup_args(['-v', '-x', '-c', '-s'])
    assert args.viper
    assert args.vxcage
    assert args.cuckoo
    assert args.sort_mime
示例#14
0
def test_save_whitelist_pass():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org/assets/docs/test.pdf')
    assert maltrieve.save_malware(r, cfg)
    assert os.access('archive-test/b9ff662486d448da7b60ba6234867c65', os.F_OK)
示例#15
0
def test_saving_args():
    args = maltrieve.setup_args(['-v', '-x', '-c', '-s'])
    assert args.viper
    assert args.vxcage
    assert args.cuckoo
    assert args.sort_mime
示例#16
0
def test_create_default_dumpdir():
    args = maltrieve.setup_args(['-d', '/'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
示例#17
0
def test_read_alt_config():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    assert args.config == "maltrieve-test.cfg"
示例#18
0
def test_create_default_dumpdir_when_specified_doesnt_exist():
    args = maltrieve.setup_args(['-d', '/_nope_'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
示例#19
0
def test_inputfile():
    args = maltrieve.setup_args(['-i', 'test-input'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.inputfile == 'test-input'
示例#20
0
def test_basic_args():
    args = maltrieve.setup_args(['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/opt/'])
    assert args.logfile == 'testlog'
    assert args.proxy == '127.0.0.1:8080'
    assert args.dumpdir == '/opt/'
示例#21
0
def test_create_default_dumpdir():
    args = maltrieve.setup_args(['-d', '/'])
    cfg = maltrieve.config(args, 'maltrieve-test.cfg')
    assert cfg.dumpdir == '/tmp/malware'
示例#22
0
def test_save_blacklist():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org')
    assert maltrieve.save_malware(r, cfg) is False
示例#23
0
def test_basic_args():
    args = maltrieve.setup_args(
        ['-l', 'testlog', '-p', '127.0.0.1:8080', '-d', '/opt/'])
    assert args.logfile == 'testlog'
    assert args.proxy == '127.0.0.1:8080'
    assert args.dumpdir == '/opt/'
示例#24
0
def test_save_blacklist():
    args = maltrieve.setup_args(['--config', 'maltrieve-test.cfg'])
    cfg = maltrieve.config(args, args.config)
    r = requests.get('http://xwell.org')
    assert maltrieve.save_malware(r, cfg) is False