Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve and align ftp tls error msg #418

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions modules/ftp/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ func (ftp *Connection) GetFTPSCertificates() error {
ftpsReady, err := ftp.SetupFTPS()

if err != nil {
return err
return fmt.Errorf("error setting up FTPS: %w", err)
}
if !ftpsReady {
return nil
}
var conn *zgrab2.TLSConnection
if conn, err = ftp.config.TLSFlags.GetTLSConnection(ftp.conn); err != nil {
return err
return fmt.Errorf("error setting up TLS connection: %w", err)
}
ftp.results.TLSLog = conn.GetLog()

Expand All @@ -232,20 +232,20 @@ func (ftp *Connection) GetFTPSCertificates() error {
// AUTH TLS succeeds, but the handshake fails, dumping
// "error:1408A0C1:SSL routines:ssl3_get_client_hello:no shared cipher"
// to the socket.
return err
return fmt.Errorf("TLS handshake failed: %w", err)
}
ftp.conn = conn
return nil
}

// Scan performs the configured scan on the FTP server, as follows:
// * Read the banner into results.Banner (if it is not a 2XX response, bail)
// * If the FTPAuthTLS flag is not set, finish.
// * Send the AUTH TLS command to the server. If the response is not 2XX, then
// send the AUTH SSL command. If the response is not 2XX, then finish.
// * Perform ths TLS handshake / any configured TLS scans, populating
// results.TLSLog.
// * Return SCAN_SUCCESS, &results, nil
// - Read the banner into results.Banner (if it is not a 2XX response, bail)
// - If the FTPAuthTLS flag is not set, finish.
// - Send the AUTH TLS command to the server. If the response is not 2XX, then
// send the AUTH SSL command. If the response is not 2XX, then finish.
// - Perform ths TLS handshake / any configured TLS scans, populating
// results.TLSLog.
// - Return SCAN_SUCCESS, &results, nil
func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result interface{}, thrown error) {
var err error
conn, err := t.Open(&s.config.BaseFlags)
Expand Down Expand Up @@ -279,7 +279,7 @@ func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result in
}
if s.config.FTPAuthTLS && is200Banner {
if err := ftp.GetFTPSCertificates(); err != nil {
return zgrab2.SCAN_APPLICATION_ERROR, &ftp.results, err
return zgrab2.TryGetScanStatus(err), &ftp.results, err
developStorm marked this conversation as resolved.
Show resolved Hide resolved
}
}
return zgrab2.SCAN_SUCCESS, &ftp.results, nil
Expand Down
Loading