Documentation
¶
Overview ¶
Package packetgen [allows sending customized tcp/udp traffic. Inspired by https://github.com/bilalcaliskan/syn-flood]
Index ¶
- Constants
- func BuildLinkLayer(c LayerConfig) (gopacket.LinkLayer, error)
- func BuildNetworkLayer(c LayerConfig) (gopacket.NetworkLayer, error)
- func BuildPayload(c LayerConfig) (gopacket.Layer, error)
- func BuildTransportLayer(c LayerConfig, network gopacket.NetworkLayer) (gopacket.TransportLayer, error)
- func Serialize(payloadBuf gopacket.SerializeBuffer, layer gopacket.Layer) error
- func SerializeLayers(payloadBuf gopacket.SerializeBuffer, layers ...gopacket.Layer) error
- type Connection
- type ConnectionConfig
- type DNSPacketConfig
- type DNSQuestion
- type EthernetPacketConfig
- type ICMPV4PacketConfig
- type IPPacketConfig
- type LayerConfig
- type Packet
- type PacketConfig
- type TCPFlagsConfig
- type TCPPacketConfig
- type UDPPacketConfig
Constants ¶
View Source
const ( TCPHeaderSize = 25 // 20 for header + at least 5 for options UDPHeaderSize = 8 IPHeaderSize = 20 )
Common protocol header sizes to help with metrics
Variables ¶
This section is empty.
Functions ¶
func BuildLinkLayer ¶ added in v0.8.0
func BuildLinkLayer(c LayerConfig) (gopacket.LinkLayer, error)
func BuildNetworkLayer ¶ added in v0.8.0
func BuildNetworkLayer(c LayerConfig) (gopacket.NetworkLayer, error)
func BuildPayload ¶ added in v0.8.0
func BuildPayload(c LayerConfig) (gopacket.Layer, error)
func BuildTransportLayer ¶ added in v0.8.0
func BuildTransportLayer(c LayerConfig, network gopacket.NetworkLayer) (gopacket.TransportLayer, error)
func Serialize ¶ added in v0.8.0
func Serialize(payloadBuf gopacket.SerializeBuffer, layer gopacket.Layer) error
func SerializeLayers ¶ added in v0.8.0
func SerializeLayers(payloadBuf gopacket.SerializeBuffer, layers ...gopacket.Layer) error
Types ¶
type Connection ¶ added in v0.8.15
type Connection interface {
Write(Packet) (int, error)
Read([]byte) (int, error)
Close() error
Target() string
}
func OpenConnection ¶ added in v0.8.15
func OpenConnection(ctx context.Context, c ConnectionConfig) (Connection, error)
type ConnectionConfig ¶ added in v0.8.0
type ConnectionConfig struct {
Type string
Args map[string]any
Proxy *utils.ProxyParams
}
ConnectionConfig describes which network to use when sending packets
type DNSPacketConfig ¶ added in v0.8.0
type DNSPacketConfig struct {
ID uint16
Qr bool
OpCode uint8
AA bool // Authoritative answer
TC bool // Truncated
RD bool // Recursion desired
RA bool // Recursion available
Z uint8 // Reserved for future use
ResponseCode uint8
QDCount *uint16 // Number of questions to expect
// Entries
Questions []DNSQuestion
}
type DNSQuestion ¶ added in v0.8.21
DNSQuestion wraps a single request (question) within a DNS query.
type EthernetPacketConfig ¶
EthernetPacketConfig describes ethernet layer configuration
type ICMPV4PacketConfig ¶ added in v0.8.0
type IPPacketConfig ¶
IPPacketConfig describes ip layer configuration
type LayerConfig ¶ added in v0.8.0
type Packet ¶ added in v0.8.0
type Packet struct {
Link gopacket.LinkLayer
Network gopacket.NetworkLayer
Transport gopacket.TransportLayer
Payload gopacket.Layer
}
type PacketConfig ¶
type PacketConfig struct {
Link LayerConfig
Network LayerConfig
Transport LayerConfig
Payload LayerConfig
}
func (PacketConfig) Build ¶ added in v0.8.0
func (c PacketConfig) Build() (result Packet, err error)
type TCPFlagsConfig ¶
type TCPFlagsConfig struct {
SYN bool
ACK bool
FIN bool
RST bool
PSH bool
URG bool
ECE bool
CWR bool
NS bool
}
TCPFlagsConfig stores flags to be set on tcp layer
type TCPPacketConfig ¶
type TCPPacketConfig struct {
SrcPort int
DstPort int
Seq uint32
Ack uint32
Window uint16
Urgent uint16
Flags TCPFlagsConfig
}
TCPPacketConfig describes tcp layer configuration
type UDPPacketConfig ¶
UDPPacketConfig describes udp layer configuration
Click to show internal directories.
Click to hide internal directories.