mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 18:57:17 -07:00
Refactoring modules
This commit is contained in:
parent
c0d3c314fc
commit
ed652622e2
89 changed files with 186 additions and 138 deletions
39
modules/net_sniff/net_sniff_upnp.go
Normal file
39
modules/net_sniff/net_sniff_upnp.go
Normal file
|
@ -0,0 +1,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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue