Ipsec.py CANT FIND attribute IPPROTO_ESP and socket.IPPROTO_AH

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

WARNING: unable to import ipsec layer: object 'module' does not have attribute 'IPPROTO_AH'

I looked at the socket attributes and I did not find the IPPROTO_AH attribute. Also, I tried to edit the ipsec.py module and find a way to replace IPPROTO_AH with something else, but then I received a WARNING with IPPROTO_ESP!

I tried editing lines in ipsec.py, for example:

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) 

how can i fix this?

+5
source share
1 answer

I think I have it ... this is not a clean solution, but it will do the trick ... I saw it in other scapy files ...
All you have to do is edit ipsec. py and find the import socket line just below it , add the following conventions:

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

As I mentioned in one of the comments, I tested Python 2.7.10 on various OSs (Lnx, Sol, AIX, HPUX, OSX), and the values ​​seem consistent, whereas on Win they do not exist. MS seems to have removed them from WinSock2.h between (VStudio) 2005 and 2010.

+6
source

All Articles