横向移动的时候因为局域网中可能存在未分配的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()