Skip to content

Commit

Permalink
fix SA warning, suppress info messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Hynek Petrak committed Jun 26, 2021
1 parent 8709630 commit c208fdf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sshame/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def get_keys_to_test(self, host, port, username):
Ordered by number of host, that a key can logon to."""

vk = self.get_valued_keys().subquery()
tk = self.get_tested_keys(host, port, username).subquery()
tk = self.get_tested_keys(host, port, username) #.subquery()

q = (self.db.query(vk.c.fingerprint, vk.c.private_key)
.filter(vk.c.fingerprint.notin_(tk))
Expand Down Expand Up @@ -505,8 +505,7 @@ def keys_left(self):
return len(self._keylist)

def connection_made(self, conn):
self.host = conn.get_extra_info('peername')[0]
log.debug(f'[+] [{self.log_id}] Connection made.')
log.debug(f'[+] [{self.log_id}] Connection made')

def connection_lost(self, exc):
log.debug(f'[-] [{self.log_id}] connection_lost: {str(exc)}')
Expand All @@ -532,11 +531,15 @@ def auth_completed(self):
self.db.commit()
self.key_fingerprint = None

def password_auth_requested(self):
log.debug(f'[*] [{self.log_id}] Password authentication requested')
return None

def public_key_auth_requested(self):
if self.key_fingerprint:
cred = self.db.query(Credential).filter(Credential.host_address == self.host_address).filter(Credential.host_port == self.host_port).filter(
Credential.key_fingerprint == self.key_fingerprint).filter(Credential.username == self.username).first()
log.debug(str(cred))
#log.debug(f'[{self.log_id] [D] Cred: str(cred)')
if not cred:
cred = Credential(host_address=self.host_address, host_port=self.host_port,
key_fingerprint=self.key_fingerprint, username=self.username)
Expand Down Expand Up @@ -579,7 +582,7 @@ def client_factory():
log.debug(f'[{log_id}] All {_pkssh.keys_to_test} keys tested.')
return valid_creds # Exception("No more keys")
if (_pkssh.keys_consumed() == keys_consumed):
log.info(f'[{log_id}] No keys consumed, but: {msg}')
log.debug(f'[{log_id}] No keys consumed, but: {msg}')
return valid_creds
keys_consumed = _pkssh.keys_consumed()
ignore = ['Permission denied', 'Too many authentication', 'Connection reset by peer',
Expand Down

0 comments on commit c208fdf

Please sign in to comment.