discovery.py 文件源码

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

项目:SupercomputerInABriefcase 作者: SupercomputerInABriefcase 项目源码 文件源码
def discover(data: ConnectionData) -> None:
    assert isinstance(data, ConnectionData)
    ip_net, iface = data
    try:
        ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_net), iface=iface, timeout=2, verbose=False)
        for s, r in ans:
            line = r.sprintf("%Ether.src%  %ARP.psrc%")
            try:
                hostname = socket.gethostbyaddr(r.psrc)
                line += '  ' + hostname[0]
            except socket.herror:
                pass
            print(line)
    except PermissionError:
        print('Cannot execute necessary code, did you run as root?')
        sys.exit(1)
    except:
        raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号