Documentation
¶
Index ¶
- Constants
- Variables
- func ACKPort(listenHandler *ListenHandler, dstIP string, port int, timeout time.Duration) (bool, error)
- func CleanupHandlersUnix()
- func EthernetWriteWorker(ch <-chan *PkgSend)
- func GetInterfaceFromIP(ip net.IP) (*net.Interface, error)
- func ICMPWriteWorker()
- func ParseTimestamp(_ int, b []byte) (icmp.MessageBody, error)
- func PingIcmpAddressMaskRequestAsync(ip string)
- func PingIcmpEchoRequest(ip string, timeout time.Duration) bool
- func PingIcmpEchoRequestAsync(ip string)
- func PingIcmpTimestampRequest(ip string, timeout time.Duration) bool
- func PingIcmpTimestampRequestAsync(ip string)
- func PingNdpRequestAsync(ip string)
- func SendAsyncPkg(listenHandler *ListenHandler, ip string, p *port.Port, pkgFlag PkgFlag)
- func SetupHandler(interfaceName string) error
- func SetupHandlerUnix(interfaceName, bpfFilter string, protocols ...protocol.Protocol) error
- func SetupHandlers() error
- func ToString(ip net.IP) string
- func TransportReadWorker()
- func TransportWriteWorker()
- func WhatsMyIP() (string, error)
- type AddressMask
- type Handlers
- type ListenHandler
- type Options
- type Phase
- type Ping
- type PingResult
- type PingResultType
- type PkgFlag
- type PkgResult
- type PkgSend
- type Scanner
- func (s *Scanner) CdnCheck(ip string) (bool, string, error)
- func (s *Scanner) Close() error
- func (s *Scanner) ConnectPort(host, payload string, p *port.Port, timeout time.Duration) (bool, error)
- func (s *Scanner) ConnectVerify(host string, ports []*port.Port) []*port.Port
- func (s *Scanner) EnqueueEthernet(ip string, pkgtype PkgFlag)
- func (s *Scanner) EnqueueICMP(ip string, pkgtype PkgFlag)
- func (s *Scanner) EnqueueTCP(ip string, pkgtype PkgFlag, ports ...*port.Port)
- func (s *Scanner) EnqueueUDP(ip string, ports ...*port.Port)
- func (s *Scanner) ICMPResultWorker(ctx context.Context)
- func (s *Scanner) ScanSyn(ip string)
- func (s *Scanner) StartWorkers(ctx context.Context)
- func (s *Scanner) TCPResultWorker(ctx context.Context)
- func (s *Scanner) UDPResultWorker(ctx context.Context)
- type State
- type TCPSequencer
- type Timestamp
Constants ¶
const ( TypeSyn = "s" TypeConnect = "c" )
const ( DeadlineSec = 10 ProtocolICMP = 1 ProtocolIPv6ICMP = 58 )
Some constants
const ( IPv4 = "4" IPv6 = "6" )
Variables ¶
var ( ListenHandlers []*ListenHandler NetworkInterface string PkgRouter routing.Router ArpRequestAsync func(ip string) InitScanner func(s *Scanner) error NumberOfHandlers = 1 )
var (
EnableTLSDetection = envutil.GetEnvOrDefault("ENABLE_TLS_DETECTION", false) // Enable TLS detection for connect scans
)
Functions ¶
func ACKPort ¶
func ACKPort(listenHandler *ListenHandler, dstIP string, port int, timeout time.Duration) (bool, error)
ACKPort sends an ACK packet to a port
func EthernetWriteWorker ¶
func EthernetWriteWorker(ch <-chan *PkgSend)
EthernetWriteWorker writes packet to the network layer
func GetInterfaceFromIP ¶
GetInterfaceFromIP gets the name of the network interface from local ip address
func ParseTimestamp ¶
func ParseTimestamp(_ int, b []byte) (icmp.MessageBody, error)
ParseTimestamp to MessageBody structure
func PingIcmpAddressMaskRequestAsync ¶
func PingIcmpAddressMaskRequestAsync(ip string)
PingIcmpAddressMaskRequestAsync asynchronous to the target ip address - ipv4 only
func PingIcmpEchoRequest ¶
PingIcmpEchoRequest synchronous to the target ip address
func PingIcmpEchoRequestAsync ¶
func PingIcmpEchoRequestAsync(ip string)
PingIcmpEchoRequestAsync asynchronous to the target ip address
func PingIcmpTimestampRequest ¶
PingIcmpTimestampRequest synchronous to the target ip address
func PingIcmpTimestampRequestAsync ¶
func PingIcmpTimestampRequestAsync(ip string)
PingIcmpTimestampRequestAsync synchronous to the target ip address - ipv4 only
func PingNdpRequestAsync ¶
func PingNdpRequestAsync(ip string)
PingNdpRequestAsync asynchronous to the target ip address
func SendAsyncPkg ¶
func SendAsyncPkg(listenHandler *ListenHandler, ip string, p *port.Port, pkgFlag PkgFlag)
SendAsyncPkg sends a single packet to a port
func SetupHandler ¶
func SetupHandlerUnix ¶
SetupHandlerUnix on unix OS
func SetupHandlers ¶
func SetupHandlers() error
func TransportReadWorker ¶
func TransportReadWorker()
func TransportWriteWorker ¶
func TransportWriteWorker()
TCPWriteWorker that sends out TCP|UDP packets
Types ¶
type AddressMask ¶
AddressMask ICMP structure
type Handlers ¶
type Handlers struct {
InterfaceHandle map[string]*pcap.Handle
TransportActive []*pcap.Handle
LoopbackHandlers []*pcap.Handle
TransportInactive []*pcap.InactiveHandle
EthernetActive []*pcap.Handle
EthernetInactive []*pcap.InactiveHandle
}
Handlers contains the list of pcap handlers
type ListenHandler ¶
type ListenHandler struct {
Busy bool
Phase *Phase
SourceHW net.HardwareAddr
SourceIp4 net.IP
SourceIP6 net.IP
Port int
TcpConn4, UdpConn4, TcpConn6, UdpConn6 *net.IPConn
TcpChan, UdpChan, HostDiscoveryChan chan *PkgResult
}
func Acquire ¶
func Acquire(options *Options) (*ListenHandler, error)
func NewListenHandler ¶
func NewListenHandler() *ListenHandler
func (*ListenHandler) ICMPReadWorker4 ¶
func (l *ListenHandler) ICMPReadWorker4()
ICMPReadWorker4 reads packets from the network layer
func (*ListenHandler) ICMPReadWorker6 ¶
func (l *ListenHandler) ICMPReadWorker6()
ICMPReadWorker6 reads packets from the network layer
func (*ListenHandler) Release ¶
func (l *ListenHandler) Release()
func (*ListenHandler) TcpReadWorker4 ¶
func (l *ListenHandler) TcpReadWorker4()
func (*ListenHandler) TcpReadWorker6 ¶
func (l *ListenHandler) TcpReadWorker6()
func (*ListenHandler) UdpReadWorker4 ¶
func (l *ListenHandler) UdpReadWorker4()
func (*ListenHandler) UdpReadWorker6 ¶
func (l *ListenHandler) UdpReadWorker6()
type Options ¶
type Options struct {
Timeout time.Duration
Retries int
Rate int
PortThreshold int
ExcludeCdn bool
OutputCdn bool
ExcludedIps []string
Proxy string
ProxyAuth string
Stream bool
OnReceive result.ResultFn
ScanType string
NetworkPolicyOptions *networkpolicy.Options
}
Options of the scan
type Ping ¶
type Ping struct {
Type PingResultType
Latency time.Duration
Error error
Host string
}
Ping contains the results for ping on a single host
type PingResult ¶
type PingResult struct {
Hosts []Ping
}
PingResult contains the results for the Ping request
func PingHosts ¶
func PingHosts(addresses []string) (*PingResult, error)
PingHosts pings the addresses given and returns the latencies of each host If the address returns an error, that address is marked as unusable.
func (*PingResult) GetFastestHost ¶
func (p *PingResult) GetFastestHost() (Ping, error)
GetFastestHost gets the fastest host from the ping responses
type PingResultType ¶
type PingResultType int
PingResultType contains the type of result for ping request on an address
const ( HostInactive PingResultType = iota HostActive )
Type of ping responses
type PkgResult ¶
type PkgResult struct {
// contains filtered or unexported fields
}
PkgResult contains the results of sending TCP packages
type PkgSend ¶
type PkgSend struct {
ListenHandler *ListenHandler
SourceIP string
// contains filtered or unexported fields
}
PkgSend is a TCP package
type Scanner ¶
type Scanner struct {
Ports []*port.Port
IPRanger *ipranger.IPRanger
HostDiscoveryResults *result.Result
ScanResults *result.Result
NetworkInterface *net.Interface
ScanType string
ListenHandler *ListenHandler
OnReceive result.ResultFn
// contains filtered or unexported fields
}
func NewScanner ¶
NewScanner creates a new full port scanner that scans all ports using SYN packets.
func (*Scanner) ConnectPort ¶
func (s *Scanner) ConnectPort(host, payload string, p *port.Port, timeout time.Duration) (bool, error)
ConnectPort a single host and port
func (*Scanner) ConnectVerify ¶
ConnectVerify is used to verify if ports are accurate using a connect request
func (*Scanner) EnqueueEthernet ¶
EnqueueEthernet outgoing Ethernet packets
func (*Scanner) EnqueueICMP ¶
EnqueueICMP outgoing ICMP packets
func (*Scanner) EnqueueTCP ¶
EnqueueTCP outgoing TCP packets
func (*Scanner) EnqueueUDP ¶
EnqueueTCP outgoing TCP packets
func (*Scanner) ICMPResultWorker ¶
ICMPResultWorker handles ICMP responses (used only during probes)
func (*Scanner) StartWorkers ¶
StartWorkers of the scanner
func (*Scanner) TCPResultWorker ¶
TCPResultWorker handles probes and scan results
func (*Scanner) UDPResultWorker ¶
UDPResultWorker handles probes and scan results
type TCPSequencer ¶
type TCPSequencer struct {
// contains filtered or unexported fields
}
TCPSequencer generates linear TCP sequence numbers that wrap around after reaching their maximum value.
According to specs, this is the correct way to approach TCP sequence number since linearity will be guaranteed by the wrapping around to initial 0.
func NewTCPSequencer ¶
func NewTCPSequencer() *TCPSequencer
NewTCPSequencer creates a new linear tcp sequenc enumber generator
func (*TCPSequencer) Next ¶
func (t *TCPSequencer) Next() uint32
Next returns the next number in the sequence of tcp sequence numbers