More byte/str mixups fixed

This commit is contained in:
VakarisZ 2019-09-25 16:06:15 +03:00
parent c40ec2adaf
commit a194bb5622
6 changed files with 8 additions and 8 deletions

View File

@ -138,7 +138,7 @@ class SSHExploiter(HostExploiter):
if not self.host.os.get('machine'):
try:
_, stdout, _ = ssh.exec_command('uname -m')
uname_machine = stdout.read().lower().strip()
uname_machine = stdout.read().lower().strip().decode()
if '' != uname_machine:
self.host.os['machine'] = uname_machine
except Exception as exc:

View File

@ -38,10 +38,10 @@ class Encryptor:
def _unpad(self, message: str):
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 = 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):
enc_message = base64.b64decode(enc_message)

View File

@ -33,7 +33,7 @@ class TelemetryFeed(flask_restful.Resource):
'timestamp': datetime.now().isoformat()
}
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()}
@staticmethod

View File

@ -55,4 +55,4 @@ def encrypt_exploit_creds(telemetry_json):
for field in ['password', 'lm_hash', 'ntlm_hash']:
credential = attempts[i][field]
if len(credential) > 0:
attempts[i][field] = encryptor.enc(credential.encode('utf-8'))
attempts[i][field] = encryptor.enc(credential)

View File

@ -26,4 +26,4 @@ def process_telemetry(telemetry_json):
else:
logger.info('Got unknown type of telemetry: %s' % telem_category)
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)

View File

@ -43,7 +43,7 @@ def encrypt_system_info_ssh_keys(ssh_info):
for idx, user in enumerate(ssh_info):
for field in ['public_key', 'private_key', 'known_hosts']:
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):
@ -77,7 +77,7 @@ def encrypt_system_info_creds(creds):
for field in ['password', 'lm_hash', 'ntlm_hash']:
if field in creds[user]:
# 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):