Documentation ¶
Overview ¶
Package ftp contains the zgrab2 Module implementation for FTP(S).
Setting the --authtls flag will cause the scanner to attempt a upgrade the connection to TLS. Settings for the TLS handshake / probe can be set with the standard TLSFlags.
The scan performs a banner grab and (optionally) a TLS handshake.
The output is the banner, any responses to the AUTH TLS/AUTH SSL commands, and any TLS logs.
Index ¶
- func RegisterModule()
- type Connection
- type Flags
- type Module
- type ScanResults
- type Scanner
- func (s *Scanner) GetName() string
- func (s *Scanner) GetPort() uint
- func (scanner *Scanner) GetTrigger() string
- func (s *Scanner) Init(flags zgrab2.ScanFlags) error
- func (s *Scanner) InitPerSender(senderID int) error
- func (s *Scanner) Protocol() string
- func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result interface{}, thrown error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection holds the state for a single connection to the FTP server.
func (*Connection) GetFTPBanner ¶
func (ftp *Connection) GetFTPBanner() (bool, error)
GetFTPBanner reads the data sent by the server immediately after connecting. Returns true if and only if the server returns a success status code. Taken over from the original zgrab.
func (*Connection) GetFTPSCertificates ¶
func (ftp *Connection) GetFTPSCertificates() error
GetFTPSCertificates attempts to perform a TLS handshake with the server so that the TLS certificates will end up in the TLSLog. First sends the AUTH TLS/AUTH SSL command to tell the server we want to do a TLS handshake. If that fails, break. Otherwise, perform the handshake. Taken over from the original zgrab.
func (*Connection) SetupFTPS ¶
func (ftp *Connection) SetupFTPS() (bool, error)
SetupFTPS returns true if and only if the server reported support for FTPS. First attempt AUTH TLS; if that fails, try AUTH SSL. Taken over from the original zgrab.
type Flags ¶
type Flags struct { zgrab2.BaseFlags zgrab2.TLSFlags Verbose bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"` FTPAuthTLS bool `long:"authtls" description:"Collect FTPS certificates in addition to FTP banners"` }
Flags are the FTP-specific command-line flags. Taken from the original zgrab. (TODO: should FTPAuthTLS be on by default?).
type Module ¶
type Module struct { }
Module implements the zgrab2.Module interface.
func (*Module) NewFlags ¶
func (m *Module) NewFlags() interface{}
NewFlags returns the default flags object to be filled in with the command-line arguments.
func (*Module) NewScanner ¶
NewScanner returns a new Scanner instance.
type ScanResults ¶
type ScanResults struct { // Banner is the initial data banner sent by the server. Banner string `json:"banner,omitempty"` // AuthTLSResp is the response to the AUTH TLS command. // Only present if the FTPAuthTLS flag is set. AuthTLSResp string `json:"auth_tls,omitempty"` // AuthSSLResp is the response to the AUTH SSL command. // Only present if the FTPAuthTLS flag is set and AUTH TLS failed. AuthSSLResp string `json:"auth_ssl,omitempty"` // TLSLog is the standard shared TLS handshake log. // Only present if the FTPAuthTLS flag is set. TLSLog *zgrab2.TLSLog `json:"tls,omitempty"` }
ScanResults is the output of the scan. Identical to the original from zgrab, with the addition of TLSLog.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner implements the zgrab2.Scanner interface, and holds the state for a single scan.
func (*Scanner) GetTrigger ¶
GetTrigger returns the Trigger defined in the Flags.
func (*Scanner) InitPerSender ¶
InitPerSender does nothing in this module.
func (*Scanner) Scan ¶
func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result interface{}, thrown error)
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