Skip to content

Instantly share code, notes, and snippets.

@cjoudrey
Created July 6, 2017 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cjoudrey/f8e9b227e3be34553e56a738435f8046 to your computer and use it in GitHub Desktop.
Save cjoudrey/f8e9b227e3be34553e56a738435f8046 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/pcap"
)
func main() {
handle, err := pcap.OpenLive("en0", 1600, true, pcap.BlockForever)
if err != nil {
panic(err)
}
bpfInstructions := []pcap.BPFInstruction{
{0x28, 0, 0, 0x0000000c},
{0x15, 0, 10, 0x00000800},
{0x30, 0, 0, 0x00000017},
{0x15, 0, 8, 0x00000006},
{0x28, 0, 0, 0x00000014},
{0x45, 6, 0, 0x00001fff},
{0xb1, 0, 0, 0x0000000e},
{0x48, 0, 0, 0x0000000e},
{0x15, 2, 0, 0x00000050},
{0x48, 0, 0, 0x00000010},
{0x15, 0, 1, 0x00000050},
{0x6, 0, 0, 0x00040000},
{0x6, 0, 0, 0x00000000},
}
if err := handle.SetBPFInstructionFilter(bpfInstructions); err != nil {
panic(err)
}
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
for packet := range packetSource.Packets() {
fmt.Printf("%s", packet.Dump())
}
}
@Arnold1
Copy link

Arnold1 commented Dec 21, 2018

hi, i cannot see any output when i start the executable. i run the application with sudo and use chrome to google.com... any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment