mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
new: SNI packet sniffer + sniffer refactoring.
This commit is contained in:
parent
55b9b1f189
commit
9cdf365b13
5 changed files with 182 additions and 22 deletions
50
modules/net_sniff_views.go
Normal file
50
modules/net_sniff_views.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/google/gopacket/layers"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/session"
|
||||
)
|
||||
|
||||
func vTime(t time.Time) string {
|
||||
return t.Format("15:04:05")
|
||||
}
|
||||
|
||||
func vIP(ip net.IP) string {
|
||||
if session.I.Interface.IP.Equal(ip) {
|
||||
return core.Dim("-")
|
||||
} else if session.I.Gateway.IP.Equal(ip) {
|
||||
return "gateway"
|
||||
}
|
||||
|
||||
address := ip.String()
|
||||
host, found := session.I.Targets.Targets[address]
|
||||
|
||||
if found == true {
|
||||
if host.Hostname != "" {
|
||||
return host.Hostname
|
||||
}
|
||||
}
|
||||
|
||||
return address
|
||||
}
|
||||
|
||||
func vPort(p interface{}) string {
|
||||
sp := fmt.Sprintf("%d", p)
|
||||
if tcp, ok := p.(layers.TCPPort); ok {
|
||||
if name, found := layers.TCPPortNames[tcp]; found {
|
||||
sp = core.Yellow(name)
|
||||
}
|
||||
} else if udp, ok := p.(layers.UDPPort); ok {
|
||||
if name, found := layers.UDPPortNames[udp]; found {
|
||||
sp = core.Yellow(name)
|
||||
}
|
||||
}
|
||||
|
||||
return sp
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue