forked from hackedteam/test-av2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_infected.py
54 lines (44 loc) · 1.2 KB
/
check_infected.py
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
#!/usr/bin/python
""" check_infected.py - Checks for synchronization request during update. """
import os
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
log_file = "/var/log/rcs.log"
detected_file = '/var/log/detected'
def send_mail(line):
content = "INFECTED MACHINE DETECTED!\n%s" % line
try:
msg = MIMEMultipart()
msg["Subject"] = "AV Monitor Results"
msg["From"] = "avmonitor@hackingteam.com"
msg["To"] = "olli@hackingteam.com"
body = MIMEText(content, 'txt')
msg.attach(body)
smtp = smtplib.SMTP("mail.hackingteam.com", 25)
smtp.sendmail(msg["From"], msg["To"].split(","), msg.as_string())
smtp.quit()
except Exception as e:
print "Impossible to send mail. Exception: %s" % e
def delete_logfile():
pass
def stop():
with open(detected_file, 'w') as f:
f.write("")
def trigger(cont):
send_mail(cont)
delete_logfile()
stop()
def main():
if os.path.exists(detected_file):
exit()
print "not exited"
if os.path.exists(log_file):
with open(log_file, "r") as f:
cont = f.read()
if "RCS-SYNC" in cont:
print "--- INFECTED MACHINE DETECTED ---"
''' TODO: do something '''
trigger(cont)
if __name__ == "__main__":
main()