scapy - 名称错误 "global name 'Padding' is not defined"

scapy - Name Error "global name 'Padding' is not defined"

我正在尝试编写小型 http 代理服务器,只是为了测试 scapy 如何使用 StreamSocket 处理数据包。

from scapy.all import *
import socket

sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print "Start"
sk.bind(("127.0.0.1",8090))
sk.listen(1)
conn , addr = sk.accept()
ss = StreamSocket(conn)
r = ss.recv(2048)
print r
ss.close()

当我收到 r = ss.recv(2048) 行时,它说(在 scapy 2.2.0 上):

Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
    r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
    pad = pkt.getlayer(Padding)
NameError: global name 'Padding' is not defined

我尝试更新我的 scapy(从 2.2.0 到 2.3.2),但它出现了同样的错误:

Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
    r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
    pkt = self.basecls(pkt)
NameError: global name 'Padding' is not defined

请帮忙? 抱歉我的英语不好

注意:我有 windows 7 64 位,python 2.6,现在是 scapy 2.3.2

我发现在卸载并重新安装scapy后我没有重启我的机器并且出现了这个错误! 对于可能会遇到我的错误的人,只需从您的机器中删除 scapy 并重新启动它并安装最新的 scapy 版本。