forked from p34709852/monkey
fixed PR comments
This commit is contained in:
parent
6c4a515442
commit
f2d25c4481
|
@ -35,11 +35,11 @@ class T1110(AttackTechnique):
|
||||||
result['successful_creds'].append(T1110.parse_creds(attempt))
|
result['successful_creds'].append(T1110.parse_creds(attempt))
|
||||||
|
|
||||||
if succeeded:
|
if succeeded:
|
||||||
data = {'message': T1110.used_msg, 'status': ScanStatus.USED.name}
|
data = T1110.get_message_and_status(T1110, ScanStatus.USED)
|
||||||
elif attempts:
|
elif attempts:
|
||||||
data = {'message': T1110.scanned_msg, 'status': ScanStatus.SCANNED.name}
|
data = T1110.get_message_and_status(T1110, ScanStatus.SCANNED)
|
||||||
else:
|
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)})
|
data.update({'services': attempts, 'title': T1110.technique_title(T1110.tech_id)})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -51,21 +51,33 @@ class T1110(AttackTechnique):
|
||||||
:return: string with username and used password/hash
|
:return: string with username and used password/hash
|
||||||
"""
|
"""
|
||||||
username = attempt['user']
|
username = attempt['user']
|
||||||
if attempt['lm_hash']:
|
creds = {'lm_hash': {'type': 'LM hash', 'shown_chars': 5, 'funct': T1110.censor_hash},
|
||||||
return '%s ; LM hash %s ...' % (username, encryptor.dec(attempt['lm_hash'])[0:5])
|
'ntlm_hash': {'type': 'NTLM hash', 'shown_chars': 20, 'funct': T1110.censor_hash},
|
||||||
if attempt['ntlm_hash']:
|
'ssh_key': {'type': 'SSH key', 'shown_chars': 15, 'funct': T1110.censor_hash},
|
||||||
return '%s ; NTLM hash %s ...' % (username, encryptor.dec(attempt['ntlm_hash'])[0:20])
|
'password': {'type': 'Plaintext password', 'shown_chars': 3, 'funct': T1110.censor_password}}
|
||||||
if attempt['ssh_key']:
|
for key, cred in creds.items():
|
||||||
return '%s ; SSH key %s ...' % (username, encryptor.dec(attempt['ssh_key'])[0:15])
|
if attempt[key]:
|
||||||
if attempt['password']:
|
return '%s ; %s : %s' % (username,
|
||||||
return '%s : %s' % (username, T1110.obfuscate_password(encryptor.dec(attempt['password'])))
|
cred['type'],
|
||||||
|
cred['funct'](encryptor.dec(attempt[key]), cred['shown_chars']))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def obfuscate_password(password, plain_chars=3):
|
def censor_password(password, plain_chars=3, secret_chars=5):
|
||||||
"""
|
"""
|
||||||
Obfuscates password by changing characters to *
|
Obfuscates password by changing characters to *
|
||||||
:param password: Password or string to obfuscate
|
: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 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: 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] + ' ...'
|
||||||
|
|
|
@ -60,6 +60,15 @@ class AttackTechnique(object):
|
||||||
else:
|
else:
|
||||||
return ScanStatus.UNSCANNED
|
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
|
@staticmethod
|
||||||
def technique_title(technique):
|
def technique_title(technique):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue