You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Scapy代码报错AttributeError: module 'scapy.all' has no attribute 'RAW'

报错原因

Scapy 中用于表示数据包原生载荷的层类名大小写敏感,正确名称为Raw。你在代码第12行读取载荷时错误使用了全大写的scapy.RAW,而scapy.all模块中不存在该名称的属性,因此触发AttributeError。

解决方法

将代码第12行的错误写法:

if ".exe" in scapy_packet[scapy.RAW].load:

修改为正确的大小写格式即可:

if ".exe" in scapy_packet[scapy.Raw].load:

可选优化建议

你可以放开注释的那行判断逻辑,替换原有的if scapy_packet.haslayer(scapy.Raw):,避免没有TCP层的数据包访问scapy.TCP相关属性时报错:

if scapy.Raw in scapy_packet and scapy.TCP in scapy_packet:

内容的提问来源于stack exchange,提问作者Kurdish Learner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 16:06:01