Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit c5be1e5

Browse files
author
mpgn
committed
Add exception handler when login fails on MSSQL protocol #364
1 parent bfe1d5b commit c5be1e5

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

cme/protocols/mssql.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,30 +166,38 @@ def check_if_admin(self):
166166
return True
167167

168168
def plaintext_login(self, domain, username, password):
169-
res = self.conn.login(None, username, password, domain, None, self.args.auth_type == 'windows')
170-
if res is not True:
171-
self.conn.printReplies()
172-
if self.args.no_bruteforce:
173-
self.conn.disconnect()
174-
self.create_conn_obj()
175-
return False
176-
177-
self.password = password
178-
self.username = username
179-
self.domain = domain
180-
self.check_if_admin()
181-
self.db.add_credential('plaintext', domain, username, password)
182169

183-
if self.admin_privs:
184-
self.db.add_admin_user('plaintext', domain, username, password, self.host)
170+
try:
171+
res = self.conn.login(None, username, password, domain, None, self.args.auth_type == 'windows')
172+
if res is not True:
173+
self.conn.printReplies()
174+
if self.args.no_bruteforce:
175+
self.conn.disconnect()
176+
self.create_conn_obj()
177+
return False
185178

186-
out = u'{}{}:{} {}'.format('{}\\'.format(domain) if self.args.auth_type == 'windows' else '',
187-
username,
188-
password,
189-
highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else ''))
190-
self.logger.success(out)
191-
if not self.args.continue_on_success:
192-
return True
179+
self.password = password
180+
self.username = username
181+
self.domain = domain
182+
self.check_if_admin()
183+
self.db.add_credential('plaintext', domain, username, password)
184+
185+
if self.admin_privs:
186+
self.db.add_admin_user('plaintext', domain, username, password, self.host)
187+
188+
out = u'{}{}:{} {}'.format('{}\\'.format(domain) if self.args.auth_type == 'windows' else '',
189+
username,
190+
password,
191+
highlight('({})'.format(self.config.get('CME', 'pwn3d_label')) if self.admin_privs else ''))
192+
self.logger.success(out)
193+
if not self.args.continue_on_success:
194+
return True
195+
except Exception as e:
196+
self.logger.error(u'{}\\{}:{} {}'.format(domain,
197+
username,
198+
password,
199+
e))
200+
return False
193201

194202
self.conn.disconnect()
195203
self.create_conn_obj()

0 commit comments

Comments
 (0)