python - 使用scapy检测ARP中毒

标签 python pcap scapy arp

我捕获了一些流量并存储在 .pcap 文件中。在那里,发生了ARP中毒攻击。

有没有办法在 python 脚本中使用 scapy 检测攻击者的 IP 和 MAC 地址以及受害者的 IP 和 MAC 地址?

最佳答案

我相信像这样的脚本可以完成这项工作

#! /usr/bin/python
from scapy.all import *
pkts = rdpcap('capture2.pcap')
#these are from wireshark
ipadr=['192.168.0.1','192.168.0.2','192.168.0.3','192.168.0.30']
macadr['00:03:ff:98:98:01','00:03:ff:98:98:02','00:03:ff:98:98:03','00:03:ff:98:98:30']
c=-1
for p in pkts:
 c=c+1
 if p.haslayer(ARP):
  #find a packet where p.dst and p.pdst isn't a valid pair
  if p.dst != 'ff:ff:ff:ff:ff:ff':
   if not(( ipadr[0]==p.pdst and  macadr[0]==p.dst ) or ( ipadr[1]==p.pdst and      macadr[1]==p.dst) or ( ipadr[2]==p.pdst and  macadr[2]==p.dst ) or ( ipadr[3]==p.pdst and  macadr[3]==p.dst )) :
print 'packet data ' +p.psrc +"   "+p.src+"  " + p.pdst + " " + p.dst +" "+str(c)
print 'packet number = ' + str(c)
print 'MAC of attacker = ' + p.dst
print 'IP of attacker = ' + ipadr[macadr.index(p.dst)]
print 'MAC of target = ' + p.src
print 'IP of target = ' + p.psrc

关于python - 使用scapy检测ARP中毒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20301127/

相关文章:

python - 整数数组作为 Scapy 自定义字段

Python pandas : insert rows for missing dates, groupby 数据帧中的时间序列

c - 了解 pcap 包头

linux - 如何使用 tshark 从 PCAP 中提取 media.type?

python - 使用 Python 和 PyKML 修改 map 层

python - 使用 scapy 完成 HTTP GET

python - 问题的扩展 "Python logging multiple files using the same logger"

python - 在 R 的自定义安装中使用 rpy2

python - 为什么可以在ansible中使用分割过滤器?

c - pcap_set_filter() 可以与 pcap_open_offline() 一起使用吗?