python3 利用scapy抓取网卡数据包并保存pcap

python scapy实现包的抓取,脚本如下

python;gutter:true;</p> <h1>coding=utf-8</h1> <p>from scapy.all import * count = input("Input catch tcp num:") now_time = datetime.now().strftime( "%Y%m%d%H%M%S" ) filename = "./pcap/email_dns_data_{0}.pcap".format(now_time)</p> <h1>filter = 'tcp.port == 2222'</h1> <p>o_open_file= PcapWriter(filename, append=True) def callback(packet): packet.show() o_open_file.write(packet)</p> <p>dpkt_input = sniff(iface = "Realtek PCIe GBE Family Controller",count = int(count), filter='tcp',prn = callback)</p> <pre><code> sniff解释: ;gutter:true;
iface 网卡

python;gutter:true;
filter 过滤条件,和wireshark 相同count 抓包数量,0为永久抓包prn 回调函数

Original: https://www.cnblogs.com/royfans/p/16366459.html
Author: RoyFans
Title: python3 利用scapy抓取网卡数据包并保存pcap

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/15705/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总