forked from p15670423/monkey
Add all known telemetry types to dict + don't except when unknown telem_type is received
telem_type + data don't have default value
This commit is contained in:
parent
93d4f08e90
commit
7807a46769
|
@ -97,11 +97,11 @@ class ControlClient(object):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_telemetry(tele_type='general', data=''):
|
def send_telemetry(telem_type, data):
|
||||||
if not WormConfiguration.current_server:
|
if not WormConfiguration.current_server:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
telemetry = {'monkey_guid': GUID, 'telem_type': tele_type, 'data': data}
|
telemetry = {'monkey_guid': GUID, 'telem_type': telem_type, 'data': data}
|
||||||
reply = requests.post("https://%s/api/telemetry" % (WormConfiguration.current_server,),
|
reply = requests.post("https://%s/api/telemetry" % (WormConfiguration.current_server,),
|
||||||
data=json.dumps(telemetry),
|
data=json.dumps(telemetry),
|
||||||
headers={'content-type': 'application/json'},
|
headers={'content-type': 'application/json'},
|
||||||
|
|
|
@ -43,8 +43,12 @@ class Telemetry(flask_restful.Resource):
|
||||||
monkey = NodeService.get_monkey_by_guid(telemetry_json['monkey_guid'])
|
monkey = NodeService.get_monkey_by_guid(telemetry_json['monkey_guid'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
TELEM_PROCESS_DICT[telemetry_json.get('telem_type')](telemetry_json)
|
|
||||||
NodeService.update_monkey_modify_time(monkey["_id"])
|
NodeService.update_monkey_modify_time(monkey["_id"])
|
||||||
|
telem_type = telemetry_json.get('telem_type')
|
||||||
|
if telem_type in TELEM_PROCESS_DICT:
|
||||||
|
TELEM_PROCESS_DICT[telem_type](telemetry_json)
|
||||||
|
else:
|
||||||
|
print('Got unknown type of telemetry: %s' % telem_type)
|
||||||
except StandardError as ex:
|
except StandardError as ex:
|
||||||
print("Exception caught while processing telemetry: %s" % str(ex))
|
print("Exception caught while processing telemetry: %s" % str(ex))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -154,6 +158,10 @@ class Telemetry(flask_restful.Resource):
|
||||||
if 'ntlm_hash' in creds[user]:
|
if 'ntlm_hash' in creds[user]:
|
||||||
ConfigService.creds_add_ntlm_hash(creds[user]['ntlm_hash'])
|
ConfigService.creds_add_ntlm_hash(creds[user]['ntlm_hash'])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_trace_telemetry(telemetry_json):
|
||||||
|
# Nothing to do
|
||||||
|
return
|
||||||
|
|
||||||
TELEM_PROCESS_DICT = \
|
TELEM_PROCESS_DICT = \
|
||||||
{
|
{
|
||||||
|
@ -162,4 +170,5 @@ TELEM_PROCESS_DICT = \
|
||||||
'exploit': Telemetry.process_exploit_telemetry,
|
'exploit': Telemetry.process_exploit_telemetry,
|
||||||
'scan': Telemetry.process_scan_telemetry,
|
'scan': Telemetry.process_scan_telemetry,
|
||||||
'system_info_collection': Telemetry.process_system_info_telemetry,
|
'system_info_collection': Telemetry.process_system_info_telemetry,
|
||||||
|
'trace': Telemetry.process_trace_telemetry
|
||||||
}
|
}
|
Loading…
Reference in New Issue