Documentation
¶
Overview ¶
Package masscan provides idiomatic `masscan` bindings for go developers.
Index ¶
- Variables
- type Host
- type Option
- func WithAdapterIP(adapterIP string) Option
- func WithAdapterMAC(mac string) Option
- func WithAdapterPort(port int) Option
- func WithBanners() Option
- func WithBinaryPath(binaryPath string) Option
- func WithConfigPath(config string) Option
- func WithDebug() Option
- func WithExclude(excludes ...string) Option
- func WithExcludeFile(path string) Option
- func WithFilterHost(hostFilter func(Host) bool) Option
- func WithFilterPort(portFilter func(Port) bool) Option
- func WithInterface(iface string) Option
- func WithOpenOnly() Option
- func WithOutputFormat(format OutputFormat) Option
- func WithPing() Option
- func WithPorts(ports ...string) Option
- func WithRate(maxRate int) Option
- func WithRawFlag(flag string) Option
- func WithRawOption(flag, value string) Option
- func WithResumeCount(count int) Option
- func WithResumeIndex(index int) Option
- func WithRouterMAC(mac string) Option
- func WithSeed(seed int) Option
- func WithShard(x, y int) Option
- func WithSourceIP(sourceIP string) Option
- func WithSourcePort(sourcePort int) Option
- func WithTargets(targets ...string) Option
- func WithTopPorts(count int) Option
- func WithWait(delay int) Option
- type OutputFormat
- type Port
- type Run
- type ScanRunner
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMasscanNotInstalled means that upon trying to manually locate masscan in the user's path, // it was not found. Either use the WithBinaryPath method to set it manually, or make sure that // the masscan binary is present in the user's $PATH. ErrMasscanNotInstalled = errors.New("masscan binary was not found") // ErrScanTimeout means that the provided context timeout triggered done before the scanner finished its scan. // This error is *not* returned if a scan timeout was configured using Masscan arguments, since Masscan would // gracefully shut down it's scanning and return some results in that case. ErrScanTimeout = errors.New("masscan scan timed out") // ErrScanInterrupt means that the scan was interrupted before the scanner finished its scan. // Reasons for this error might be sigint or a cancelled context. ErrScanInterrupt = errors.New("masscan scan interrupted") // ErrParseOutput means that masscan's output was not parsed successfully. ErrParseOutput = errors.New("masscan output parsing failure, see warnings for details") // ErrUnsupportedOutputFormat means that the requested masscan output format // cannot be parsed by this package. ErrUnsupportedOutputFormat = errors.New("unsupported masscan output format") // ErrInvalidOutput means that masscan returned output that could not be decoded. ErrInvalidOutput = errors.New("invalid masscan output") // ErrMallocFailed means that masscan failed because it could not allocate memory. ErrMallocFailed = errors.New("masscan malloc failed") // ErrRequiresRoot means that a feature (e.g. OS detection) requires root privileges. ErrRequiresRoot = errors.New("this feature requires root privileges") // ErrResolveName means that masscan could not resolve a name. ErrResolveName = errors.New("masscan could not resolve a name") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
Option configures a Scanner by adding or changing masscan arguments.
func WithAdapterIP ¶
WithAdapterIP sets adapter IP address (--adapter-ip).
func WithAdapterMAC ¶
WithAdapterMAC sets adapter MAC address (--adapter-mac).
func WithAdapterPort ¶
WithAdapterPort sets adapter/source port (--adapter-port).
func WithBinaryPath ¶
WithBinaryPath sets the masscan binary path for a scanner.
func WithConfigPath ¶
WithConfigPath sets the configuration file path (--conf).
func WithExclude ¶
WithExclude excludes targets from scan (--exclude).
func WithExcludeFile ¶
WithExcludeFile excludes targets from a file (--excludefile).
func WithFilterHost ¶
WithFilterHost allows to set a custom function to filter out hosts that don't fulfill a given condition. When the given function returns true, the host is kept, otherwise it is removed from the result. Can be used along with WithFilterPort.
func WithFilterPort ¶
WithFilterPort allows to set a custom function to filter out ports that don't fulfill a given condition. When the given function returns true, the port is kept, otherwise it is removed from the result. Can be used along with WithFilterHost.
func WithInterface ¶
WithInterface sets outgoing interface (--interface).
func WithOpenOnly ¶
func WithOpenOnly() Option
WithOpenOnly limits output to open ports only (--open-only).
func WithOutputFormat ¶
func WithOutputFormat(format OutputFormat) Option
WithOutputFormat sets output format for parsing. If explicit -o* args are passed, masscan will use them instead.
func WithRawFlag ¶
WithRawFlag appends a raw masscan flag with no value.
func WithRawOption ¶
WithRawOption appends a raw masscan option and value pair.
func WithResumeCount ¶
WithResumeCount scans count from resumed point (--resume-count).
func WithResumeIndex ¶
WithResumeIndex resumes from paused index (--resume-index).
func WithRouterMAC ¶
WithRouterMAC sets router MAC (--router-mac).
func WithSourceIP ¶
WithSourceIP sets source IP address (--source-ip).
func WithSourcePort ¶
WithSourcePort sets source port (--source-port).
func WithTargets ¶
WithTargets sets targets to scan (CIDR/range/single address/hostname).
func WithTopPorts ¶
WithTopPorts sets top port count (--top-ports).
type OutputFormat ¶
type OutputFormat string
OutputFormat is the output format produced by masscan.
const ( OutputFormatJSON OutputFormat = "json" OutputFormatXML OutputFormat = "xml" OutputFormatList OutputFormat = "list" OutputFormatGrepable OutputFormat = "grepable" OutputFormatBinary OutputFormat = "binary" OutputFormatUnknown OutputFormat = "unknown" )
OutputFormat values supported by this package.
type Run ¶
type Run struct {
Hosts []Host
// contains filtered or unexported fields
}
Run represents the parsed output of a masscan execution.
type ScanRunner ¶
ScanRunner represents something that can run a scan.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner represents a Masscan scanner.
func NewScanner ¶
NewScanner creates a new Scanner, and can take options to apply to the scanner.
func (*Scanner) AddOptions ¶
AddOptions sets more scan options after the scan is created.
func (*Scanner) Run ¶
Run executes masscan with the enabled options and parses the resulting output.
func (*Scanner) ToFile ¶
ToFile enables the Scanner to write the masscan XML output to a given path. Masscan writes the normal CLI output to stdout. The XML is parsed from file after the scan is finished.
func (*Scanner) WithOutputFormat ¶
func (s *Scanner) WithOutputFormat(format OutputFormat) (*Scanner, error)
WithOutputFormat sets the parser output preference when an explicit output flag is not already set.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
banner_scan
command
|
|
|
basic_scan
command
|
|
|
distributed_shard
command
|
|
|
interface_scan
command
|
|
|
rate_limited_scan
command
|
|
|
internal
|
|