Documentation
¶
Overview ¶
Package http contains the zgrab2 Module implementation for HTTP(S).
The Flags can be configured to perform a specific Method (e.g. "GET") on the specified Path (e.g. "/"). If UseHTTPS is true, the scanner uses TLS for the initial request. The Result contains the final HTTP response following each response in the redirect chain.
Index ¶
- Variables
- func RegisterModule()
- type Flags
- type Module
- type Results
- type Scanner
- func (scanner *Scanner) GetName() string
- func (scanner *Scanner) GetTrigger() string
- func (scanner *Scanner) Init(flags zgrab2.ScanFlags) error
- func (scanner *Scanner) InitPerSender(senderID int) error
- func (s *Scanner) Protocol() string
- func (scanner *Scanner) Scan(t zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRedirLocalhost is returned when an HTTP redirect points to localhost, // unless FollowLocalhostRedirects is set. ErrRedirLocalhost = errors.New("Redirecting to localhost") // ErrTooManyRedirects is returned when the number of HTTP redirects exceeds // MaxRedirects. ErrTooManyRedirects = errors.New("Too many redirects") )
Functions ¶
func RegisterModule ¶
func RegisterModule()
RegisterModule is called by modules/http.go to register this module with the zgrab2 framework.
Types ¶
type Flags ¶
type Flags struct { zgrab2.BaseFlags zgrab2.TLSFlags Method string `long:"method" default:"GET" description:"Set HTTP request method type"` Endpoint string `long:"endpoint" default:"/" description:"Send an HTTP request to an endpoint"` UserAgent string `long:"user-agent" default:"Mozilla/5.0 zgrab/0.x" description:"Set a custom user agent"` RetryHTTPS bool `long:"retry-https" description:"If the initial request fails, reconnect and try with HTTPS."` MaxSize int `long:"max-size" default:"256" description:"Max kilobytes to read in response to an HTTP request"` MaxRedirects int `long:"max-redirects" default:"0" description:"Max number of redirects to follow"` // FollowLocalhostRedirects overrides the default behavior to return // ErrRedirLocalhost whenever a redirect points to localhost. FollowLocalhostRedirects bool `long:"follow-localhost-redirects" description:"Follow HTTP redirects to localhost"` // UseHTTPS causes the first request to be over TLS, without requiring a // redirect to HTTPS. It does not change the port used for the connection. UseHTTPS bool `long:"use-https" description:"Perform an HTTPS connection on the initial host"` // RedirectsSucceed causes the ErrTooManRedirects error to be suppressed RedirectsSucceed bool `long:"redirects-succeed" description:"Redirects are always a success, even if max-redirects is exceeded"` }
Flags holds the command-line configuration for the HTTP scan module. Populated by the framework.
TODO: Custom headers?
type Module ¶
type Module struct { }
Module is an implementation of the zgrab2.Module interface.
func (*Module) Description ¶ added in v0.1.3
Description returns an overview of this module.
func (*Module) NewFlags ¶
func (module *Module) NewFlags() interface{}
NewFlags returns an empty Flags object.
func (*Module) NewScanner ¶
NewScanner returns a new instance Scanner instance.
type Results ¶
type Results struct { // Result is the final HTTP response in the RedirectResponseChain Response *http.Response `json:"response,omitempty"` // RedirectResponseChain is non-empty is the scanner follows a redirect. // It contains all redirect response prior to the final response. RedirectResponseChain []*http.Response `json:"redirect_response_chain,omitempty"` }
A Results object is returned by the HTTP module's Scanner.Scan() implementation.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is the implementation of the zgrab2.Scanner interface.
func (*Scanner) GetTrigger ¶
GetTrigger returns the Trigger defined in the Flags.
func (*Scanner) InitPerSender ¶
InitPerSender does nothing in this module.
func (*Scanner) Scan ¶
func (scanner *Scanner) Scan(t zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error)
Scan implements the zgrab2.Scanner interface and performs the full scan of the target. If the scanner is configured to follow redirects, this may entail multiple TCP connections to hosts other than target.