mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: small mod to allow bettercap-ng to work with interfaces without an ip (wlan0mon & friends)
This commit is contained in:
parent
5d4e0b847c
commit
37e5f6a6d0
1 changed files with 18 additions and 10 deletions
28
net/net.go
28
net/net.go
|
@ -18,11 +18,19 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
|
|
||||||
for _, iface := range ifaces {
|
for _, iface := range ifaces {
|
||||||
mac := iface.HardwareAddr.String()
|
mac := iface.HardwareAddr.String()
|
||||||
addrs, err := iface.Addrs()
|
if (name == "" && iface.Name != "lo" && iface.Name != "lo0") || iface.Name == name {
|
||||||
// is interface active?
|
var e *Endpoint = nil
|
||||||
if err == nil && len(addrs) > 0 {
|
|
||||||
if (name == "" && iface.Name != "lo" && iface.Name != "lo0") || iface.Name == name {
|
addrs, err := iface.Addrs()
|
||||||
var e *Endpoint = nil
|
if err != nil {
|
||||||
|
fmt.Printf("%s\n", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// interface is in monitor mode (or it's just down and the user is dumb)
|
||||||
|
if len(addrs) == 0 {
|
||||||
|
e = NewEndpointNoResolve("0.0.0.0", mac, iface.Name, 0)
|
||||||
|
} else {
|
||||||
// For every address of the interface.
|
// For every address of the interface.
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
ip := addr.String()
|
ip := addr.String()
|
||||||
|
@ -48,13 +56,13 @@ func FindInterface(name string) (*Endpoint, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if e != nil {
|
if e != nil {
|
||||||
if len(e.HW) == 0 {
|
if len(e.HW) == 0 {
|
||||||
return nil, fmt.Errorf("Could not detect interface hardware address.")
|
return nil, fmt.Errorf("Could not detect interface hardware address.")
|
||||||
}
|
|
||||||
return e, nil
|
|
||||||
}
|
}
|
||||||
|
return e, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue