new: the arp.spoof.targets variable now supports MAC addresses as well (closes #87)

This commit is contained in:
evilsocket 2018-02-26 13:12:24 +01:00
commit 3926f52f2d
2 changed files with 96 additions and 17 deletions

View file

@ -12,7 +12,7 @@ type ArpTable map[string]string
var (
arpWasParsed = false
arpLock = &sync.Mutex{}
arpLock = &sync.RWMutex{}
arpTable = make(ArpTable)
)
@ -64,6 +64,9 @@ func ArpLookup(iface string, address string, refresh bool) (string, error) {
}
}
arpLock.RLock()
defer arpLock.RUnlock()
// Lookup the hardware address of this ip.
if mac, found := arpTable[address]; found == true {
return mac, nil
@ -72,8 +75,27 @@ func ArpLookup(iface string, address string, refresh bool) (string, error) {
return "", fmt.Errorf("Could not find mac for %s", address)
}
func ArpInverseLookup(iface string, mac string, refresh bool) (string, error) {
if ArpParsed() == false || refresh == true {
if _, err := ArpUpdate(iface); err != nil {
return "", err
}
}
arpLock.RLock()
defer arpLock.RUnlock()
for ip, hw := range arpTable {
if hw == mac {
return ip, nil
}
}
return "", fmt.Errorf("Could not find IP for %s", mac)
}
func ArpParsed() bool {
arpLock.Lock()
defer arpLock.Unlock()
arpLock.RLock()
defer arpLock.RUnlock()
return arpWasParsed
}