python
Function to scan devices in the network using the ARP protocol
from scapy.all import *
def scan(ip_router):
ether = Ether(dst='ff:ff:ff:ff:ff:ff')
ip_range = f'{ip_router}/24'
arp = ARP(pdst=f'{IP_ROUTER}/24')
request = ether / arp
ans, unans = srp(request, timeout=2, verbose=False, retry=1)
data = dict()
for sent, reciverd in ans:
data[reciverd.psrc] = reciverd.hwsrc
return data
Was this helpful?
Similar Posts
- [Python] Get nodeid, module, function name using Pytest request built-in fixture
- [Python] Using inspect.stack() to get module name, path, function name
- Function argument unpacking in Python
- [Python] Range - standard function to create a list of numbers
- [Python] Function returns multiple values
- [Python] Function parameters - pack and unpack
- [Python] Eval() function