ipsec.py无法找到属性IPPROTO_ESP和socket.IPPROTO_AH [英] ipsec.py CANT FIND THE attribute IPPROTO_ESP and socket.IPPROTO_AH

查看:154
本文介绍了ipsec.py无法找到属性IPPROTO_ESP和socket.IPPROTO_AH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为python 2.6安装了scapy模块,当我导入该模块时,出现以下警告:

I install the module scapy for python 2.6 and when I import this module I get this warning:

警告:无法导入层ipsec:模块"对象没有属性"IPPROTO_AH"

WARNING: can't import layer ipsec: 'module' object has no attribute 'IPPROTO_AH'

我查看了套接字属性,但没有找到"IPPROTO_AH"属性 另外,我尝试编辑模块ipsec.py并找到用其他东西替换IPPROTO_AH的方法,但随后我得到了IPPROTO_ESP的警告!

I looked in the socket attributes and i didnt find the 'IPPROTO_AH' attribute In addition, i tried to edit the module ipsec.py and find way to replace IPPROTO_AH with something else but then i got WARNING WITH IPPROTO_ESP !

我尝试了ipsec.py中的编辑行,例如:

I tried edit lines in ipsec.py such as:

    overload_fields = {
    IP: {'proto': IPTest},
    IPv6: {'nh': IPTest},
    IPv6ExtHdrHopByHop: {'nh': socket.IPPROTO_AH},
    IPv6ExtHdrDestOpt: {'nh': socket.IPPROTO_AH},
    IPv6ExtHdrRouting: {'nh': socket.IPPROTO_AH},}

bind_layers(IP, AH, proto=socket.IPPROTO_AH)
bind_layers(IPv6, AH, nh=socket.IPPROTO_AH)

我该如何解决?

推荐答案

我认为我有...这不是一个干净的解决方案,但可以解决问题...我在其他中也看到了scapy 文件...
您需要做的就是编辑 ipsec.py 并在其下找到import socket ,然后将其添加有条件的:

I think I have it...it's not a clean solution, but it will do the trick... I've seen it in other scapy files...
All you need to do is edit ipsec.py and look for the line import socket just under it, add these conditionals:

if not hasattr(socket, "IPPROTO_ESP"):
    socket.IPPROTO_ESP = 50
if not hasattr(socket, "IPPROTO_AH"):
    socket.IPPROTO_AH = 51

正如我在评论中提到的那样,我在各种 OS es( Lnx Sol AIX HPUX OSX ),并且在 Win 不存在.似乎 MS 在( VStudio ) 2005 2010 WinSock2.h 中删除了>.

As I mentioned in one of the comments, I tested using Python 2.7.10 on a variety of OSes (Lnx, Sol, AIX, HPUX, OSX) and the values seem to be consistent, while on Win they don't exist. Seems like MS removed them from WinSock2.h between (VStudio) 2005 and 2010.

这篇关于ipsec.py无法找到属性IPPROTO_ESP和socket.IPPROTO_AH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆