我需要转换一个pcap文件,我有我的驱动器到一个csv文件使用python代码(我知道如何做它使用wireshark用户界面),但我需要通过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")
我得到一个结果文件,但它是空的。
有人能帮我吗?
4条答案
按热度按时间6rvt4ljy1#
当我将命令改为:
将
separatorr
更改为separator
。通常我使用包
pyshark
(https://pypi.org/project/pyshark/)在python中处理我的pcap文件。tzxcd3kk2#
这是最简单的方法(在我看来)
os.system ('tshark -r'+in_file +'>'+ out_file +'.txt')
其中
PS:仅在python 3上测试
xfyts7mz3#
我使用
subprocess
以下面的方式执行此操作:将
stdout
写入'/path/to/csv_file.csv'
nbysray54#
您可以使用tshark和Python来自动执行此操作。
为什么你没有得到一个空的csv的原因是你还没有安装tshark可用于您的CLI。在Linux中。尝试apt-install tshark,在Windows中,你必须安装Wireshark,然后设置环境变量到安装文件夹,使tshark激活到您的命令提示符。