Documentation
¶
Index ¶
- Constants
- func GetDefaultICMPClient() *icmpClient.Client
- func GetTCPPayload(buffer *stack.PacketBuffer) []byte
- func MaskToIPString(mask net.IPMask) string
- func NewNetStackFromConfig(c *Config) (*stack.Stack, error)
- func NewPCAPAdaptor(ifaceName string, mtu int32, promisc bool) (*pcapAdaptor, error)
- func ReadServerName(data []byte) string
- type AliveTargetMonitor
- type Config
- type NIC
- type NetStackVirtualMachine
- func (m *NetStackVirtualMachine) DialTCP(timeout time.Duration, target string) (net.Conn, error)
- func (m *NetStackVirtualMachine) GetEntry(id tcpip.NICID) (*NetStackVirtualMachineEntry, bool)
- func (m *NetStackVirtualMachine) GetStack() *stack.Stack
- func (m *NetStackVirtualMachine) ListenTCP(addr string) (net.Listener, error)
- func (m *NetStackVirtualMachine) SetEntry(id tcpip.NICID, vm *NetStackVirtualMachineEntry)
- type NetStackVirtualMachineEntry
- func (vm *NetStackVirtualMachineEntry) AddDefaultRoute(gateway net.IP) error
- func (vm *NetStackVirtualMachineEntry) AllowTCP(destinationAddr string)
- func (vm *NetStackVirtualMachineEntry) AllowTCPWithSrc(destinationAddr string, srcAddr string)
- func (vm *NetStackVirtualMachineEntry) DialTCP(timeout time.Duration, hostport string) (net.Conn, error)
- func (vm *NetStackVirtualMachineEntry) DisallowTCP(destinationAddr string)
- func (vm *NetStackVirtualMachineEntry) DisallowTCPWithSrc(destinationAddr string, srcAddr string)
- func (vm *NetStackVirtualMachineEntry) GetMTU() int
- func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Address() net.IP
- func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Gateway() net.IP
- func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Netmask() *net.IPNet
- func (vm *NetStackVirtualMachineEntry) GetMainNICLinkAddress() net.HardwareAddr
- func (vm *NetStackVirtualMachineEntry) GetOSNetStackIPv4() (net.IP, net.IP, net.IPMask)
- func (vm *NetStackVirtualMachineEntry) GetOSNetStackIPv6() (net.IP, net.IP, net.IPMask)
- func (vm *NetStackVirtualMachineEntry) GetPcapInterfaceNeighborRoute() (tcpip.Route, error)
- func (vm *NetStackVirtualMachineEntry) GetStack() *stack.Stack
- func (vm *NetStackVirtualMachineEntry) GetSystemInterface() *net.Interface
- func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceConfig() error
- func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceIP() error
- func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceNeighborRoute() error
- func (vm *NetStackVirtualMachineEntry) ListenTCP(hostport string) (net.Listener, error)
- func (vm *NetStackVirtualMachineEntry) MainNICID() tcpip.NICID
- func (vm *NetStackVirtualMachineEntry) SetDefaultRoute(gateway net.IP) error
- func (vm *NetStackVirtualMachineEntry) SetFilterForSynScan()
- func (vm *NetStackVirtualMachineEntry) SetMainNICv4(ipAddr net.IP, netmask *net.IPNet, getaway net.IP) error
- func (m *NetStackVirtualMachineEntry) StartAnnounceARP() error
- func (vm *NetStackVirtualMachineEntry) StartDHCP() error
- func (vm *NetStackVirtualMachineEntry) Wait()
- func (t *NetStackVirtualMachineEntry) WaitDHCPFinished(ctx context.Context) error
- type NetstackSniffer
- type Option
- func WithARPDisabled(disabled bool) Option
- func WithContext(ctx context.Context) Option
- func WithDHCPDisabled(disabled bool) Option
- func WithDisableForwarding(v bool) Option
- func WithDisallowPacketEndpointWrite(disallow bool) Option
- func WithEnableLinkLayer(enable bool) Option
- func WithForceSystemNetStack(force bool) Option
- func WithHandleLocal(handleLocal bool) Option
- func WithICMPDisabled(disabled bool) Option
- func WithIPv4Disabled(disabled bool) Option
- func WithIPv6Disabled(disabled bool) Option
- func WithMainNICIPAddress(ipAddress string) Option
- func WithMainNICLinkAddress(linkAddress string) Option
- func WithNetStack(netStack *stack.Stack) Option
- func WithOnTCPConnectionRequested(fn func(*tcpip.FullAddress, *tcpip.FullAddress)) Option
- func WithPCAPInboundFilter(filter func(packet gopacket.Packet) bool) Option
- func WithPCAPOutboundFilter(filter func(packet gopacket.Packet) bool) Option
- func WithPcapCapabilities(capabilities stack.LinkEndpointCapabilities) Option
- func WithPcapDevice(device string) Option
- func WithPcapPromisc(promisc bool) Option
- func WithRandomMainNICLinkAddress() Option
- func WithTCPDisabled(disabled bool) Option
- func WithUDPDisabled(disabled bool) Option
- type PCAPEndpoint
- func (p *PCAPEndpoint) AllowTCP(addr string)
- func (p *PCAPEndpoint) AllowTCPWithSrc(addr string, src string)
- func (p *PCAPEndpoint) Attach(dispatcher stack.NetworkDispatcher)
- func (p *PCAPEndpoint) Capabilities() stack.LinkEndpointCapabilities
- func (p *PCAPEndpoint) Close()
- func (p *PCAPEndpoint) DisallowTCP(addr string)
- func (p *PCAPEndpoint) DisallowTCPWithSrc(addr string, src string)
- func (p *PCAPEndpoint) SetCapabilities(flag stack.LinkEndpointCapabilities)
- func (p *PCAPEndpoint) SetGatewayHardwareAddr(hwAddr net.HardwareAddr)
- func (p *PCAPEndpoint) SetGatewayIP(g net.IP)
- func (p *PCAPEndpoint) SetLoopback(b bool)
- func (p *PCAPEndpoint) SetPCAPInboundFilter(filter func(packet gopacket.Packet) bool)
- func (p *PCAPEndpoint) SetPCAPOutboundFilter(filter func(packet gopacket.Packet) bool)
- func (p *PCAPEndpoint) Wait()
- type TCPAliveInfo
- type TCPKey
- type TunSpoofingListener
- type TunVirtualMachine
- func (t *TunVirtualMachine) Close() error
- func (t *TunVirtualMachine) GetListener() *TunSpoofingListener
- func (t *TunVirtualMachine) GetTunnelName() string
- func (t *TunVirtualMachine) HijackDomain(domain string) error
- func (t *TunVirtualMachine) HijackIP(ip string) error
- func (t *TunVirtualMachine) HijackIPNet(ipNet *net.IPNet) error
- func (t *TunVirtualMachine) ListenTCP() (*TunVmTCPListener, error)
- func (t *TunVirtualMachine) SetHijackTCPHandler(handle func(conn netstack.TCPConn)) error
- type TunVmTCPListener
Constants ¶
View Source
const TUN_MTU = 3200
TUN_MTU is the default MTU for TUN device. 1420 is wg default MTU, use it for compatibility.
View Source
const UTUNINDEXSTART = 410
Variables ¶
This section is empty.
Functions ¶
func GetDefaultICMPClient ¶
func GetDefaultICMPClient() *icmpClient.Client
func GetTCPPayload ¶
func GetTCPPayload(buffer *stack.PacketBuffer) []byte
func MaskToIPString ¶
func NewPCAPAdaptor ¶
NewPCAPAdaptor creates a new pcap adaptor for the given interface. It reuses existing adaptors if one already exists for the interface.
func ReadServerName ¶
Types ¶
type AliveTargetMonitor ¶
type AliveTargetMonitor struct {
// contains filtered or unexported fields
}
func StartTargetMonitor ¶
func StartTargetMonitor() (*AliveTargetMonitor, error)
func (*AliveTargetMonitor) GetAliveDomain ¶
func (m *AliveTargetMonitor) GetAliveDomain() []string
func (*AliveTargetMonitor) GetAliveIP ¶
func (m *AliveTargetMonitor) GetAliveIP() map[string]int
type Config ¶
type Config struct {
// stack options
IPv4Disabled bool
IPv6Disabled bool
DHCPDisabled bool
ARPDisabled bool
ICMPDisabled bool
HandleLocal bool
TCPDisabled bool
UDPDisabled bool
DisallowPacketEndpointWrite bool
EnableLinkLayer bool
OnTCPConnectionRequested func(*tcpip.FullAddress, *tcpip.FullAddress)
DisableForwarding bool
//dhcp config
DHCPAcquireTimeout time.Duration
DHCPAcquireInterval time.Duration
DHCPAcquireRetryInterval time.Duration
DHCPAcquireCallback func(ctx context.Context, lost, acquired tcpip.AddressWithPrefix, cfg gvisorDHCP.Config)
//arp config
ARPAnnouncementFastInterval time.Duration
ARPAnnouncementFastTimes int
ARPAnnouncementSlowInterval time.Duration
// nic options
MainNICIPv4Address string
MainNICIPv4AddressNetmask string
MainNICIPv6Address string
MainNICIPv6AddressNetmask string
MainNICLinkAddress net.HardwareAddr
// tcp options
// DefaultTTL specifies the default TTL used by stack
DefaultTTL uint8
// ICMPBurst is the number of ICMP messages that can be sent in a single burst
ICMPBurst int
// ICMPLimit is the maximum number of ICMP messages permitted by rate limiter
ICMPLimit rate.Limit
// TCPSendBufferSizeMin is the smallest size of a send buffer
TCPSendBufferSizeMin int
// TCPSendBufferSizeMax is the maximum permitted size of a send buffer
TCPSendBufferSizeMax int
// TCPSendBufferSizeDefault is the default size of the send buffer
TCPSendBufferSizeDefault int
// TCPReceiveBufferSizeMin is the smallest size of a receive buffer
TCPReceiveBufferSizeMin int
// TCPReceiveBufferSizeMax is the maximum permitted size of a receive buffer
TCPReceiveBufferSizeMax int
// TCPReceiveBufferSizeDefault is the default size of the receive buffer
TCPReceiveBufferSizeDefault int
// TCPCongestionControl is the congestion control algorithm used by TCP (reno or cubic)
TCPCongestionControl string
// TCPDelayEnabled enables/disables Nagle's algorithm for TCP
TCPDelayEnabled bool
// TCPModerateReceiveBuffer enables/disables TCP receive buffer auto-tuning
TCPModerateReceiveBuffer bool
// TCPSACKEnabled enables/disables TCP selective acknowledgment
TCPSACKEnabled bool
// TCPRACKLossDetection specifies the TCP loss detection algorithm
TCPRACKLossDetection tcpip.TCPRecovery
// force use system net stack, not dhcp
ForceSystemNetStack bool
// contains filtered or unexported fields
}
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type NetStackVirtualMachine ¶
type NetStackVirtualMachine struct {
// contains filtered or unexported fields
}
func GetDefaultSYNScanClient ¶
func GetDefaultSYNScanClient() *NetStackVirtualMachine
func NewSystemNetStackVM ¶
func NewSystemNetStackVM(opts ...Option) (*NetStackVirtualMachine, error)
func NewSystemNetStackVMWithoutDHCP ¶
func NewSystemNetStackVMWithoutDHCP(entryOption ...Option) (*NetStackVirtualMachine, error)
func (*NetStackVirtualMachine) GetEntry ¶
func (m *NetStackVirtualMachine) GetEntry(id tcpip.NICID) (*NetStackVirtualMachineEntry, bool)
func (*NetStackVirtualMachine) GetStack ¶
func (m *NetStackVirtualMachine) GetStack() *stack.Stack
func (*NetStackVirtualMachine) ListenTCP ¶
func (m *NetStackVirtualMachine) ListenTCP(addr string) (net.Listener, error)
func (*NetStackVirtualMachine) SetEntry ¶
func (m *NetStackVirtualMachine) SetEntry(id tcpip.NICID, vm *NetStackVirtualMachineEntry)
type NetStackVirtualMachineEntry ¶
type NetStackVirtualMachineEntry struct {
// contains filtered or unexported fields
}
func NewNetStackVirtualMachineEntry ¶
func NewNetStackVirtualMachineEntry(opts ...Option) (*NetStackVirtualMachineEntry, error)
func (*NetStackVirtualMachineEntry) AddDefaultRoute ¶
func (vm *NetStackVirtualMachineEntry) AddDefaultRoute(gateway net.IP) error
func (*NetStackVirtualMachineEntry) AllowTCP ¶
func (vm *NetStackVirtualMachineEntry) AllowTCP(destinationAddr string)
func (*NetStackVirtualMachineEntry) AllowTCPWithSrc ¶
func (vm *NetStackVirtualMachineEntry) AllowTCPWithSrc(destinationAddr string, srcAddr string)
func (*NetStackVirtualMachineEntry) DisallowTCP ¶
func (vm *NetStackVirtualMachineEntry) DisallowTCP(destinationAddr string)
func (*NetStackVirtualMachineEntry) DisallowTCPWithSrc ¶
func (vm *NetStackVirtualMachineEntry) DisallowTCPWithSrc(destinationAddr string, srcAddr string)
func (*NetStackVirtualMachineEntry) GetMTU ¶
func (vm *NetStackVirtualMachineEntry) GetMTU() int
func (*NetStackVirtualMachineEntry) GetMainNICIPv4Address ¶
func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Address() net.IP
func (*NetStackVirtualMachineEntry) GetMainNICIPv4Gateway ¶
func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Gateway() net.IP
func (*NetStackVirtualMachineEntry) GetMainNICIPv4Netmask ¶
func (vm *NetStackVirtualMachineEntry) GetMainNICIPv4Netmask() *net.IPNet
func (*NetStackVirtualMachineEntry) GetMainNICLinkAddress ¶
func (vm *NetStackVirtualMachineEntry) GetMainNICLinkAddress() net.HardwareAddr
func (*NetStackVirtualMachineEntry) GetOSNetStackIPv4 ¶
func (*NetStackVirtualMachineEntry) GetOSNetStackIPv6 ¶
func (*NetStackVirtualMachineEntry) GetPcapInterfaceNeighborRoute ¶
func (vm *NetStackVirtualMachineEntry) GetPcapInterfaceNeighborRoute() (tcpip.Route, error)
GetPcapInterfaceNeighborRoute returns the route of the pcap interface, should call after set main nic ip
func (*NetStackVirtualMachineEntry) GetStack ¶
func (vm *NetStackVirtualMachineEntry) GetStack() *stack.Stack
func (*NetStackVirtualMachineEntry) GetSystemInterface ¶
func (vm *NetStackVirtualMachineEntry) GetSystemInterface() *net.Interface
func (*NetStackVirtualMachineEntry) InheritPcapInterfaceConfig ¶
func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceConfig() error
InheritPcapInterfaceConfig inherits the IP address and route of the pcap interface( will set default route, netx hop is gateway)
func (*NetStackVirtualMachineEntry) InheritPcapInterfaceIP ¶
func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceIP() error
InheritPcapInterfaceIP inherits the IP address of the pcap interface, set default mac address for driver(pcap endpoint)
func (*NetStackVirtualMachineEntry) InheritPcapInterfaceNeighborRoute ¶
func (vm *NetStackVirtualMachineEntry) InheritPcapInterfaceNeighborRoute() error
InheritPcapInterfaceNeighborRoute inherits the route of the pcap interface
func (*NetStackVirtualMachineEntry) ListenTCP ¶
func (vm *NetStackVirtualMachineEntry) ListenTCP(hostport string) (net.Listener, error)
func (*NetStackVirtualMachineEntry) MainNICID ¶
func (vm *NetStackVirtualMachineEntry) MainNICID() tcpip.NICID
func (*NetStackVirtualMachineEntry) SetDefaultRoute ¶
func (vm *NetStackVirtualMachineEntry) SetDefaultRoute(gateway net.IP) error
func (*NetStackVirtualMachineEntry) SetFilterForSynScan ¶
func (vm *NetStackVirtualMachineEntry) SetFilterForSynScan()
func (*NetStackVirtualMachineEntry) SetMainNICv4 ¶
func (*NetStackVirtualMachineEntry) StartAnnounceARP ¶
func (m *NetStackVirtualMachineEntry) StartAnnounceARP() error
func (*NetStackVirtualMachineEntry) StartDHCP ¶
func (vm *NetStackVirtualMachineEntry) StartDHCP() error
func (*NetStackVirtualMachineEntry) Wait ¶
func (vm *NetStackVirtualMachineEntry) Wait()
func (*NetStackVirtualMachineEntry) WaitDHCPFinished ¶
func (t *NetStackVirtualMachineEntry) WaitDHCPFinished(ctx context.Context) error
type NetstackSniffer ¶
type NetstackSniffer struct {
// contains filtered or unexported fields
}
func NewNetstackSniffer ¶
func NewNetstackSniffer(vm *NetStackVirtualMachine) *NetstackSniffer
func (*NetstackSniffer) RegisterSniffHandle ¶
func (m *NetstackSniffer) RegisterSniffHandle(protocol tcpip.TransportProtocolNumber, handle func(*stack.PacketBuffer))
type Option ¶
func WithARPDisabled ¶
func WithContext ¶
func WithDHCPDisabled ¶
func WithDisableForwarding ¶
func WithEnableLinkLayer ¶
func WithForceSystemNetStack ¶
func WithHandleLocal ¶
func WithICMPDisabled ¶
func WithIPv4Disabled ¶
func WithIPv6Disabled ¶
func WithMainNICIPAddress ¶
func WithMainNICLinkAddress ¶
func WithNetStack ¶
func WithOnTCPConnectionRequested ¶
func WithOnTCPConnectionRequested(fn func(*tcpip.FullAddress, *tcpip.FullAddress)) Option
func WithPCAPInboundFilter ¶
func WithPCAPOutboundFilter ¶
func WithPcapCapabilities ¶
func WithPcapCapabilities(capabilities stack.LinkEndpointCapabilities) Option
func WithPcapDevice ¶
func WithPcapPromisc ¶
func WithRandomMainNICLinkAddress ¶
func WithRandomMainNICLinkAddress() Option
func WithTCPDisabled ¶
func WithUDPDisabled ¶
type PCAPEndpoint ¶
func NewPCAPEndpoint ¶
func NewPCAPEndpoint(ctx context.Context, stackIns *stack.Stack, device string, macAddr net.HardwareAddr, promisc bool) (*PCAPEndpoint, error)
func (*PCAPEndpoint) AllowTCP ¶
func (p *PCAPEndpoint) AllowTCP(addr string)
func (*PCAPEndpoint) AllowTCPWithSrc ¶
func (p *PCAPEndpoint) AllowTCPWithSrc(addr string, src string)
func (*PCAPEndpoint) Attach ¶
func (p *PCAPEndpoint) Attach(dispatcher stack.NetworkDispatcher)
func (*PCAPEndpoint) Capabilities ¶
func (p *PCAPEndpoint) Capabilities() stack.LinkEndpointCapabilities
func (*PCAPEndpoint) Close ¶
func (p *PCAPEndpoint) Close()
func (*PCAPEndpoint) DisallowTCP ¶
func (p *PCAPEndpoint) DisallowTCP(addr string)
func (*PCAPEndpoint) DisallowTCPWithSrc ¶
func (p *PCAPEndpoint) DisallowTCPWithSrc(addr string, src string)
func (*PCAPEndpoint) SetCapabilities ¶
func (p *PCAPEndpoint) SetCapabilities(flag stack.LinkEndpointCapabilities)
func (*PCAPEndpoint) SetGatewayHardwareAddr ¶
func (p *PCAPEndpoint) SetGatewayHardwareAddr(hwAddr net.HardwareAddr)
func (*PCAPEndpoint) SetGatewayIP ¶
func (p *PCAPEndpoint) SetGatewayIP(g net.IP)
func (*PCAPEndpoint) SetLoopback ¶
func (p *PCAPEndpoint) SetLoopback(b bool)
func (*PCAPEndpoint) SetPCAPInboundFilter ¶
func (p *PCAPEndpoint) SetPCAPInboundFilter(filter func(packet gopacket.Packet) bool)
func (*PCAPEndpoint) SetPCAPOutboundFilter ¶
func (p *PCAPEndpoint) SetPCAPOutboundFilter(filter func(packet gopacket.Packet) bool)
func (*PCAPEndpoint) Wait ¶
func (p *PCAPEndpoint) Wait()
type TCPAliveInfo ¶
type TCPAliveInfo struct {
// contains filtered or unexported fields
}
type TunSpoofingListener ¶
type TunSpoofingListener struct {
// contains filtered or unexported fields
}
func NewTunSpoofingListener ¶
func NewTunSpoofingListener(ctx context.Context, c chan net.Conn) *TunSpoofingListener
func (*TunSpoofingListener) Addr ¶
func (t *TunSpoofingListener) Addr() net.Addr
func (*TunSpoofingListener) Close ¶
func (t *TunSpoofingListener) Close() error
type TunVirtualMachine ¶
type TunVirtualMachine struct {
// contains filtered or unexported fields
}
func NewTunVirtualMachine ¶
func NewTunVirtualMachine(ctx context.Context) (*TunVirtualMachine, error)
func (*TunVirtualMachine) Close ¶
func (t *TunVirtualMachine) Close() error
func (*TunVirtualMachine) GetListener ¶
func (t *TunVirtualMachine) GetListener() *TunSpoofingListener
func (*TunVirtualMachine) GetTunnelName ¶
func (t *TunVirtualMachine) GetTunnelName() string
func (*TunVirtualMachine) HijackDomain ¶
func (t *TunVirtualMachine) HijackDomain(domain string) error
func (*TunVirtualMachine) HijackIP ¶
func (t *TunVirtualMachine) HijackIP(ip string) error
func (*TunVirtualMachine) HijackIPNet ¶
func (t *TunVirtualMachine) HijackIPNet(ipNet *net.IPNet) error
func (*TunVirtualMachine) ListenTCP ¶
func (t *TunVirtualMachine) ListenTCP() (*TunVmTCPListener, error)
func (*TunVirtualMachine) SetHijackTCPHandler ¶
func (t *TunVirtualMachine) SetHijackTCPHandler(handle func(conn netstack.TCPConn)) error
type TunVmTCPListener ¶
type TunVmTCPListener struct {
// contains filtered or unexported fields
}
func (*TunVmTCPListener) Close ¶
func (t *TunVmTCPListener) Close() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.