Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

summary() of group of IPv6 packets results in "TypeError: inet_pton() argument 2 must be str, not map" #233

Open
dkg opened this issue Jan 20, 2018 · 0 comments

Comments

@dkg
Copy link

dkg commented Jan 20, 2018

try this reproducer (tested against 0.23):

from scapy.all import IP, IPv6, TCP, sr, conf

examples = {
    'v4single': IP(dst='192.0.2.1',ttl=(1,5))/TCP(dport=80,flags='S'),
    'v4dual': IP(dst=['192.0.2.1','192.0.2.2'],ttl=(1,5))/TCP(dport=80,flags='S'),
    'v6single': IPv6(dst='2001:db8::1',hlim=(1,5))/TCP(dport=80,flags='S'),
    'v6dual': IPv6(dst=['2001:db8::1','2001:db8::2'],hlim=(1,5))/TCP(dport=80,flags='S')
}
for ex in ['v4single', 'v4dual', 'v6single', 'v6dual']:
    print(ex)
    print(examples[ex].summary())

i see as output:

v4single
IP / TCP 192.0.2.254:ftp_data > 192.0.2.1:http S
v4dual
IP / TCP 192.0.2.254:ftp_data > ['192.0.2.1', '192.0.2.2']:http S
v6single
IPv6 / TCP 2001:db8::fffe:ftp_data > 2001:db8::1:http S
v6dual
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/dkg/test.py in <module>()
     11 for ex in ['v4single', 'v4dual', 'v6single', 'v6dual']:
     12     print(ex)
---> 13     print(examples[ex].summary())
     14 

/usr/lib/python3/dist-packages/scapy/packet.py in summary(self, intern)
   1016     def summary(self, intern=0):
   1017         """Prints a one line summary of a packet."""
-> 1018         found,s,needed = self._do_summary()
   1019         return s
   1020 

/usr/lib/python3/dist-packages/scapy/packet.py in _do_summary(self)
    992 
    993     def _do_summary(self):
--> 994         found,s,needed = self.payload._do_summary()
    995         if s:
    996             s = " / "+s

/usr/lib/python3/dist-packages/scapy/packet.py in _do_summary(self)
    997         ret = ""
    998         if not found or self.__class__ in needed:
--> 999             ret = self.mysummary()
   1000             if type(ret) is tuple:
   1001                 ret,n = ret

/usr/lib/python3/dist-packages/scapy/layers/inet.py in mysummary(self)
    581             return self.underlayer.sprintf("TCP %IP.src%:%TCP.sport% > %IP.dst%:%TCP.dport% %TCP.flags%")
    582         elif conf.ipv6_enabled and isinstance(self.underlayer, scapy.layers.inet6.IPv6):
--> 583             return self.underlayer.sprintf("TCP %IPv6.src%:%TCP.sport% > %IPv6.dst%:%TCP.dport% %TCP.flags%")
    584         else:
    585             return self.sprintf("TCP %TCP.sport% > %TCP.dport% %TCP.flags%")

/usr/lib/python3/dist-packages/scapy/packet.py in sprintf(self, fmt, relax)
    975                         val = getattr(self,fld)
    976                         if fld in self.fieldtype:
--> 977                             val = self.fieldtype[fld].i2repr(self,val)
    978                 else:
    979                     val = self.payload.sprintf("%%%s%%" % sfclsfld, relax)

/usr/lib/python3/dist-packages/scapy/layers/inet6.py in i2repr(self, pkt, x)
    214             return self.i2h(pkt,x)
    215         elif not isinstance(x, Net6) and not type(x) is list:
--> 216             if in6_isaddrTeredo(x):   # print Teredo info
    217                 server, flag, maddr, mport = teredoAddrExtractInfo(x)
    218                 return "%s [Teredo srv: %s cli: %s:%s]" % (self.i2h(pkt, x), server, maddr,mport)

/usr/lib/python3/dist-packages/scapy/utils6.py in in6_isaddrTeredo(x)
    535     format.
    536     """
--> 537     our = inet_pton(socket.AF_INET6, x)[0:4]
    538     teredoPrefix = inet_pton(socket.AF_INET6, conf.teredoPrefix)[0:4]
    539     return teredoPrefix == our

TypeError: inet_pton() argument 2 must be str, not map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant