0
我工作的一種方式來獲得基於其IP機器的MAC地址,所以我結合使用Python和Scapy的:蟒蛇3 - 基於IP的MAC地址 - Scapy的
def obtain_mac(IP):
conf.verb = 0
ans, unans = srp(Ether(dst = "ff:ff:ff:ff:ff:ff")/ARP(pdst = IP), timeout = 2, iface = interface, retry = 10)
for snd,rcv in ans:
return rcv.sprintf(r"%Ether.src%")
# i also tried this, but same result
#return rcv[Ether].src
當我運行此方法:
try:
otherMac = obtain_mac(192.168.2.134)
except Exception:
# some stuff
print ("[!] Couldn't Find MAC Address")
sys.exit(1)
它總是返回:
Couldn't Find MAC Address
我從我的linux此代碼。 使用ping我已經確定,我可以訪問網絡中的其他機器。
有沒有我從文檔中遺漏的東西?
感謝和問候
什麼問題? – moritzg
好吧,API已經沒了?或者爲什麼我不能從IP地址獲取MAC地址? –
我試着通過查看ARP-Table來獲得MAC,看看[這裏](http://python-arptable.readthedocs.io/en/latest/readme.html)。 「ARP表」將IP地址轉換爲MAC – moritzg