Some bug fixes and CR after shocks

This commit is contained in:
maor.rayzin 2018-10-29 13:06:09 +02:00
parent 17b344f62f
commit b85fb8c94a
5 changed files with 9 additions and 9 deletions

View File

@ -328,4 +328,4 @@ class NodeService:
@staticmethod
def get_hostname_by_id(node_id):
NodeService.get_node_hostname(mongo.db.monkey.find_one({'_id': node_id}, {'hostname': 1}))
return NodeService.get_node_hostname(mongo.db.monkey.find_one({'_id': node_id}, {'hostname': 1}))

View File

@ -70,8 +70,7 @@ class PTHReportService(object):
{
'username': user['name'],
'domain_name': user['domain_name'],
'hostname': NodeService.get_hostname_by_id(ObjectId(user['machine_id']))
if user['machine_id'] else None
'hostname': NodeService.get_hostname_by_id(ObjectId(user['machine_id'])) if user['machine_id'] else None
} for user in doc['Docs']
]
users_cred_groups.append({'cred_groups': users_list})

View File

@ -159,7 +159,7 @@ class ReportService:
@staticmethod
def get_stolen_creds():
PASS_TYPE_DICT = {'password': 'Clear Password', 'lm_hash': 'LM hash', 'ntlm_hash': 'NTLM hash'}
creds = set()
creds = []
for telem in mongo.db.telemetry.find(
{'telem_type': 'system_info_collection', 'data.credentials': {'$exists': True}},
{'data.credentials': 1, 'monkey_guid': 1}
@ -176,9 +176,10 @@ class ReportService:
'type': PASS_TYPE_DICT[pass_type],
'origin': origin
}
creds.add(cred_row)
if cred_row not in creds:
creds.append(cred_row)
logger.info('Stolen creds generated for reporting')
return list(creds)
return creds
@staticmethod
def get_ssh_keys():
@ -560,7 +561,7 @@ class ReportService:
issues_dict = {}
for issue in issues:
if issue.get('is_local', True):
machine = issue.get('machine').upper()
machine = issue.get('machine', '').upper()
if machine not in issues_dict:
issues_dict[machine] = []
issues_dict[machine].append(issue)

View File

@ -22,7 +22,7 @@ class MimikatzSecrets(object):
users_dict[username] = {}
ntlm = sam_user.get("NTLM")
if "[hashed secret]" not in ntlm:
if not ntlm or "[hashed secret]" not in ntlm:
continue
users_dict[username]['SAM'] = ntlm.replace("[hashed secret]", "").strip()

View File

@ -29,7 +29,7 @@ class WMIHandler(object):
self.update_critical_services()
def update_critical_services(self):
critical_names = ("W3svc", "MSExchangeServiceHost", "MSSQLServer", "dns", 'MSSQL$SQLEXPRESS', 'SQL')
critical_names = ("W3svc", "MSExchangeServiceHost", "dns", 'MSSQL$SQLEXPRES')
mongo.db.monkey.update({'_id': self.monkey_id}, {'$set': {'critical_services': []}})
services_names_list = [str(i['Name'])[2:-1] for i in self.services]