scapy - 名称错误“全局名称'填充'未定义”

时间:2016-02-14 12:12:22

标签: python python-2.6 scapy

我试图写一些小的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

1 个答案:

答案 0 :(得分:0)

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