neighbors_parser.py 文件源码

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

项目:Network-Scanner-PORT-ALIVE 作者: C3s1um133 项目源码 文件源码
def scan_and_print_neighbors(net, interface, timeout=1):
    global ips_o
    print_fmt("\n\033[94m[ARP]\033[0m %s sur %s" % (net, interface))
    try:
        ans, unans = scapy.layers.l2.arping(net, iface=interface, timeout=timeout, verbose=False)
        for s, r in ans.res:
            line = r.sprintf("%Ether.src%  %ARP.psrc%")
            ips_o.append(line.split(' ')[2])
            line = mac_address_id(line)
            try:
                hostname = socket.gethostbyaddr(r.psrc)
                line += " " + hostname[0]
            except socket.herror:
                pass
            except KeyboardInterrupt:
                print '\033[91m[-]\033[0m L\'utilisateur a choisi l\'interruption du process.'
                break
            logger.info("\033[96m[ONLINE]\033[0m " + line)
    except socket.error as e:
        if e.errno == errno.EPERM:
            logger.error("\033[91m[-]\033[0m %s. Vous n'etes pas root?", e.strerror)
        else:
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号