资 源 简 介
Python porting of winpcap - pcap exported functions using ctypes.
No automatic install. Copy winpcapy.py into your site-packages dir.
Some examples are in the examples directory.
Get documentation about functions from official winpcap site
Python version of winpcap sendpack example:
```
from ctypes import *
from winpcapy import *
fp=pcap_t
errbuf= createstringbuffer(PCAPERRBUFSIZE)
packet=(c_ubyte * 100)()
## Check the validity of the command line
if len(sys.argv) != 2:
print ("usage: %s interface" % sys.argv[0])
sys.exit(1)
## Open the adapter
fp = pcapopenlive(sys.argv[1],65536,PCAPOPENFLAGPROMISCUOUS ,1000,errbuf)
if not bool(fp):
print ("
Unable to open the adapter. %s is not supported by WinPcap
" % sys.argv[1])
sys.exit(2)
## Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1
packet[0]=1
packet[1]=1
packet[2]=1
packet[3]=1
packet[4]=1
packet[5]=1
## set mac source