Created
July 6, 2017 17:39
-
-
Save cjoudrey/f8e9b227e3be34553e56a738435f8046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?