/
net_sniff_upnp.go
39 lines (31 loc) · 763 Bytes
/
net_sniff_upnp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package net_sniff
import (
"fmt"
"github.com/bettercap/bettercap/packets"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
)
func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 {
s := ""
for name, value := range data {
s += fmt.Sprintf("%s:%s ", tui.Blue(name), tui.Yellow(value))
}
NewSnifferEvent(
pkt.Metadata().Timestamp,
"upnp",
ip.SrcIP.String(),
ip.DstIP.String(),
nil,
"%s %s -> %s : %s",
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "upnp"),
vIP(ip.SrcIP),
vIP(ip.DstIP),
str.Trim(s),
).Push()
return true
}
return false
}