pcapx

package
v1.2.7-sp3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: AGPL-3.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TCP_FLAG_FIN = 1 << iota
	TCP_FLAG_SYN
	TCP_FLAG_RST
	TCP_FLAG_PSH
	TCP_FLAG_ACK
	TCP_FLAG_URG
	TCP_FLAG_ECE
	TCP_FLAG_CWR
	TCP_FLAG_NS
)

Variables

View Source
var (
	PublicGatewayAddress   net.IP
	PublicPreferredAddress net.IP
	PublicInterface        *net.Interface
)
View Source
var (
	Exports = map[string]interface{}{
		"GetStatistics":      getStatistics,
		"InjectRaw":          InjectRaw,
		"InjectIP":           InjectTCPIP,
		"InjectTCP":          InjectTCPIP,
		"InjectHTTPRequest":  InjectHTTPRequest,
		"InjectChaosTraffic": InjectChaosTraffic,
	}
)

Functions

func CompleteTCPFlow added in v1.2.6

func CompleteTCPFlow(raw []byte) ([][]byte, error)

func CreateTCPFlowFromPayload added in v1.2.6

func CreateTCPFlowFromPayload(src, dst string, payload []byte) ([][]byte, error)

func GetPublicLinkLayer

func GetPublicLinkLayer(t layers.EthernetType, toServer bool) (*layers.Ethernet, error)

func GetPublicToClientLinkLayerIPv4

func GetPublicToClientLinkLayerIPv4() (*layers.Ethernet, error)

func GetPublicToClientLinkLayerIPv6

func GetPublicToClientLinkLayerIPv6() (*layers.Ethernet, error)

func GetPublicToServerLinkLayerIPv4

func GetPublicToServerLinkLayerIPv4() (*layers.Ethernet, error)

func GetPublicToServerLinkLayerIPv6

func GetPublicToServerLinkLayerIPv6() (*layers.Ethernet, error)

func InjectChaosTraffic

func InjectChaosTraffic(t *ChaosTraffic, opts ...ConfigOption)

func InjectHTTPRequest

func InjectHTTPRequest(raw []byte, opt ...ConfigOption)

func InjectICMPIP

func InjectICMPIP(raw []byte, opt ...ConfigOption)

func InjectRaw

func InjectRaw(raw []byte, opt ...ConfigOption)

func InjectTCPIP

func InjectTCPIP(raw []byte, opt ...ConfigOption)

func InjectTCPIPInstance

func InjectTCPIPInstance(raw *TCPIPFrame, opt ...ConfigOption)

func InjectTCPPayload

func InjectTCPPayload(payload []byte, opt ...ConfigOption)

func InjectUDPIP

func InjectUDPIP(raw []byte, opt ...ConfigOption)

func NewDefaultIPv4Layer added in v1.2.5

func NewDefaultIPv4Layer() *layers.IPv4

func NewDefaultTCPLayer added in v1.2.5

func NewDefaultTCPLayer() *layers.TCP

func PacketBuilder added in v1.2.3

func PacketBuilder(opts ...any) ([]byte, error)

func ParseEthernetLinkLayer added in v1.2.7

func ParseICMPIPv4

func ParseICMPIPv4(raw []byte) (*layers.IPv4, *layers.ICMPv4, gopacket.Payload, error)

func ParseSrcNDstAddress

func ParseSrcNDstAddress(src, dst string) (net.IP, net.IP, uint16, uint16, error)

func ParseTCPIPv4

func ParseTCPIPv4(raw []byte) (*layers.IPv4, *layers.TCP, gopacket.Payload, error)

func ParseTCPRaw

func ParseTCPRaw(raw []byte) (*layers.IPv4, *layers.TCP, gopacket.Payload, error)

func ParseUDPIPv4

func ParseUDPIPv4(raw []byte) (*layers.IPv4, *layers.UDP, gopacket.Payload, error)

func RegenerateTCPTraffic

func RegenerateTCPTraffic(raw []byte, localIPAddress string, opt ...ConfigOption)

Types

type ArpConfig added in v1.2.5

type ArpConfig func(arp *layers.ARP) error

func WithArp_ReplyTo added in v1.2.5

func WithArp_ReplyTo(targetIp, targetMac string) ArpConfig

func WithArp_ReplyToEx added in v1.2.5

func WithArp_ReplyToEx(srcTarget, srcMac, targetIp, targetMac string) ArpConfig

func WithArp_RequestAuto added in v1.2.5

func WithArp_RequestAuto(ip string) ArpConfig

func WithArp_RequestEx added in v1.2.5

func WithArp_RequestEx(selfIP, selfMac string, remoteIP string) ArpConfig

type BuilderConfig added in v1.2.3

type BuilderConfig struct {
	Loopback bool
	Payload  []byte
}

type BuilderConfigOption added in v1.2.3

type BuilderConfigOption func(config *BuilderConfig)

func WithLoopback added in v1.2.3

func WithLoopback() BuilderConfigOption

func WithPayload added in v1.2.3

func WithPayload(payload []byte) BuilderConfigOption

type ChaosTraffic added in v1.2.6

type ChaosTraffic struct {
	Raw                   []byte
	RawTCP                bool
	LocalIP               string
	LinkLayerPayload      []byte
	TCPIPPayload          []byte
	UDPIPInboundPayload   []byte
	UDPIPOutboundPayload  []byte
	ICMPIPInboundPayload  []byte
	ICMPIPOutboundPayload []byte
	HttpRequest           []byte
	HttpResponse          []byte
}

type Config

type Config struct {
	Iface       string
	ToServerSet bool
	ToServer    bool
	IsHttps     bool

	TCPLocalAddress  string
	TCPRemoteAddress string
}

type ConfigOption

type ConfigOption func(config *Config)

func WithIface

func WithIface(iface string) ConfigOption

func WithLocalAddress

func WithLocalAddress(addr string) ConfigOption

func WithRemoteAddress

func WithRemoteAddress(addr string) ConfigOption

func WithToClient

func WithToClient() ConfigOption

func WithToServer

func WithToServer() ConfigOption

type EthernetOption added in v1.2.5

type EthernetOption func(config *layers.Ethernet) error

func WithEthernet_DstMac added in v1.2.5

func WithEthernet_DstMac(dstMac any) EthernetOption

func WithEthernet_NextLayerType added in v1.2.5

func WithEthernet_NextLayerType(i any) EthernetOption

func WithEthernet_SrcMac added in v1.2.5

func WithEthernet_SrcMac(srcMac any) EthernetOption

type ICMPOption added in v1.2.5

type ICMPOption func(pv4 *layers.ICMPv4) error

func WithICMP_Id added in v1.2.5

func WithICMP_Id(id any) ICMPOption

func WithICMP_Payload added in v1.2.5

func WithICMP_Payload(i []byte) ICMPOption

func WithICMP_Sequence added in v1.2.5

func WithICMP_Sequence(sequence any) ICMPOption

func WithICMP_Type added in v1.2.5

func WithICMP_Type(icmpType any, icmpCode any) ICMPOption

type IPv4Option added in v1.2.5

type IPv4Option func(pv4 *layers.IPv4) error

func WithIPv4_DstIP added in v1.2.5

func WithIPv4_DstIP(i any) IPv4Option

func WithIPv4_Flags added in v1.2.5

func WithIPv4_Flags(i any) IPv4Option

func WithIPv4_FragmentOffset added in v1.2.5

func WithIPv4_FragmentOffset(i any) IPv4Option

func WithIPv4_ID added in v1.2.5

func WithIPv4_ID(i any) IPv4Option

func WithIPv4_NextProtocol added in v1.2.5

func WithIPv4_NextProtocol(i any) IPv4Option

func WithIPv4_Option added in v1.2.5

func WithIPv4_Option(optType any, data []byte) IPv4Option

func WithIPv4_SrcIP added in v1.2.5

func WithIPv4_SrcIP(i any) IPv4Option

func WithIPv4_TOS added in v1.2.5

func WithIPv4_TOS(i any) IPv4Option

func WithIPv4_TTL added in v1.2.5

func WithIPv4_TTL(i any) IPv4Option

type Statistics

type Statistics struct {
	LinkLayerStatistics           map[string]int64
	NetworkLayerStatistics        map[string]int64
	TransportationLayerStatistics map[string]int64
	ICMPStatistics                map[string]int64
}

func GetGlobalStatistics

func GetGlobalStatistics() *Statistics

func NewStatistics

func NewStatistics() *Statistics

func (*Statistics) AddICMPStatistics

func (s *Statistics) AddICMPStatistics(name string)

func (*Statistics) AddLinkLayerStatistics

func (s *Statistics) AddLinkLayerStatistics(name string)

func (*Statistics) AddNetworkLayerStatistics

func (s *Statistics) AddNetworkLayerStatistics(name string)

func (*Statistics) AddTransportationLayerStatistics

func (s *Statistics) AddTransportationLayerStatistics(name string)

type TCPIPFrame

type TCPIPFrame struct {
	ToServer bool
	IP       *layers.IPv4
	TCP      *layers.TCP
}

type TCPOption added in v1.2.5

type TCPOption func(config *layers.TCP) error

func WithTCP_Ack added in v1.2.5

func WithTCP_Ack(ack any) TCPOption

func WithTCP_DataOffset added in v1.2.5

func WithTCP_DataOffset(dataOffset any) TCPOption

func WithTCP_DstPort added in v1.2.5

func WithTCP_DstPort(dstPort any) TCPOption

func WithTCP_Flags added in v1.2.5

func WithTCP_Flags(in any) TCPOption

func WithTCP_OptionMSS added in v1.2.5

func WithTCP_OptionMSS(i any) TCPOption

WithTCP_OptionMSS is a IPv4Option default 1460

func WithTCP_OptionSACK added in v1.2.5

func WithTCP_OptionSACK(i ...any) TCPOption

func WithTCP_OptionSACKPermitted added in v1.2.5

func WithTCP_OptionSACKPermitted() TCPOption

func WithTCP_OptionTimestamp added in v1.2.5

func WithTCP_OptionTimestamp(i any) TCPOption

func WithTCP_OptionWindowScale added in v1.2.5

func WithTCP_OptionWindowScale(i any) TCPOption

func WithTCP_Options added in v1.2.5

func WithTCP_Options(optionType any, data []byte) TCPOption

func WithTCP_Seq added in v1.2.5

func WithTCP_Seq(seq any) TCPOption

func WithTCP_SrcPort added in v1.2.5

func WithTCP_SrcPort(srcPort any) TCPOption

func WithTCP_Urgent added in v1.2.5

func WithTCP_Urgent(urgent any) TCPOption

func WithTCP_Window added in v1.2.5

func WithTCP_Window(window any) TCPOption

type UDPOption added in v1.2.5

type UDPOption func(config *layers.UDP) error

func WithUDP_DstPort added in v1.2.5

func WithUDP_DstPort(in any) UDPOption

func WithUDP_SrcPort added in v1.2.5

func WithUDP_SrcPort(in any) UDPOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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