橫向移動的時候因爲局域網中可能存在未分配的IP,若是請求這些未分配的IP可能致使被發現(旁路檢測設備),先能夠作一下arp被動信息收集。固然對蜜罐類設備沒用。python
from scapy.all import * """ arp信息被動收集 arp op=1 arp request information(brodcast) arp op=2 arp reply information(unicast) arp gratuitous op=1 sender IP address same as target IP and sender MAC address same as target MAC address """ # arp arp_info = {} # passive arp information collection def arp_sniff(): return sniff(filter="arp",store=0,prn=arp_collect) # arp information collect to dict like[IP:MAC] def arp_collect(arp_pkg): mac = arp_pkg[ARP].hwsrc ip = arp_pkg[ARP].psrc # 若是mac信息沒存儲在arp_info中就是新發現的mac # 若是mac存在,分兩種狀況:新抓的包和原來IP不相等就是change,沒有就什麼都不用作 if arp_info.get(mac) == None: arp_info[mac] = ip print(mac,":",ip) elif ip != arp_info[mac]: arp_info[mac] = ip print("change:") print(mac,":",ip) if __name__ == "__main__": arp_sniff()