首页 > 解决方案 > 如何使用 python 将 pcap 转换为 CSV

问题描述

我需要使用 python 代码将驱动器上的 pcap 文件转换为 csv 文件(我知道如何使用 wireshark UI 进行操作),但我需要通过 python 代码来完成,

我已经尝试过这段代码:

import os
os.system("tshark -r mirai.pcap -T fields -e ip.src -e frame.len -e     ip.proto -E separatorr=, -E occurrence=f > traffic.csv")

我得到一个结果文件,但它是空的。

谁能帮助我。

标签: pythoncsvpcap

解决方案


这是最简单的方法(在我看来)

os.system ('tshark -r'+in_file +'>'+ out_file +'.txt')

在哪里

in_file = <name of your pcap file>
out_file = <name of your output file>

PS:仅在 python 3 上测试


推荐阅读