class Agent: def __init__(self): try: self.running = True logging.basicConfig(level=LOG_LEVEL) self.logger = logging.getLogger('HostAgent') self.logger.debug(GREEN+'[+] Agent Class Initialized.') self.start_listener() self.start_proc_monitor() self.start_net_monitor() #time.sleep(DELAY) #self.start_orphan_checker() while True: pass except KeyboardInterrupt: print RED+"[*] Terminating Agent" self.end() print RED+"[*] Flushing IPTables" os.system("iptables -F") print RED+"[*] Killing Fatrace" os.system("ps | grep fatrace | awk {'print $1'} | xargs kill -9") print RED+"[*] Killing Python" os.system("ps | grep python | awk {'print $1'} | xargs kill -9") def start_listener(self): self.listenT = ListenThread('0.0.0.0',8888) self.listenT.daemon = True self.listenT.start() def start_proc_monitor(self): self.procT = ProcThread() self.procT.daemon = True self.procT.start() def start_net_monitor(self): self.netT = NetThread() self.netT.daemon = True self.netT.start() def end(self): self.listenT.end() self.procT.end() self.netT.end()
def start_proc_monitor(self): self.procT = ProcThread() self.procT.daemon = True self.procT.start()