This repository was archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·59 lines (59 loc) · 2.48 KB
/
Copy pathmain.py
File metadata and controls
executable file
·59 lines (59 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from Analysis import youra
from VirtualBox import scheduler
from os.path import join, abspath
from os import getcwd
from time import sleep
import mysql.connector as mariadb
import logging
from subprocess import call
from shutil import copy
logging.basicConfig(format='%(levelname)s:\t%(message)s', level=logging.DEBUG)
con = mariadb.connect(user='root', password='',
host='localhost', database='ama')
c = con.cursor()
while True:
c.execute(
'SELECT filename,tid from tasks where tid=(SELECT min(tid) from tasks where finished=0)')
res = c.fetchone()
if res:
fname = res[0]
fullpath = join(abspath("Web/uploads"), fname)
f = open(abspath('Analysis/const.py'), 'r')
lines = f.readlines()
lines[1] = 'FILE_TO_SCAN = "' + str(fullpath) + '"\n'
tid = res[1]
lines[2] = 'TID = ' + str(tid) + '\n'
f.close()
f = open(abspath('Analysis/const.py'), 'w')
f.writelines(lines)
f.close()
print 'applying yara'
youra.applyara()
f = open(abspath('VirtualBox/const.py'), 'r')
lines = f.readlines()
lines[2] = 'SOURCE_PATH = "' + str(fullpath) + '"\n'
lines[4] = 'DEST_PATH = "C:/Project/' + str(fname) + '"\n'
f.close()
f = open(abspath('VirtualBox/const.py'), 'w')
f.writelines(lines)
f.close()
print 'scheduling'
scheduler.schedule()
pwd = 'your_system_password'
cmd = 'chmod 777 -R ' + getcwd()
perm = call('echo {} | sudo -S {}'.format(pwd, cmd), shell=True)
print 'apllying suri'
cmd = 'suricata -c /etc/suricata/suricata.yaml -r ' + \
abspath('VirtualBox/gen/ama.pcap')
suri = call('echo {} | sudo -S {}'.format(pwd, cmd), shell=True)
copy(abspath('Analysis/logs/fast.log'),
abspath('Analysis/logs/'+str(tid)+'net.log'))
imageconv = call([abspath('Analysis/volatility/vol.py'), '-f', abspath(
'VirtualBox/gen/coredump'), '--profile=Win7SP1x64', 'imagecopy', '-O', abspath('VirtualBox/gen/copy.raw')])
volatil = call([abspath('Analysis/volatility/vol.py'), '-f', abspath('VirtualBox/gen/copy.raw'), '--profile=Win7SP1x64',
'yarascan', '-y', abspath('Analysis/malware_rules.yar'), '--output-file=./Analysis/logs/'+str(tid)+'vmem.txt'])
c.execute('UPDATE tasks SET finished = 1 where tid=%s' % tid)
con.commit()
else:
print('Nothing left. Sleeping')
sleep(300)