[英]Wireless Data Packet Capturing with help of scapy
我嘗試過的代碼如下:
from scapy.all import *
def PacketHandler(pkt) :
if pkt.haslayer == 2 and pkt.subtype==0:
if pkt.haslayer(IP) :
ip=pkt.getlayer(IP)
print ip.dst
if pkt.haslayer(UDP):
udp=pkt.getlayer(UDP)
print udp.dport
if pkt.haslayer(TCP) :
tcp=pkt.getlayer(TCP)
print tcp.port
sniff(iface="mon0", prn=PacketHandler)
使用此方法,我想捕獲所有無線DATA數據包,但僅得到多播(IP / UDP)數據包。 那么,如何獲取無線網絡中的所有DATA數據包? 我為此暫時禁用了訪問點上的加密,以便可以訪問數據包中的數據。
如果您只想處理Data
幀,而不要Management
和Control
幀,則可以執行以下操作:
from scapy.all import *
def packet_handler(pkt) :
# if packet has 802.11 layer, and type of packet is Data frame
if pkt.haslayer(Dot11) and pkt.type == 2:
# do your stuff here
print(pkt.show())
sniff(iface="mon0", prn=packet_handler)
您也可以使用sniff
函數的filter
選項來僅過濾Data
幀以轉到您的packet_handler
函數:
from scapy.all import *
def packet_handler(pkt) :
# if packet has 802.11 layer
if pkt.haslayer(Dot11):
# do your stuff here
print(pkt.show())
sniff(iface="mon0", prn=packet_handler, filter="type Data")
這是一個很好的列表,列出了幀的type
和subtype
值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.