Install pcap
First download http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip
Download pypcap source code package pypcap-1.1, unzip
1) if mingw32 is not installed, download and install a hypothesis to c: \ wingw32.
2) set the environment variable Path = % PATH %; C: \ wingw32 \ bin
3) decompress the downloaded wpdpack (Winpcap development pack) to c: \ wpdpack.
4) enter the pypcap-1.1 extract directory, in turn to execute:
> Python. \ setup. py config -- With-pcap = "C: \ wpdpack"
> Python. \ setup. py build-cmingw32
> Python. \ setup. py install
Install dpkt, go to the project homepage, and download the binary installation package for Windows.
Test:
Import pcap
Import dpkt
A = pcap. pcap ()
A. setfilter ('Arp ') # It Can Be Used for filtering by 'tcp', 'udp ', 'port 80', etc.
For I, J in:
TEM = dpkt. Ethernet. Ethernet (j)
Print ("% S % x", I, TEM)