-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.py
executable file
·88 lines (65 loc) · 2.67 KB
/
action.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import time
from live_response import LiveResponseThread
class Action(object):
def __init__(self, cb, logger):
self.cb = cb
self.logger = logger
def name(self):
return self.__class__.__name__
class FlushAction(Action):
def __init__(self, cb, logger):
Action.__init__(self, cb, logger)
def action(self, sensor_id):
flush_time = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(time.time() + 86400))
self.cb.sensor_flush(sensor_id, flush_time)
def name(self):
return 'Flush sensor information'
class IsolateAction(Action):
def __init__(self, cb, logger):
Action.__init__(self, cb, logger)
def action(self, sensor_id):
self.cb.sensor_toggle_isolation(sensor_id, True)
def name(self):
return 'Isolate affected sensor'
class RunLiveResponseScript(LiveResponseThread):
def run(self):
self.success = False
try:
self.establish_session()
self.logger.info("Gathering running services")
self.running_services = self.create_process("c:\\windows\\system32\\net.exe start")
self.logger.info("Gathering running processes")
self.running_processes = self.get_processes()
# get the current user
users = set([proc['username'].split('\\')[-1]
for proc in self.running_processes if proc['path'].find('explorer.exe') != -1])
for user in users:
self.logger.info("Gathering Chrome browser history for %s" % user)
self.browser_history = \
self.get_file("c:\\users\\%s\\appdata\\local\\google\\chrome\\user data\\default\\history" % user)
self.logger.info("LR done")
except Exception as e:
import traceback
traceback.print_exc()
else:
self.success = True
def get_results(self):
if self.success:
return {'running_services': self.running_services.decode('latin-1'),
'running_processes': self.running_processes,
'browser_history': self.browser_history}
else:
return None
class RunLiveResponseScriptAction(Action):
def __init__(self, cb, logger):
Action.__init__(self, cb, logger)
def action(self, sensor_id):
print "Starting live response against sensor %d" % sensor_id
lr_thread = RunLiveResponseScript(self.cb, self.logger, sensor_id)
lr_thread.start()
lr_thread.join()
return lr_thread.get_results()
def name(self):
return 'Run live response script'
def shortname(self):
return 'liveresponse'