mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 01:23:42 -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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
|
||||
"github.com/google/gopacket"
|
||||
|
@ -23,7 +21,7 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
|||
if a.IP == nil {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("[%s] %s %s > %s : %s is %s\n",
|
||||
SniffPrinter("[%s] %s %s > %s : %s is %s\n",
|
||||
vTime(pkt.Metadata().Timestamp),
|
||||
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
||||
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]))
|
||||
|
||||
fmt.Printf("[%s] %s %s %s %s\n",
|
||||
SniffPrinter("[%s] %s %s %s %s\n",
|
||||
vTime(pkt.Metadata().Timestamp),
|
||||
core.W(core.BG_RED+core.FG_BLACK, "http"),
|
||||
vIP(ip.SrcIP),
|
||||
|
|
|
@ -10,6 +10,10 @@ import (
|
|||
"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) {
|
||||
tcp := pkt.Layer(layers.LayerTypeTCP).(*layers.TCP)
|
||||
|
||||
|
@ -20,7 +24,7 @@ func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
|||
}
|
||||
|
||||
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),
|
||||
core.W(core.BG_LBLUE+core.FG_BLACK, "tcp"),
|
||||
vIP(ip.SrcIP),
|
||||
|
@ -39,7 +43,7 @@ func udpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {
|
|||
}
|
||||
|
||||
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),
|
||||
core.W(core.BG_DGRAY+core.FG_WHITE, "udp"),
|
||||
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) {
|
||||
if verbose == true {
|
||||
fmt.Printf("[%s] [%s] %s > %s (%d bytes)\n",
|
||||
SniffPrinter("[%s] [%s] %s > %s (%d bytes)\n",
|
||||
vTime(pkt.Metadata().Timestamp),
|
||||
pkt.TransportLayer().LayerType(),
|
||||
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)
|
||||
}
|
||||
|
||||
fmt.Printf("[%s] %s %s > %s\n",
|
||||
SniffPrinter("[%s] %s %s > %s\n",
|
||||
vTime(pkt.Metadata().Timestamp),
|
||||
core.W(core.BG_YELLOW+core.FG_WHITE, "sni"),
|
||||
vIP(ip.SrcIP),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue