python - 使用 Scapy 的数据包嗅探器
问题描述
我已经在 python 中使用 scapy 编写了嗅探数据包的代码。我遇到了一些让我感到困惑的问题,如下图所示。
在此处输入图像描述-> 重要
所以这是代码
import subprocess
import time
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
logging.getLogger("scapy.loading").setLevel(logging.ERROR)
logging.getLogger("scapy.interactive").setLevel(logging.ERROR)
try:
from scapy.all import *
except ImportError:
sys.exit()
interface = 'wlp10s0'
subprocess.call(["ifconfig",interface,"promisc"],stdout=None,stderr=None,shell=False)
print 'Interface has been set to Promiscous mode'
totalpackets=0
sniffingtime=10
protocols=0
infinite=1
def timenow():
currenttime=time.strftime("%m%d%y-%H%M%S")
return currenttime
def export():
p = sniff(iface='wlp10s0',timeout=sniffingtime,count=0)
wrpcap('./home/Desktop/' + timenow() + '.pcap',p);
while infinite==1 :
export()
我希望有人可以帮助我解决此代码。
谢谢你。
解决方案
./home/...
是一个有效的路径。改为使用/home/...
。
它清楚地显示“OSerror:没有这样的文件或目录”。您可能想查找这些错误 ;-)
推荐阅读
- android - 谷歌播放中 Flashalerts 应用程序的 RECEIVE_SMS 权限被禁止
- sql - 按日期按组对列值求和
- arrays - 如何使用索引从数组中删除元素?
- r - R:dccfit 错误:“dimnames”[2] 的长度不等于数组范围
- java - 操作系统环境变量不会在java中按主机更新
- c - 我不能无限使用 fscanf() 吗?
- indexing - DAE 上使用的 lsqcurvefit 函数给出的错误 Index 超过了数组元素的数量 (1)
- angular - 如何从“Http-Native”插件 Ionic(3 或 4)读取“Set-Cookie”标头?
- docker - 开发和生产中的 Vue 子域
- sql-server - min(count(*)) over... 行为?