ports

package
v0.0.0-...-6fd5be8 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
const (
	PROTOCOL_UDP = iota
	PROTOCOL_TCP
)
View Source
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

type Protocol

type Protocol uint

func (Protocol) Value

func (p Protocol) Value() string

type Scheme

type Scheme uint

func (Scheme) Value

func (s Scheme) Value() string

Jump to

Keyboard shortcuts

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