Skip to content

Commit e7e23bf

Browse files
committed
Improve updateBruteResult behavior
If this BruteForceResult was an error.. as in, not a positive or negative result, don't update anything. We can't say definitively that the credential does or does not work. Also update the seen_last field on the hosts table, since a non-err BruteForceResult means the system was reachable.
1 parent 7fce102 commit e7e23bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sshauditor/store.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,23 @@ func (s *SQLiteStore) getRescanQueue() ([]ScanRequest, error) {
370370
}
371371

372372
func (s *SQLiteStore) updateBruteResult(br BruteForceResult) error {
373+
if br.err != nil {
374+
//If this BruteForceResult was an error.. as in, not a positive or
375+
//negative result, don't update anything. We can't say definitively
376+
//that the credential does or does not work.
377+
return nil
378+
}
373379
_, err := s.Exec(`UPDATE host_creds set last_tested=datetime('now', 'localtime'), result=$1
374380
WHERE hostport=$2 AND user=$3 AND password=$4`,
375381
br.result, br.hostport, br.cred.User, br.cred.Password)
382+
if err != nil {
383+
return errors.Wrap(err, "updateBruteResult")
384+
}
385+
//Also update the seen_last field on the hosts table, since a non-err
386+
//BruteForceResult means the system was reachable.
387+
_, err = s.Exec(
388+
"UPDATE hosts SET seen_last=datetime('now', 'localtime') WHERE hostport=$1",
389+
br.hostport)
376390
return errors.Wrap(err, "updateBruteResult")
377391
}
378392

0 commit comments

Comments
 (0)