简体   繁体   English

Python ARP 扫描器

[英]Python ARP scanner

This code is an arp scanner, it scans all hosts on the network except phones.这段代码是一个arp扫描器,它扫描网络上除手机外的所有主机。
Program print only ip and mac addresses of computers, not phones程序只打印电脑的 ip 和 mac 地址,不打印手机

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

Have a look at https://stackoverflow.com/a/57017630/5459467 Some phones simply don't answer to ARP pings, mostly iPhones.看看https://stackoverflow.com/a/57017630/5459467有些手机根本不响应 ARP ping,主要是 iPhone。

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.他们也往往会忽略免费的 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.您实际上可以做的唯一操作是在路由器执行实际 ARP 请求时响应速度比路由器更快,或者只是被动地嗅探所有 ARP 请求。

您需要添加设备正在使用的接口。

answered, unanswered = srp(Ether(dst = "FF:FF:FF:FF:FF:FF") / ARP(pdst = ip), timeout = 1, iface = 'wlp1s0', inter = 0.1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM