python解析http数据包_如何在python中嗅探HTTP数据包?
I want to sniff all the HTTP packets in my computer via python(version2.6.. is this possible? can I do it with scapy, or without other external modules?
解決方案
Scrapy is only for extracting data from webpages or similar structured documents.
To actually read the packets coming from the NIC your best performance option would probably be to use a C/C++ API that has python bindings.
For example WireShark has a Python API.
Pcapy is a module for packet capture using libpcap.
LibPCAP is the packet capture library written for TCPDUMP and also used in WireShark.
Another option is to try the dpkt python module. Here is a nice write up.
Here's an example using using dpkt and pcap to sniff HTTP packets.
EDIT: oops, I misread scapy. Thanks root!
As you mentioned, Scapy is another python module that also uses LibPCAP.
This documentation has an example of sniffing.
If you are having trouble running on Python 2.7 check out this post.
總結(jié)
以上是生活随笔為你收集整理的python解析http数据包_如何在python中嗅探HTTP数据包?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一箪食读音 一箪食读音是什么
- 下一篇: pycharm如何更改python项目环