mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 09:33:40 -07:00
refact: minor refactoring
This commit is contained in:
parent
dc58fbbb36
commit
acf1e8b612
4 changed files with 10 additions and 8 deletions
|
@ -1,8 +1,6 @@
|
||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
|
@ -23,7 +21,7 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
if a.IP == nil {
|
if a.IP == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("[%s] %s %s > %s : %s is %s\n",
|
SniffPrinter("[%s] %s %s > %s : %s is %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
|
|
@ -31,7 +31,7 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
}
|
}
|
||||||
url += fmt.Sprintf("%s", string(m[2]))
|
url += fmt.Sprintf("%s", string(m[2]))
|
||||||
|
|
||||||
fmt.Printf("[%s] %s %s %s %s\n",
|
SniffPrinter("[%s] %s %s %s %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_RED+core.FG_BLACK, "http"),
|
core.W(core.BG_RED+core.FG_BLACK, "http"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
|
|
@ -10,6 +10,10 @@ import (
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type SniffPrinterType func(format string, args ...interface{}) (int, error)
|
||||||
|
|
||||||
|
var SniffPrinter = SniffPrinterType(fmt.Printf)
|
||||||
|
|
||||||
func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
tcp := pkt.Layer(layers.LayerTypeTCP).(*layers.TCP)
|
tcp := pkt.Layer(layers.LayerTypeTCP).(*layers.TCP)
|
||||||
|
|
||||||
|
@ -20,7 +24,7 @@ func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if verbose == true {
|
if verbose == true {
|
||||||
fmt.Printf("[%s] %s %s:%s > %s:%s %s\n",
|
SniffPrinter("[%s] %s %s:%s > %s:%s %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_LBLUE+core.FG_BLACK, "tcp"),
|
core.W(core.BG_LBLUE+core.FG_BLACK, "tcp"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
@ -39,7 +43,7 @@ func udpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if verbose == true {
|
if verbose == true {
|
||||||
fmt.Printf("[%s] %s %s:%s > %s:%s %s\n",
|
SniffPrinter("[%s] %s %s:%s > %s:%s %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "udp"),
|
core.W(core.BG_DGRAY+core.FG_WHITE, "udp"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
@ -52,7 +56,7 @@ func udpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
|
|
||||||
func unkParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
func unkParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
||||||
if verbose == true {
|
if verbose == true {
|
||||||
fmt.Printf("[%s] [%s] %s > %s (%d bytes)\n",
|
SniffPrinter("[%s] [%s] %s > %s (%d bytes)\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
pkt.TransportLayer().LayerType(),
|
pkt.TransportLayer().LayerType(),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
|
|
@ -31,7 +31,7 @@ func sniParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
domain = fmt.Sprintf("%s:%d", domain, tcp.DstPort)
|
domain = fmt.Sprintf("%s:%d", domain, tcp.DstPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[%s] %s %s > %s\n",
|
SniffPrinter("[%s] %s %s > %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_YELLOW+core.FG_WHITE, "sni"),
|
core.W(core.BG_YELLOW+core.FG_WHITE, "sni"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue