trireme-lib: Index | Files

package packetgen

import ""

Package packetgen "PacketGen" is a Packet Generator library Current version: V1.0, Updates are coming soon


Package Files

interfaces.go packet_gen.go packet_templates.go


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

type EthernetPacketManipulator Uses

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 Uses

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 Uses

type Packet struct {
    // contains filtered or unexported fields

Packet is a custom type which holds the packets and implements PacketManipulator

func (*Packet) AddEthernetLayer Uses

func (p *Packet) AddEthernetLayer(srcMACstr string, dstMACstr string) error

AddEthernetLayer creates an Ethernet layer

func (*Packet) AddIPLayer Uses

func (p *Packet) AddIPLayer(srcIPstr string, dstIPstr string) error

AddIPLayer creates an IP layer

func (*Packet) AddPacket Uses

func (p *Packet) AddPacket(packet gopacket.Packet)

AddPacket is a helper method to add the packet from the template to the struct internal struct field

func (*Packet) AddTCPLayer Uses

func (p *Packet) AddTCPLayer(srcPort layers.TCPPort, dstPort layers.TCPPort) error

AddTCPLayer creates a TCP layer

func (*Packet) DecodePacket Uses

func (p *Packet) DecodePacket() PacketManipulator

DecodePacket returns decoded packet which implements PacketManipulator

func (*Packet) GetEthernetPacket Uses

func (p *Packet) GetEthernetPacket() layers.Ethernet

GetEthernetPacket returns the ethernet layer created

func (*Packet) GetIPChecksum Uses

func (p *Packet) GetIPChecksum() uint16

GetIPChecksum returns IP cheksum

func (*Packet) GetIPPacket Uses

func (p *Packet) GetIPPacket() layers.IPv4

GetIPPacket returns IP checksum

func (*Packet) GetTCPAck Uses

func (p *Packet) GetTCPAck() bool

GetTCPAck returns TCP ACK flag

func (*Packet) GetTCPAcknowledgementNumber Uses

func (p *Packet) GetTCPAcknowledgementNumber() uint32

GetTCPAcknowledgementNumber returns TCP Acknowledgement number

func (*Packet) GetTCPChecksum Uses

func (p *Packet) GetTCPChecksum() uint16

GetTCPChecksum returns TCP checksum

func (*Packet) GetTCPFin Uses

func (p *Packet) GetTCPFin() bool

GetTCPFin returns TCP FIN flag

func (*Packet) GetTCPPacket Uses

func (p *Packet) GetTCPPacket() layers.TCP

GetTCPPacket returns created TCP packet

func (*Packet) GetTCPSequenceNumber Uses

func (p *Packet) GetTCPSequenceNumber() uint32

GetTCPSequenceNumber returns TCP Sequence number

func (*Packet) GetTCPSyn Uses

func (p *Packet) GetTCPSyn() bool

GetTCPSyn returns TCP SYN flag

func (*Packet) GetTCPWindow Uses

func (p *Packet) GetTCPWindow() uint16

GetTCPWindow returns TCP Window

func (*Packet) NewTCPPayload Uses

func (p *Packet) NewTCPPayload(newPayload string) error

NewTCPPayload adds new payload to TCP layer

func (*Packet) SetTCPAck Uses

func (p *Packet) SetTCPAck()

SetTCPAck changes the TCP ACK flag to true

func (*Packet) SetTCPAcknowledgementNumber Uses

func (p *Packet) SetTCPAcknowledgementNumber(ackNum uint32)

SetTCPAcknowledgementNumber changes TCP Acknowledgement number

func (*Packet) SetTCPCwr Uses

func (p *Packet) SetTCPCwr()

SetTCPCwr changes the TCP CWR flag to true

func (*Packet) SetTCPEce Uses

func (p *Packet) SetTCPEce()

SetTCPEce changes the TCP ECE flag to true

func (*Packet) SetTCPFin Uses

func (p *Packet) SetTCPFin()

SetTCPFin changes the TCP FIN flag to true

func (*Packet) SetTCPPsh Uses

func (p *Packet) SetTCPPsh()

SetTCPPsh changes the TCP PSH flag to true

func (*Packet) SetTCPRst Uses

func (p *Packet) SetTCPRst()

SetTCPRst changes the TCP RST flag to true

func (*Packet) SetTCPSequenceNumber Uses

func (p *Packet) SetTCPSequenceNumber(seqNum uint32)

SetTCPSequenceNumber changes TCP sequence number

func (*Packet) SetTCPSyn Uses

func (p *Packet) SetTCPSyn()

SetTCPSyn changes the TCP SYN flag to true

func (*Packet) SetTCPSynAck Uses

func (p *Packet) SetTCPSynAck()

SetTCPSynAck changes the TCP SYN and ACK flag to true

func (*Packet) SetTCPUrg Uses

func (p *Packet) SetTCPUrg()

SetTCPUrg changes the TCP URG flag to true

func (*Packet) SetTCPWindow Uses

func (p *Packet) SetTCPWindow(window uint16)

SetTCPWindow changes the TCP window

func (*Packet) ToBytes Uses

func (p *Packet) ToBytes() ([]byte, error)

ToBytes creates a packet buffer and converts it into a complete packet with ethernet, IP and TCP (with options)

type PacketFlow Uses

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 Uses

func (p *PacketFlow) AppendPacket(pm PacketManipulator) int

AppendPacket adds the packet to Flow field of PacketFlowManipulator interface

func (*PacketFlow) GenerateTCPFlow Uses

func (p *PacketFlow) GenerateTCPFlow(pt PacketFlowType) (PacketFlowManipulator, error)

GenerateTCPFlow returns an array of PacketFlowManipulator interface

func (*PacketFlow) GenerateTCPFlowPayload Uses

func (p *PacketFlow) GenerateTCPFlowPayload(newPayload string) PacketFlowManipulator

GenerateTCPFlowPayload Coming soon...

func (*PacketFlow) GetAckPackets Uses

func (p *PacketFlow) GetAckPackets() PacketFlowManipulator

GetAckPackets returns the Ack Packets

func (*PacketFlow) GetFirstAckPacket Uses

func (p *PacketFlow) GetFirstAckPacket() PacketManipulator

GetFirstAckPacket return first Ack packet from the flow

func (*PacketFlow) GetFirstSynAckPacket Uses

func (p *PacketFlow) GetFirstSynAckPacket() PacketManipulator

GetFirstSynAckPacket return first SynAck packet from the flow

func (*PacketFlow) GetFirstSynPacket Uses

func (p *PacketFlow) GetFirstSynPacket() PacketManipulator

GetFirstSynPacket return first Syn packet from the flow

func (*PacketFlow) GetNthPacket Uses

func (p *PacketFlow) GetNthPacket(index int) PacketManipulator

GetNthPacket returns the packet requested by the user from the array

func (*PacketFlow) GetNumPackets Uses

func (p *PacketFlow) GetNumPackets() int

GetNumPackets returns an array of packets

func (*PacketFlow) GetSynAckPackets Uses

func (p *PacketFlow) GetSynAckPackets() PacketFlowManipulator

GetSynAckPackets returns the SynAck packets

func (*PacketFlow) GetSynPackets Uses

func (p *PacketFlow) GetSynPackets() PacketFlowManipulator

GetSynPackets returns the SYN packets

func (*PacketFlow) GetUptoFirstAckPacket Uses

func (p *PacketFlow) GetUptoFirstAckPacket() PacketFlowManipulator

GetUptoFirstAckPacket will return packets upto first Ack packet

func (*PacketFlow) GetUptoFirstSynAckPacket Uses

func (p *PacketFlow) GetUptoFirstSynAckPacket() PacketFlowManipulator

GetUptoFirstSynAckPacket will return packets upto first SynAck packet

type PacketFlowManipulator Uses

type PacketFlowManipulator interface {
    //Used to create a flow of TCP packets
    GenerateTCPFlow(pt PacketFlowType) (PacketFlowManipulator, error)
    //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 Uses

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 Uses

func NewTemplateFlow() PacketFlowManipulator

NewTemplateFlow will return flow of packets which implements PacketManipulator

type PacketFlowType Uses

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
    //PacketFlowTypeMultipleGoodFlow will have two flows
    //PacketFlowTypeMultipleIntervenedFlow will have two flows intervened to eachothers

type PacketHelper Uses

type PacketHelper interface {
    ToBytes() ([]byte, error)
    AddPacket(packet gopacket.Packet)
    DecodePacket() PacketManipulator

PacketHelper interface is a helper for packets and packet flows Optional: not needed for actual usage

type PacketManipulator Uses

type PacketManipulator interface {

PacketManipulator is an interface for packet manipulations Composition of Ethernet, IP and TCP Manipulator interface

func NewPacket Uses

func NewPacket() PacketManipulator

NewPacket returns a packet strut which implements PacketManipulator

type TCPPacketManipulator Uses

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)
    //Used to set TCP Acknowledgement number
    SetTCPAcknowledgementNumber(ackNum uint32)
    //Used to set TCP Window
    SetTCPWindow(window uint16)
    //Used to set TCP Syn flag to true
    //Used to set TCP Syn and Ack flag to true
    //Used to set TCP Ack flag to true
    //Used to set TCP Cwr flag to true
    //Used to set TCP Ece flag to true
    //Used to set TCP Urg flag to true
    //Used to set TCP Psh flag to true
    //Used to set TCP Rst flag to true
    //Used to set TCP Fin flag to true
    //Used to add TCP Payload
    NewTCPPayload(newPayload string) error

TCPPacketManipulator interface is used to create/manipulate TCP packet

Package packetgen imports 5 packages (graph). Updated 2018-07-23. Refresh now. Tools for package owners.