脚本 - 通过mac反查ip

import scapy

def mac_to_ip(mac, net_scope):
    # mac 为 mac 地址
    # net_scope 为 网段

    pkg = Ether(dst=mac)/ARP(pdst=net_scopte)
    ans, unans = srp(pkg, verbose=False, timeout=1)

    for k, v in ans:
        if v.sprintf("%Ether.src%").lower() == mac.lower():
            return v.sprintf("%ARP.psrc%")
posted @ 2024-06-06 23:15  难德糊涂  阅读(121)  评论(0)    收藏  举报