Skip to content

Commit a603067

Browse files
added MAC address colorization and nocolor flag
1 parent 876471b commit a603067

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

arpspoof/arpspoof.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func (ar *ARPSpoofer) spoofTargets() {
394394
if err != nil {
395395
continue
396396
}
397-
ar.logger.Debug().Msgf("[arp spoofer] Sending %d bytes of ARP packet to %s (%s)", len(ap.data), targetIP, oui.VendorWithMAC(targetMAC))
397+
ar.logger.Debug().Msgf("[arp spoofer] Sending %dB of ARP packet to %s (%s)", len(ap.data), targetIP, oui.VendorWithMAC(targetMAC))
398398
ar.packets <- ap
399399
}
400400
if ar.fullduplex {

cmd/marpspoof/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var (
2020
ipPortPattern = regexp.MustCompile(
2121
`\b(?:\d{1,3}\.){3}\d{1,3}(?::(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]?\d{1,4}))?\b`,
2222
)
23+
macPattern = regexp.MustCompile(`(?i)([a-z0-9_]+_[0-9a-f]{2}(?::[0-9a-f]{2}){2}|(?:[0-9a-f]{2}[:-]){5}[0-9a-f]{2})`)
2324
)
2425

2526
func root(args []string) error {
@@ -35,6 +36,7 @@ func root(args []string) error {
3536
flags.StringVar(&conf.Interface, "i", "", "The name of the network interface. Example: eth0 (Default: default interface)")
3637
flags.BoolVar(&conf.FullDuplex, "f", false, "Run ARP spoofing in fullduplex mode")
3738
flags.BoolVar(&conf.Debug, "d", false, "Enable debug logging")
39+
nocolor := flags.Bool("nocolor", false, "Disable colored output")
3840
flags.BoolFunc("I", "Display list of interfaces and exit.", func(flagValue string) error {
3941
if err := network.DisplayInterfaces(); err != nil {
4042
fmt.Fprintf(os.Stderr, "%s: %v\n", app, err)
@@ -53,19 +55,28 @@ func root(args []string) error {
5355
}
5456
conf.Gateway = &ip
5557
}
56-
output := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: false}
58+
output := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: *nocolor}
5759
output.FormatTimestamp = func(i any) string {
5860
ts, _ := time.Parse(time.RFC3339, i.(string))
61+
if *nocolor {
62+
return colors.WrapBrackets(ts.Format(time.TimeOnly))
63+
}
5964
return colors.Gray(colors.WrapBrackets(ts.Format(time.TimeOnly))).String()
6065
}
6166
output.FormatMessage = func(i any) string {
6267
if i == nil || i == "" {
6368
return ""
6469
}
6570
s := i.(string)
71+
if *nocolor {
72+
return s
73+
}
6674
result := ipPortPattern.ReplaceAllStringFunc(s, func(match string) string {
6775
return colors.Gray(match).String()
6876
})
77+
result = macPattern.ReplaceAllStringFunc(result, func(match string) string {
78+
return colors.Yellow(match).String()
79+
})
6980
return result
7081
}
7182
logger := zerolog.New(output).With().Timestamp().Logger()

0 commit comments

Comments
 (0)