kbandla / dpkt

fast, simple packet creation / parsing, with definitions for the basic TCP/IP protocols
Other
1.09k stars 270 forks source link

IEEE80211 Protocol unpack Frame #474

Open legend21313 opened 4 years ago

legend21313 commented 4 years ago

I just captured via wireshark the network traffic. I am trying to get the http request. The problem is that my whole data is captured in IEEE80211 Protocol, almost all example are about ethernet Protocol.

#!/usr/bin/env python

import dpkt

f = open('data/data.pcap','rb')
pcap = dpkt.pcap.Reader(f)

for ts, buf in pcap:
 eth = dpkt.ieee80211.IEEE80211(buf)
 ip = eth.data
 tcp = ip.data

 if tcp.dport == 80 and len(tcp.data) > 0:
  http = dpkt.http.Request(tcp.data)
  print (http.uri)

f.close()

I am getting Error:

Traceback (most recent call last):
  File "C:/Users/user/parser/take.py", line 11, in <module>
    tcp = ip.data
AttributeError: 'bytes' object has no attribute 'data'

How can I access the data in a IEEE80211 Protocol? I hope anyone can help me. @kbandla

Thanks