fixed PR comments

This commit is contained in:
VakarisZ 2019-06-12 11:51:20 +03:00
parent 6c4a515442
commit f2d25c4481
2 changed files with 34 additions and 13 deletions

View File

@ -35,11 +35,11 @@ class T1110(AttackTechnique):
result['successful_creds'].append(T1110.parse_creds(attempt))
if succeeded:
data = {'message': T1110.used_msg, 'status': ScanStatus.USED.name}
data = T1110.get_message_and_status(T1110, ScanStatus.USED)
elif attempts:
data = {'message': T1110.scanned_msg, 'status': ScanStatus.SCANNED.name}
data = T1110.get_message_and_status(T1110, ScanStatus.SCANNED)
else:
data = {'message': T1110.unscanned_msg, 'status': ScanStatus.UNSCANNED.name}
data = T1110.get_message_and_status(T1110, ScanStatus.UNSCANNED)
data.update({'services': attempts, 'title': T1110.technique_title(T1110.tech_id)})
return data
@ -51,21 +51,33 @@ class T1110(AttackTechnique):
:return: string with username and used password/hash
"""
username = attempt['user']
if attempt['lm_hash']:
return '%s ; LM hash %s ...' % (username, encryptor.dec(attempt['lm_hash'])[0:5])
if attempt['ntlm_hash']:
return '%s ; NTLM hash %s ...' % (username, encryptor.dec(attempt['ntlm_hash'])[0:20])
if attempt['ssh_key']:
return '%s ; SSH key %s ...' % (username, encryptor.dec(attempt['ssh_key'])[0:15])
if attempt['password']:
return '%s : %s' % (username, T1110.obfuscate_password(encryptor.dec(attempt['password'])))
creds = {'lm_hash': {'type': 'LM hash', 'shown_chars': 5, 'funct': T1110.censor_hash},
'ntlm_hash': {'type': 'NTLM hash', 'shown_chars': 20, 'funct': T1110.censor_hash},
'ssh_key': {'type': 'SSH key', 'shown_chars': 15, 'funct': T1110.censor_hash},
'password': {'type': 'Plaintext password', 'shown_chars': 3, 'funct': T1110.censor_password}}
for key, cred in creds.items():
if attempt[key]:
return '%s ; %s : %s' % (username,
cred['type'],
cred['funct'](encryptor.dec(attempt[key]), cred['shown_chars']))
@staticmethod
def obfuscate_password(password, plain_chars=3):
def censor_password(password, plain_chars=3, secret_chars=5):
"""
Obfuscates password by changing characters to *
:param password: Password or string to obfuscate
:param plain_chars: How many plain-text characters should be kept at the start of the string
:param secret_chars: How many * symbols should be used to hide the remainder of the password
:return: Obfuscated string e.g. Pass****
"""
return password[0:plain_chars] + '*' * (len(password) - plain_chars)
return password[0:plain_chars] + '*' * secret_chars
@staticmethod
def censor_hash(hash_, plain_chars=5):
"""
Obfuscates hash by only showing a part of it
:param hash_: Hash to obfuscate
:param plain_chars: How many chars of hash should be shown
:return: Obfuscated string
"""
return hash_[0: plain_chars] + ' ...'

View File

@ -60,6 +60,15 @@ class AttackTechnique(object):
else:
return ScanStatus.UNSCANNED
@staticmethod
def get_message_and_status(technique, status):
if status == ScanStatus.UNSCANNED:
return {'message': technique.unscanned_msg, 'status': ScanStatus.UNSCANNED.name}
elif status == ScanStatus.SCANNED:
return {'message': technique.scanned_msg, 'status': ScanStatus.SCANNED.name}
else:
return {'message': technique.used_msg, 'status': ScanStatus.USED.name}
@staticmethod
def technique_title(technique):
"""