Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3aec70289b | ||
|
|
a308a3aa13 |
14
main.go
14
main.go
@@ -9,6 +9,7 @@ import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"strconv"
|
||||
|
||||
@@ -70,12 +71,21 @@ func sInit(os string) *targetInfo {
|
||||
return &tInfo
|
||||
}
|
||||
|
||||
func openCapture(tInfo *targetInfo) *pcap.Handle {
|
||||
for {
|
||||
handle, err := pcap.OpenLive(tInfo.iFace, tInfo.snaplen, true, pcap.BlockForever)
|
||||
if err == nil {
|
||||
return handle
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
tInfo := sInit(runtime.GOOS)
|
||||
|
||||
// Read package and analze them
|
||||
handle, err := pcap.OpenLive(tInfo.iFace, tInfo.snaplen, true, pcap.BlockForever)
|
||||
errorPrinter(err)
|
||||
handle := openCapture(tInfo)
|
||||
|
||||
handle.SetBPFFilter(tInfo.filter)
|
||||
packets := gopacket.NewPacketSource(handle, handle.LinkType()).Packets()
|
||||
|
||||
Reference in New Issue
Block a user