Documentation ¶
Overview ¶
Author: Alano Terblanche (Benehiko)
Written with the guidance of Kent Gruber's Medium article (https://medium.com/@KentGruber/building-a-high-performance-port-scanner-with-golang-9976181ec39d) Source: https://gist.github.com/picatz/9c0028efd7b3ced3329f7322f41b16e1#file-port_scanner-go
Index ¶
- Constants
- type OptionPortScanner
- func WithEntireCidr(entireCidr bool) OptionPortScanner
- func WithPorts(ports []int) OptionPortScanner
- func WithProtocol(protocol Protocol) OptionPortScanner
- func WithRestful(restOpts restOptions) OptionPortScanner
- func WithReturnOnlyOpen(onlyOpen bool) OptionPortScanner
- func WithTimeout(timeout int) OptionPortScanner
- type PortScanner
- type Protocol
- type Scheme
Constants ¶
const ( PROTOCOL_UDP = iota PROTOCOL_TCP )
const ( SCHEME_HTTP = iota SCHEME_HTTPS )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptionPortScanner ¶
type OptionPortScanner interface {
// contains filtered or unexported methods
}
func WithEntireCidr ¶
func WithEntireCidr(entireCidr bool) OptionPortScanner
Set to true to scan the entire CIDR block Default is false
func WithPorts ¶
func WithPorts(ports []int) OptionPortScanner
Custom list of ports to scan Default is 80
func WithProtocol ¶
func WithProtocol(protocol Protocol) OptionPortScanner
Set the protocol, either UDP or TCP Default is TCP
func WithRestful ¶
func WithRestful(restOpts restOptions) OptionPortScanner
Add a restful endpoint to test when port is open
func WithReturnOnlyOpen ¶
func WithReturnOnlyOpen(onlyOpen bool) OptionPortScanner
Set to true to only return open devices Default is false
func WithTimeout ¶
func WithTimeout(timeout int) OptionPortScanner
Timeout in milliseconds Default is 1000
type PortScanner ¶
type PortScanner struct {
// contains filtered or unexported fields
}
func NewPortScanner ¶
func NewPortScanner(ipAddr string, opts ...OptionPortScanner) (*PortScanner, error)
Create a new port scanner object Accepts an IP address in the IPv4 format such as eg. "192.168.0.1" or when querying the whole CIDR "192.168.0.0/24" Only the passed IP address with be scanned unless WithEntireCidr is specified in the opts field.
Allow scanning of the entire CIDR with opts WithEntireCidr. Add ports with opts WithPorts. Add a specified timeout in milliseconds with opts WithTimeout. Add a verifying request on top of the port check specifying restful options with opts WithRest Change return value of the Scan request by only returning open ports with opts WithReturnOnlyOpen
func (*PortScanner) Scan ¶
func (ps *PortScanner) Scan() ([]*pkg.GenericDevice, error)
Scan the network with the configurations set in NewPortScanner