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?
相关问题
- Angular RxJS mergeMap types
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
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.
https://github.com/KimiNewt/pyshark
Python wrapper for
tshark
Usage:
pypcap,https://code.google.com/p/pypcap/ simplified object-oriented Python extension module for libpcap - the current tcpdump.org version, the legacy version shipping with some of the BSD operating systems, and the WinPcap port for Windows.This is a Windows version.And if you are using #nix,just install pcap and dpkt module.