diff --git a/cme_db.py b/cme_db.py index f006b614..d172a512 100644 --- a/cme_db.py +++ b/cme_db.py @@ -44,7 +44,11 @@ class CMEDatabaseNavigator(cmd.Cmd): domain = host[3] os = host[4] - print u" {}{}{}{}{}".format('{:<8}'.format(hostID), '{:<17}'.format(ip), '{:<25}'.format(hostname), '{:<17}'.format(domain), '{:<17}'.format(os)) + print u" {}{}{}{}{}".format('{:<8}'.format(hostID), + '{:<17}'.format(ip), + u'{:<25}'.format(hostname.decode('utf-8')), + u'{:<17}'.format(domain.decode('utf-8')), + '{:<17}'.format(os)) print "" @@ -66,7 +70,11 @@ class CMEDatabaseNavigator(cmd.Cmd): username = cred[3] password = cred[4] - print u" {}{}{}{}{}".format('{:<8}'.format(credID), '{:<12}'.format(credType), '{:<17}'.format(domain), '{:<21}'.format(username), '{:<17}'.format(password)) + print u" {}{}{}{}{}".format('{:<8}'.format(credID), + '{:<12}'.format(credType), + u'{:<17}'.format(domain.decode('utf-8')), + u'{:<21}'.format(username.decode('utf-8')), + u'{:<17}'.format(password.decode('utf-8'))) print "" @@ -92,7 +100,11 @@ class CMEDatabaseNavigator(cmd.Cmd): username = cred[3] password = cred[4] - print u" {}{}{}{}{}".format('{:<8}'.format(credID), '{:<12}'.format(credType), '{:<17}'.format(domain), '{:<21}'.format(username), '{:<17}'.format(password)) + print u" {}{}{}{}{}".format('{:<8}'.format(credID), + '{:<12}'.format(credType), + u'{:<17}'.format(domain.decode('utf-8')), + u'{:<21}'.format(username.decode('utf-8')), + u'{:<17}'.format(password.decode('utf-8'))) print "" @@ -114,7 +126,11 @@ class CMEDatabaseNavigator(cmd.Cmd): domain = host[3] os = host[4] - print u" {}{}{}{}{}".format('{:<8}'.format(hostID), '{:<17}'.format(ip), '{:<25}'.format(hostname), '{:<17}'.format(domain), '{:<17}'.format(os)) + print u" {}{}{}{}{}".format('{:<8}'.format(hostID), + '{:<17}'.format(ip), + u'{:<25}'.format(hostname.decode('utf-8')), + u'{:<17}'.format(domain.decode('utf-8')), + '{:<17}'.format(os)) print "" @@ -136,7 +152,12 @@ class CMEDatabaseNavigator(cmd.Cmd): links = self.db.get_links(hostID=hostID) - print u" {}{}{}{}{}{}".format('{:<8}'.format(hostID), '{:<15}'.format(str(len(links)) + ' Cred(s)'), '{:<17}'.format(ip), '{:<25}'.format(hostname), '{:<17}'.format(domain), '{:<17}'.format(os)) + print u" {}{}{}{}{}{}".format('{:<8}'.format(hostID), + '{:<15}'.format(str(len(links)) + ' Cred(s)'), + '{:<17}'.format(ip), + u'{:<25}'.format(hostname.decode('utf-8')), + u'{:<17}'.format(domain.decode('utf-8')), + '{:<17}'.format(os)) print "" @@ -158,7 +179,12 @@ class CMEDatabaseNavigator(cmd.Cmd): links = self.db.get_links(credID=credID) - print u" {}{}{}{}{}{}".format('{:<8}'.format(credID), '{:<13}'.format(str(len(links)) + ' Host(s)'), '{:<12}'.format(credType), '{:<17}'.format(domain), '{:<21}'.format(username), '{:<17}'.format(password)) + print u" {}{}{}{}{}{}".format('{:<8}'.format(credID), + '{:<13}'.format(str(len(links)) + ' Host(s)'), + '{:<12}'.format(credType), + u'{:<17}'.format(domain.decode('utf-8')), + u'{:<21}'.format(username.decode('utf-8')), + u'{:<17}'.format(password.decode('utf-8'))) print "" diff --git a/core/connection.py b/core/connection.py index abc32179..50d60b18 100644 --- a/core/connection.py +++ b/core/connection.py @@ -92,16 +92,20 @@ class Connection: if self.admin_privs: self.db.link_cred_to_host('plaintext', self.domain, username, password, self.host) - out = u'{}\\{}:{} {}'.format(self.domain, - username, - password, + out = u'{}\\{}:{} {}'.format(self.domain.decode('utf-8'), + username.decode('utf-8'), + password.decode('utf-8'), highlight('(Pwn3d!)') if self.admin_privs else '') self.logger.success(out) return True except SessionError as e: error, desc = e.getErrorString() - self.logger.error(u'{}\\{}:{} {} {}'.format(self.domain, username, password, error, '({})'.format(desc) if self.args.verbose else '')) + self.logger.error(u'{}\\{}:{} {} {}'.format(self.domain.decode('utf-8'), + username.decode('utf-8'), + password.decode('utf-8'), + error, + '({})'.format(desc) if self.args.verbose else '')) return False def hash_login(self, username, ntlm_hash): @@ -124,8 +128,8 @@ class Connection: if self.admin_privs: self.db.link_cred_to_host('hash', self.domain, username, ntlm_hash, self.host) - out = u'{}\\{} {} {}'.format(self.domain, - username, + out = u'{}\\{} {} {}'.format(self.domain.decode('utf-8'), + username.decode('utf-8'), ntlm_hash, highlight('(Pwn3d!)') if self.admin_privs else '') @@ -133,7 +137,11 @@ class Connection: return True except SessionError as e: error, desc = e.getErrorString() - self.logger.error(u'{}\\{} {} {}'.format(self.domain, username, ntlm_hash, error)) + self.logger.error(u'{}\\{} {} {} {}'.format(self.domain.decode('utf-8'), + username.decode('utf-8'), + ntlm_hash, + error, + '({})'.format(desc) if self.args.verbose else '')) return False def login(self): diff --git a/core/connector.py b/core/connector.py index 393ab8f9..c203c693 100644 --- a/core/connector.py +++ b/core/connector.py @@ -50,7 +50,7 @@ def connector(target, args, db, module, context, cmeserver): logger = CMEAdapter(getLogger('CME'), {'host': remote_ip, 'port': args.smb_port, 'hostname': u'{}'.format(servername)}) - logger.info(u"{} (name:{}) (domain:{})".format(serveros, servername, domain)) + logger.info(u"{} (name:{}) (domain:{})".format(serveros, servername.decode('utf-8'), domain.decode('utf-8'))) try: ''' diff --git a/core/logger.py b/core/logger.py index 7d2eb759..bc95cb05 100644 --- a/core/logger.py +++ b/core/logger.py @@ -48,7 +48,7 @@ class CMEAdapter(logging.LoggerAdapter): return u'{:<25} {}:{} {:<15} {}'.format(module_name, self.extra['host'], self.extra['port'], - self.extra['hostname'] if self.extra['hostname'] else 'NONE', + self.extra['hostname'].decode('utf-8') if self.extra['hostname'] else 'NONE', msg), kwargs def info(self, msg, *args, **kwargs):