【发布时间】:2020-05-18 23:49:35
【问题描述】:
我编写了一个 python V3 脚本,它可以嗅探 10 个包,编写日志并在 Wireshark 中打开日志。但不知何故,它总是在 /tmp 中打开一个空日志
我的代码:
#!/usr/bin/env python3
import sys
from scapy.all import *
x = sniff(count=10)
wrpcap('log', x, append=False)
wireshark('log')
输出:
WARNING: No route found for IPv6 destination :: (no default route?). This affects only IPv6
WARNING: PcapWriter: unknown LL type for str. Using type 1 (Ethernet)
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
ERROR: 'str' object has no attribute 'sent_time'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
它应该打开日志而不是变量,但我不知道如何。
scapy 文档 (https://readthedocs.org/projects/scapy/downloads/pdf/latest/) 说:
使用文件名(作为字符串传递),这会在 Wireshark 中加载给定文件。这需要在一个 Wireshark 支持的格式。
有人知道如何在 Wireshark 中打开 pcap 日志吗?
【问题讨论】:
-
嗯,看起来确实很奇怪。您使用的是哪个版本的 scapy?确保它是最新的。
-
我会将名称更改为
log.pcap,以便它具有扩展名。 -
@RossJacobs 将名称更改为
log.pcap会得到相同的结果。 Scapy 自动将日志写入为 .pcap 文件。 -
@Cukic0d 我正在使用最新版本的 python3-scapy (0.23-1)
标签: python-3.x wireshark scapy