Documentation ¶
Overview ¶
Package packetgen "PacketGen" is a Packet Generator library Current version: V1.0, Updates are coming soon
Index ¶
- Variables
- type EthernetPacketManipulator
- type IPPacketManipulator
- type Packet
- func (p *Packet) AddEthernetLayer(srcMACstr string, dstMACstr string) error
- func (p *Packet) AddIPLayer(srcIPstr string, dstIPstr string) error
- func (p *Packet) AddPacket(packet gopacket.Packet)
- func (p *Packet) AddTCPLayer(srcPort layers.TCPPort, dstPort layers.TCPPort) error
- func (p *Packet) DecodePacket() PacketManipulator
- func (p *Packet) GetEthernetPacket() layers.Ethernet
- func (p *Packet) GetIPChecksum() uint16
- func (p *Packet) GetIPPacket() layers.IPv4
- func (p *Packet) GetTCPAck() bool
- func (p *Packet) GetTCPAcknowledgementNumber() uint32
- func (p *Packet) GetTCPChecksum() uint16
- func (p *Packet) GetTCPFin() bool
- func (p *Packet) GetTCPPacket() layers.TCP
- func (p *Packet) GetTCPSequenceNumber() uint32
- func (p *Packet) GetTCPSyn() bool
- func (p *Packet) GetTCPWindow() uint16
- func (p *Packet) NewTCPPayload(newPayload string) error
- func (p *Packet) SetTCPAck()
- func (p *Packet) SetTCPAcknowledgementNumber(ackNum uint32) error
- func (p *Packet) SetTCPCwr()
- func (p *Packet) SetTCPEce()
- func (p *Packet) SetTCPFin()
- func (p *Packet) SetTCPPsh()
- func (p *Packet) SetTCPRst()
- func (p *Packet) SetTCPSequenceNumber(seqNum uint32) error
- func (p *Packet) SetTCPSyn()
- func (p *Packet) SetTCPSynAck()
- func (p *Packet) SetTCPUrg()
- func (p *Packet) SetTCPWindow(window uint16) error
- func (p *Packet) ToBytes() []byte
- type PacketFlow
- func (p *PacketFlow) AppendPacket(pm PacketManipulator) int
- func (p *PacketFlow) GenerateTCPFlow(pt PacketFlowType) PacketFlowManipulator
- func (p *PacketFlow) GenerateTCPFlowPayload(newPayload string) PacketFlowManipulator
- func (p *PacketFlow) GetAckPackets() PacketFlowManipulator
- func (p *PacketFlow) GetFirstAckPacket() PacketManipulator
- func (p *PacketFlow) GetFirstSynAckPacket() PacketManipulator
- func (p *PacketFlow) GetFirstSynPacket() PacketManipulator
- func (p *PacketFlow) GetNthPacket(index int) PacketManipulator
- func (p *PacketFlow) GetNumPackets() int
- func (p *PacketFlow) GetSynAckPackets() PacketFlowManipulator
- func (p *PacketFlow) GetSynPackets() PacketFlowManipulator
- func (p *PacketFlow) GetUptoFirstAckPacket() PacketFlowManipulator
- func (p *PacketFlow) GetUptoFirstSynAckPacket() PacketFlowManipulator
- type PacketFlowManipulator
- type PacketFlowType
- type PacketHelper
- type PacketManipulator
- type TCPPacketManipulator
Constants ¶
This section is empty.
Variables ¶
var PacketFlowTemplate1 [][]byte
PacketFlowTemplate1 is a good hardcoded template
var PacketFlowTemplate2 [][]byte
PacketFlowTemplate2 has a two complete TCP flow
var PacketFlowTemplate3 [][]byte
PacketFlowTemplate3 has a two intervened TCP flows
Functions ¶
This section is empty.
Types ¶
type EthernetPacketManipulator ¶
type EthernetPacketManipulator interface { //Used to create an Ethernet layer AddEthernetLayer(srcMACstr string, dstMACstr string) error //Used to return Ethernet packet created GetEthernetPacket() layers.Ethernet }
EthernetPacketManipulator interface is used to create/manipulate Ethernet packet
type IPPacketManipulator ¶
type IPPacketManipulator interface { //Used to create an IP layer AddIPLayer(srcIPstr string, dstIPstr string) error //Used to return IP packet created GetIPPacket() layers.IPv4 //Used to return IP checksum GetIPChecksum() uint16 }
IPPacketManipulator interface is used to create/manipulate IP packet
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
Packet is a custom type which holds the packets and implements PacketManipulator
func (*Packet) AddEthernetLayer ¶
AddEthernetLayer creates an Ethernet layer
func (*Packet) AddIPLayer ¶
AddIPLayer creates an IP layer
func (*Packet) AddPacket ¶ added in v1.0.35
AddPacket is a helper method to add the packet from the template to the struct internal struct field
func (*Packet) AddTCPLayer ¶
AddTCPLayer creates a TCP layer TODO: remove nolint nolint
func (*Packet) DecodePacket ¶ added in v1.0.35
func (p *Packet) DecodePacket() PacketManipulator
DecodePacket returns decoded packet which implements PacketManipulator TODO: remove nolint nolint
func (*Packet) GetEthernetPacket ¶
GetEthernetPacket returns the ethernet layer created
func (*Packet) GetIPChecksum ¶
GetIPChecksum returns IP cheksum
func (*Packet) GetIPPacket ¶
GetIPPacket returns IP checksum
func (*Packet) GetTCPAcknowledgementNumber ¶
GetTCPAcknowledgementNumber returns TCP Acknowledgement number
func (*Packet) GetTCPChecksum ¶
GetTCPChecksum returns TCP checksum
func (*Packet) GetTCPPacket ¶
GetTCPPacket returns created TCP packet
func (*Packet) GetTCPSequenceNumber ¶
GetTCPSequenceNumber returns TCP Sequence number
func (*Packet) GetTCPWindow ¶
GetTCPWindow returns TCP Window
func (*Packet) NewTCPPayload ¶
NewTCPPayload adds new payload to TCP layer
func (*Packet) SetTCPAcknowledgementNumber ¶
SetTCPAcknowledgementNumber changes TCP Acknowledgement number
func (*Packet) SetTCPCwr ¶ added in v1.0.35
func (p *Packet) SetTCPCwr()
SetTCPCwr changes the TCP CWR flag to true
func (*Packet) SetTCPEce ¶ added in v1.0.35
func (p *Packet) SetTCPEce()
SetTCPEce changes the TCP ECE flag to true
func (*Packet) SetTCPFin ¶ added in v1.0.35
func (p *Packet) SetTCPFin()
SetTCPFin changes the TCP FIN flag to true
func (*Packet) SetTCPPsh ¶ added in v1.0.35
func (p *Packet) SetTCPPsh()
SetTCPPsh changes the TCP PSH flag to true
func (*Packet) SetTCPRst ¶ added in v1.0.35
func (p *Packet) SetTCPRst()
SetTCPRst changes the TCP RST flag to true
func (*Packet) SetTCPSequenceNumber ¶
SetTCPSequenceNumber changes TCP sequence number
func (*Packet) SetTCPSynAck ¶
func (p *Packet) SetTCPSynAck()
SetTCPSynAck changes the TCP SYN and ACK flag to true
func (*Packet) SetTCPUrg ¶ added in v1.0.35
func (p *Packet) SetTCPUrg()
SetTCPUrg changes the TCP URG flag to true
func (*Packet) SetTCPWindow ¶
SetTCPWindow changes the TCP window
type PacketFlow ¶
type PacketFlow struct {
// contains filtered or unexported fields
}
PacketFlow is a custom type which holds the packet attributes and the flow Implements PacketFlowManipulator interface
func (*PacketFlow) AppendPacket ¶
func (p *PacketFlow) AppendPacket(pm PacketManipulator) int
AppendPacket adds the packet to Flow field of PacketFlowManipulator interface
func (*PacketFlow) GenerateTCPFlow ¶
func (p *PacketFlow) GenerateTCPFlow(pt PacketFlowType) PacketFlowManipulator
GenerateTCPFlow returns an array of PacketFlowManipulator interface TODO: remove nolint nolint
func (*PacketFlow) GenerateTCPFlowPayload ¶
func (p *PacketFlow) GenerateTCPFlowPayload(newPayload string) PacketFlowManipulator
GenerateTCPFlowPayload Coming soon...
func (*PacketFlow) GetAckPackets ¶
func (p *PacketFlow) GetAckPackets() PacketFlowManipulator
GetAckPackets returns the Ack Packets
func (*PacketFlow) GetFirstAckPacket ¶
func (p *PacketFlow) GetFirstAckPacket() PacketManipulator
GetFirstAckPacket return first Ack packet from the flow
func (*PacketFlow) GetFirstSynAckPacket ¶
func (p *PacketFlow) GetFirstSynAckPacket() PacketManipulator
GetFirstSynAckPacket return first SynAck packet from the flow
func (*PacketFlow) GetFirstSynPacket ¶
func (p *PacketFlow) GetFirstSynPacket() PacketManipulator
GetFirstSynPacket return first Syn packet from the flow
func (*PacketFlow) GetNthPacket ¶
func (p *PacketFlow) GetNthPacket(index int) PacketManipulator
GetNthPacket returns the packet requested by the user from the array
func (*PacketFlow) GetNumPackets ¶
func (p *PacketFlow) GetNumPackets() int
GetNumPackets returns an array of packets
func (*PacketFlow) GetSynAckPackets ¶
func (p *PacketFlow) GetSynAckPackets() PacketFlowManipulator
GetSynAckPackets returns the SynAck packets
func (*PacketFlow) GetSynPackets ¶
func (p *PacketFlow) GetSynPackets() PacketFlowManipulator
GetSynPackets returns the SYN packets
func (*PacketFlow) GetUptoFirstAckPacket ¶ added in v1.0.35
func (p *PacketFlow) GetUptoFirstAckPacket() PacketFlowManipulator
GetUptoFirstAckPacket will return packets upto first Ack packet
func (*PacketFlow) GetUptoFirstSynAckPacket ¶ added in v1.0.35
func (p *PacketFlow) GetUptoFirstSynAckPacket() PacketFlowManipulator
GetUptoFirstSynAckPacket will return packets upto first SynAck packet
type PacketFlowManipulator ¶
type PacketFlowManipulator interface { //Used to create a flow of TCP packets GenerateTCPFlow(pt PacketFlowType) PacketFlowManipulator //Used to return first TCP Syn packet GetFirstSynPacket() PacketManipulator //Used to return first TCP SynAck packet GetFirstSynAckPacket() PacketManipulator //Used to return first TCP Ack packet GetFirstAckPacket() PacketManipulator //Used to return all the TCP Syn packets from the flow GetSynPackets() PacketFlowManipulator //Used to return all the TCP SynAck packets from the flow GetSynAckPackets() PacketFlowManipulator //Used to return all the TCP Ack packets from the flow GetAckPackets() PacketFlowManipulator //Used to return all the packets upto first TCP SynAck packet from the flow GetUptoFirstSynAckPacket() PacketFlowManipulator //Used to return all the packets upto first TCP Ack packet from the flow GetUptoFirstAckPacket() PacketFlowManipulator //Used to return Nth packet from the flow GetNthPacket(index int) PacketManipulator //Used to return length of the flow GetNumPackets() int //Used to add a new packet to the flow AppendPacket(p PacketManipulator) int }
PacketFlowManipulator is an interface for packet flow manipulations Used to create/manipulate packet flows
func NewPacketFlow ¶ added in v1.0.35
func NewPacketFlow(smac string, dmac string, sip string, dip string, sport layers.TCPPort, dport layers.TCPPort) PacketFlowManipulator
NewPacketFlow returns PacketFlow struct which implements PacketFlowManipulator
func NewTemplateFlow ¶ added in v1.0.35
func NewTemplateFlow() PacketFlowManipulator
NewTemplateFlow will return flow of packets which implements PacketManipulator
type PacketFlowType ¶
type PacketFlowType uint8
PacketFlowType type for different types of flows
const ( //PacketFlowTypeGenerateGoodFlow is used to generate a good floe PacketFlowTypeGenerateGoodFlow PacketFlowType = iota //PacketFlowTypeGoodFlowTemplate will have a good flow from a hardcoded template PacketFlowTypeGoodFlowTemplate //PacketFlowTypeMultipleGoodFlow will have two flows PacketFlowTypeMultipleGoodFlow //PacketFlowTypeMultipleIntervenedFlow will have two flows intervened to eachothers PacketFlowTypeMultipleIntervenedFlow )
type PacketHelper ¶
type PacketHelper interface { ToBytes() []byte AddPacket(packet gopacket.Packet) DecodePacket() PacketManipulator }
PacketHelper interface is a helper for packets and packet flows Optional: not needed for actual usage
type PacketManipulator ¶
type PacketManipulator interface { EthernetPacketManipulator IPPacketManipulator TCPPacketManipulator PacketHelper }
PacketManipulator is an interface for packet manipulations Composition of Ethernet, IP and TCP Manipulator interface
func NewPacket ¶
func NewPacket() PacketManipulator
NewPacket returns a packet strut which implements PacketManipulator
type TCPPacketManipulator ¶
type TCPPacketManipulator interface { //Used to create a TCP layer AddTCPLayer(srcPort layers.TCPPort, dstPort layers.TCPPort) error //Used to return TCP packet GetTCPPacket() layers.TCP //Used to return TCP Sequence number GetTCPSequenceNumber() uint32 //Used to return TCP Acknowledgement number number GetTCPAcknowledgementNumber() uint32 //Used to return TCP window GetTCPWindow() uint16 //Used to return TCP Syn flag GetTCPSyn() bool //Used to return TCP Ack flag GetTCPAck() bool //Used to return TCP Fin flag GetTCPFin() bool //Used to return TCP Checksum GetTCPChecksum() uint16 //Used to set TCP Sequence number SetTCPSequenceNumber(seqNum uint32) error //Used to set TCP Acknowledgement number SetTCPAcknowledgementNumber(ackNum uint32) error //Used to set TCP Window SetTCPWindow(window uint16) error //Used to set TCP Syn flag to true SetTCPSyn() //Used to set TCP Syn and Ack flag to true SetTCPSynAck() //Used to set TCP Ack flag to true SetTCPAck() //Used to set TCP Cwr flag to true SetTCPCwr() //Used to set TCP Ece flag to true SetTCPEce() //Used to set TCP Urg flag to true SetTCPUrg() //Used to set TCP Psh flag to true SetTCPPsh() //Used to set TCP Rst flag to true SetTCPRst() //Used to set TCP Fin flag to true SetTCPFin() //Used to add TCP Payload NewTCPPayload(newPayload string) error }
TCPPacketManipulator interface is used to create/manipulate TCP packet