ftp

package
v0.0.0-...-e4757b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2021 License: Apache-2.0, Apache-2.0, ISC Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterModule

func RegisterModule()

RegisterModule registers the ftp zgrab2 module.

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?).

func (*Flags) Help

func (f *Flags) Help() string

Help returns this module's help string.

func (*Flags) Validate

func (f *Flags) Validate(args []string) error

Validate does nothing in this module.

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

func (m *Module) NewScanner() zgrab2.Scanner

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) GetName

func (s *Scanner) GetName() string

GetName returns the configured name for the Scanner.

func (*Scanner) GetPort

func (s *Scanner) GetPort() uint

GetPort returns the configured port for the Scanner.

func (*Scanner) GetTrigger

func (scanner *Scanner) GetTrigger() string

GetTrigger returns the Trigger defined in the Flags.

func (*Scanner) Init

func (s *Scanner) Init(flags zgrab2.ScanFlags) error

Init initializes the Scanner instance with the flags from the command line.

func (*Scanner) InitPerSender

func (s *Scanner) InitPerSender(senderID int) error

InitPerSender does nothing in this module.

func (*Scanner) Protocol

func (s *Scanner) Protocol() string

Protocol returns the protocol identifer for the scanner.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL