python-libpcap
Cython libpcap, read/write/merge/capture
Features
- Read pcap file
- Write pcap file
- Merge pcap file
- Multi-file quick merge
- Get first iface
- Get iface list
- Send raw packet
- Capture data
Usage
合併多文件:
# 根據BPF規則提取多文件內容,並輸出pcap文件
$ mpcap -i pcap/ -o pcap.pcap port 502
獲取第一個存活的網卡:
from pylibpcap import get_first_iface
print(get_first_iface()) # enp2s0
注:詳細使用請看:https://github.com/caizhengxin/python-libpcap