Questions tagged [gopacket]

46 questions
10
votes
1 answer

How to use Golang to compose raw TCP packet (using gopacket) and send it via raw socket

I would like to craft custome TCP packets using gopacket and then send them using raw sockets. Here is a short and readable example go program that demonstrates what I'd like to do: package main import ( "code.google.com/p/gopacket" …
David Stainton
  • 101
  • 1
  • 1
  • 3
9
votes
1 answer

Changing destination port using gopacket

I'm currently playing around with reading packages from nfqueue and modifying them.Unfortunately, I'm a bit stuck at changing the destination port of a package. See the code snippet below. Idea is to rewrite dest port 8888 to 8000. I do see the…
Glaslos
  • 2,872
  • 1
  • 21
  • 31
7
votes
3 answers

compile gopacket on windows 64bit

I am trying to use gopacket on my windows 10. I'm using it to sniff and inject packets directly to/from the NIC. I can easily compile and run my code with GOARCH=386 but can't in GOARCH=amd64. Worth noticing: I am NOT trying to cross-compile. I'm…
J. Dow
  • 351
  • 3
  • 5
6
votes
1 answer

Sending UDP packets to 127.0.0.1 with gopacket

I'm trying to send a UDP packet to 127.0.0.1 with gopacket. Here is my code: package main import ( "fmt" "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/pcap" ) func main() { …
paddlesteamer
  • 63
  • 1
  • 6
4
votes
2 answers

How do you use the tcp assembly package in gopacket?

I've been using the pcap package along with gopacket to parse network traffic with pretty good success. These libraries have made it much easier to work with network captures and they've definitely saved me a ton of time. I'd like to take it a step…
PeterM
  • 2,534
  • 6
  • 31
  • 38
3
votes
1 answer

How to get header bytes/length with gopacket

Try to use gopacket to create an Ethernet packet (ARP, BGP, UDP, TCP) and get the header bytes and length of it. Try to play with the example as below, try to list all layers and find the payload location then workout the total header length and…
Enze Chi
  • 1,733
  • 17
  • 28
2
votes
0 answers

Getting the MAC address from nftables nflog in go

I want to push my netfilter logs into Grafana Loki but I could not get a format I liked, between ulogd and promtail, so I decided to write my own little utility to do the job for me. It works pretty well except for one thing: I would like to be…
wz2b
  • 1,017
  • 7
  • 24
2
votes
2 answers

Unable to create static binary because of undefined reference to dbus_*

I get these errors when I try to statically link my Go program that uses Gopacket: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libpcap.a(pcap-dbus.o): in function `dbus_write': (.text+0x103): undefined reference to…
user2233706
  • 6,148
  • 5
  • 44
  • 86
2
votes
1 answer

Go: How to remove data link layer from a packet?

I am using the gopacket library, and I read packets from the wire. Right now, all packets I read contain four layers: Link, Network, Transport, and Application Data. I need to remove the Link layer from all packets and save the rest to a file.…
Prisacari Dmitrii
  • 1,985
  • 1
  • 23
  • 33
2
votes
1 answer

Send EAPoL packet: Request Identity

I try to send Request Identity EAPoL packet: func eapol_requestIdentity(handle *pcap.Handle, iface *net.Interface, id uint8) error { len := uint16(5) // eap1 field length eap1 := layers.EAP{ Code:…
ipStack
  • 381
  • 1
  • 12
2
votes
1 answer

How to use decodeLinkLayerDiscovery in lldp.go?

I would like to decode informations in a LLDP packet : lldp.go do it with decodeLinkLayerDiscovery function but I don't know how to use it. For example, I want to get value of MgmtAddress. How can I do it ? func readLLDP(handle *pcap.Handle, iface…
ipStack
  • 381
  • 1
  • 12
2
votes
1 answer

How to compile a Go application using gopacket for 32bit mips

I am trying to compile a little application using the gopacket library to linux on a 32bit mips cpu. Unfortunately I am getting loads of errors like this: /home/cdutz/go/pkg/mod/github.com/google/gopacket@v1.1.19/pcap/pcap.go:30:22: undefined:…
Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
2
votes
2 answers

How to parse information element in 802.11 probe request frame with gopacket

Gopacket supports parsing information elements in beacon and probe response frames, like this: for _, layer := range packet.Layers() { if layer.LayerType() == layers.LayerTypeDot11InformationElement { dot11info, ok :=…
qingxp9
  • 141
  • 1
  • 5
2
votes
1 answer

How To Serialize A Modified Go Packet Packet Into Real IP Packet

Why I want to write a proxy server, proxy server changes IP/port of a packet and emits modified. Attempt package main import ( "encoding/hex" "github.com/google/gopacket" "github.com/google/gopacket/layers" "fmt" "net" ) func main() { …
ilyaigpetrov
  • 3,657
  • 3
  • 30
  • 46
2
votes
1 answer

gopacket parsing Dot11 layer

I'm trying to use gopacket to parse the packets of a .pcap file and pretty much to get all the information in it, until now I get either truncated information or an error IF I try to use a filter. package main import ( "fmt" …
drd0sPy
  • 63
  • 9
1
2 3 4