forked from p34709852/monkey
More byte/str mixups fixed
This commit is contained in:
parent
c40ec2adaf
commit
a194bb5622
|
@ -138,7 +138,7 @@ class SSHExploiter(HostExploiter):
|
||||||
if not self.host.os.get('machine'):
|
if not self.host.os.get('machine'):
|
||||||
try:
|
try:
|
||||||
_, stdout, _ = ssh.exec_command('uname -m')
|
_, stdout, _ = ssh.exec_command('uname -m')
|
||||||
uname_machine = stdout.read().lower().strip()
|
uname_machine = stdout.read().lower().strip().decode()
|
||||||
if '' != uname_machine:
|
if '' != uname_machine:
|
||||||
self.host.os['machine'] = uname_machine
|
self.host.os['machine'] = uname_machine
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
|
@ -38,10 +38,10 @@ class Encryptor:
|
||||||
def _unpad(self, message: str):
|
def _unpad(self, message: str):
|
||||||
return message[0:-ord(message[len(message) - 1])]
|
return message[0:-ord(message[len(message) - 1])]
|
||||||
|
|
||||||
def enc(self, message):
|
def enc(self, message: str):
|
||||||
cipher_iv = Random.new().read(AES.block_size)
|
cipher_iv = Random.new().read(AES.block_size)
|
||||||
cipher = AES.new(self._cipher_key, AES.MODE_CBC, cipher_iv)
|
cipher = AES.new(self._cipher_key, AES.MODE_CBC, cipher_iv)
|
||||||
return base64.b64encode(cipher_iv + cipher.encrypt(self._pad(message).encode()))
|
return base64.b64encode(cipher_iv + cipher.encrypt(self._pad(message).encode())).decode()
|
||||||
|
|
||||||
def dec(self, enc_message):
|
def dec(self, enc_message):
|
||||||
enc_message = base64.b64decode(enc_message)
|
enc_message = base64.b64decode(enc_message)
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TelemetryFeed(flask_restful.Resource):
|
||||||
'timestamp': datetime.now().isoformat()
|
'timestamp': datetime.now().isoformat()
|
||||||
}
|
}
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
logger.error("Failed parsing telemetries. Error: {0}.".format(err.message))
|
logger.error("Failed parsing telemetries. Error: {0}.".format(err))
|
||||||
return {'telemetries': [], 'timestamp': datetime.now().isoformat()}
|
return {'telemetries': [], 'timestamp': datetime.now().isoformat()}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -55,4 +55,4 @@ def encrypt_exploit_creds(telemetry_json):
|
||||||
for field in ['password', 'lm_hash', 'ntlm_hash']:
|
for field in ['password', 'lm_hash', 'ntlm_hash']:
|
||||||
credential = attempts[i][field]
|
credential = attempts[i][field]
|
||||||
if len(credential) > 0:
|
if len(credential) > 0:
|
||||||
attempts[i][field] = encryptor.enc(credential.encode('utf-8'))
|
attempts[i][field] = encryptor.enc(credential)
|
||||||
|
|
|
@ -26,4 +26,4 @@ def process_telemetry(telemetry_json):
|
||||||
else:
|
else:
|
||||||
logger.info('Got unknown type of telemetry: %s' % telem_category)
|
logger.info('Got unknown type of telemetry: %s' % telem_category)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error("Exception caught while processing telemetry. Info: {}".format(ex.message), exc_info=True)
|
logger.error("Exception caught while processing telemetry. Info: {}".format(ex), exc_info=True)
|
||||||
|
|
|
@ -43,7 +43,7 @@ def encrypt_system_info_ssh_keys(ssh_info):
|
||||||
for idx, user in enumerate(ssh_info):
|
for idx, user in enumerate(ssh_info):
|
||||||
for field in ['public_key', 'private_key', 'known_hosts']:
|
for field in ['public_key', 'private_key', 'known_hosts']:
|
||||||
if ssh_info[idx][field]:
|
if ssh_info[idx][field]:
|
||||||
ssh_info[idx][field] = encryptor.enc(ssh_info[idx][field].encode('utf-8'))
|
ssh_info[idx][field] = encryptor.enc(ssh_info[idx][field])
|
||||||
|
|
||||||
|
|
||||||
def process_credential_info(telemetry_json):
|
def process_credential_info(telemetry_json):
|
||||||
|
@ -77,7 +77,7 @@ def encrypt_system_info_creds(creds):
|
||||||
for field in ['password', 'lm_hash', 'ntlm_hash']:
|
for field in ['password', 'lm_hash', 'ntlm_hash']:
|
||||||
if field in creds[user]:
|
if field in creds[user]:
|
||||||
# this encoding is because we might run into passwords which are not pure ASCII
|
# this encoding is because we might run into passwords which are not pure ASCII
|
||||||
creds[user][field] = encryptor.enc(creds[user][field].encode('utf-8'))
|
creds[user][field] = encryptor.enc(creds[user][field])
|
||||||
|
|
||||||
|
|
||||||
def process_mimikatz_and_wmi_info(telemetry_json):
|
def process_mimikatz_and_wmi_info(telemetry_json):
|
||||||
|
|
Loading…
Reference in New Issue