Documentation ¶
Overview ¶
Package packetgen "PacketGen" is a Packet Generator library Current version: V1.0, Updates are coming soon
Index ¶
- 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) AddTCPLayer(srcPort layers.TCPPort, dstPort layers.TCPPort) error
- 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) SetTCPSequenceNumber(seqNum uint32) error
- func (p *Packet) SetTCPSyn()
- func (p *Packet) SetTCPSynAck()
- 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
- type PacketFlowManipulator
- type PacketFlowType
- type PacketHelper
- type PacketManipulator
- type TCPPacketManipulator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 ¶
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) AddTCPLayer ¶
AddTCPLayer creates a TCP layer
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) 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) SetTCPWindow ¶
SetTCPWindow changes the TCP window
type PacketFlow ¶
type PacketFlow struct { Flow []PacketManipulator // 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
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
type PacketFlowManipulator ¶
type PacketFlowManipulator interface { //Ued 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 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
type PacketFlowType ¶
type PacketFlowType uint8
PacketFlowType type for different types of flows
const ( //PacketFlowTypeGoodFlow returns a good flow PacketFlowTypeGoodFlow PacketFlowType = iota )
type PacketHelper ¶
type PacketHelper interface {
ToBytes() []byte
}
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 add TCP Payload NewTCPPayload(newPayload string) error }
TCPPacketManipulator interface is used to create/manipulate TCP packet