Reputation: 222
This code is an arp scanner, it scans all hosts on the network except phones.
Program print only ip and mac addresses of computers, not phones
Nobody knows why this happens? Thanks
import scapy.all as scapy
class scan:
def Arp(self, ip):
self.ip = ip
print(ip)
arp_r = scapy.ARP(pdst=ip)
br = scapy.Ether(dst='ff:ff:ff:ff:ff:ff')
request = br/arp_r
answered, unanswered = scapy.srp(request, timeout=1)
print('\tIP\t\t\t\t\tMAC')
print('_' * 37)
for i in answered:
ip, mac = i[1].psrc, i[1].hwsrc
print(ip, '\t\t' + mac)
print('-' * 37)
arp = scan() # create an instance of the class
arp.Arp('192.168.0.1/24') # call the method
Upvotes: 1
Views: 9573
Reputation: 1
You need to add the interface your device is using.
answered, unanswered = srp(Ether(dst = "FF:FF:FF:FF:FF:FF") / ARP(pdst = ip), timeout = 1, iface = 'wlp1s0', inter = 0.1)
Upvotes: 0
Reputation: 5411
Have a look at https://stackoverflow.com/a/57017630/5459467 Some phones simply don't answer to ARP pings, mostly iPhones.
That's not necessarily explained anywhere, and could have multiple explanations such as: - security concerns - battery management
They will also tend to ignore gratuitous ARP. The only actions you can actually do is to answer faster than the router when they perform actual ARP requests, or simply sniff passively all ARP requests.
Upvotes: 1