accessibility.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:nps 作者: pentasecurity 项目源码 文件源码
def _request_arp(self, ip):
        # README: requested arp not write system arp cache
        #
        # disable scapy module verbose
        verb_conf = conf.verb
        conf.verb = 0

        # Run request arp up to three times.
        mac_addr = ""
        for i in xrange(3):
            ans, uans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=1)
            for snd, rcv in ans:
                result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split()
                mac_addr = result[1]

            if mac_addr != None and mac_addr != "":
                break

        # rollback scapy module verbose
        conf.verb = verb_conf

        if mac_addr == "":
            return None

        return mac_addr
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号