mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
balls
This commit is contained in:
parent
d9e471c6d0
commit
789d7e2c51
1 changed files with 17 additions and 10 deletions
27
net/net.go
27
net/net.go
|
@ -15,27 +15,34 @@ import (
|
||||||
|
|
||||||
const MonitorModeAddress = "0.0.0.0"
|
const MonitorModeAddress = "0.0.0.0"
|
||||||
|
|
||||||
|
func areTheSame(iface net.Interface, piface pcap.Interface) bool {
|
||||||
|
if addrs, err := iface.Addrs(); err == nil {
|
||||||
|
for _, ia := range addrs {
|
||||||
|
for _, ib := range piface.Addresses {
|
||||||
|
if ia.String() == ib.IP.String() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func getInterfaceName(iface net.Interface) string {
|
func getInterfaceName(iface net.Interface) string {
|
||||||
// all normal OS
|
// all normal operating systems
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
return iface.Name
|
return iface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Microsoft Windows
|
||||||
devs, err := pcap.FindAllDevs()
|
devs, err := pcap.FindAllDevs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return iface.Name
|
return iface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dev := range devs {
|
for _, dev := range devs {
|
||||||
fmt.Printf("%v\n", dev)
|
if areTheSame(iface, dev) {
|
||||||
if dev.Name == iface.Name {
|
return dev.Name
|
||||||
fmt.Printf("%+v\n", dev)
|
|
||||||
desc := dev.Description
|
|
||||||
name := dev.Name
|
|
||||||
if desc != "" {
|
|
||||||
name = fmt.Sprintf("%s (%s)", name, desc)
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue