Python scapy.utils.inet_ntoa() Examples

The following are 17 code examples of scapy.utils.inet_ntoa(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module scapy.utils , or try the search function .
Example #1
Source File: ldp.py    From scapy with GNU General Public License v2.0 6 votes vote down vote up
def m2i(self, pkt, x):
        used = 0
        x = x[4:]
        list = []
        while x:
            # if x[0] == 1:
            #   list.append('Wildcard')
            # else:
            # mask=orb(x[8*i+3])
            # add=inet_ntoa(x[8*i+4:8*i+8])
            mask = orb(x[3])
            nbroctets = mask // 8
            if mask % 8:
                nbroctets += 1
            add = inet_ntoa(x[4:4 + nbroctets] + b"\x00" * (4 - nbroctets))
            list.append((add, mask))
            used += 4 + nbroctets
            x = x[4 + nbroctets:]
        return list 
Example #2
Source File: ldp.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def m2i(self, pkt, x):
        nbr = struct.unpack("!H", x[2:4])[0] - 2
        nbr //= 4
        x = x[6:]
        list = []
        for i in range(0, nbr):
            add = x[4 * i:4 * i + 4]
            list.append(inet_ntoa(add))
        return list 
Example #3
Source File: ber.py    From arissploit with GNU General Public License v3.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #4
Source File: ber.py    From POC-EXP with GNU General Public License v3.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #5
Source File: ber.py    From isip with MIT License 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #6
Source File: ber.py    From dash-hack with MIT License 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #7
Source File: ber.py    From dash-hack with MIT License 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #8
Source File: ber.py    From dash-hack with MIT License 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #9
Source File: eigrp.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def m2i(self, pkt, x):
        tmp_len = self.length_from(pkt)

        if tmp_len <= 8:
            x += b"\x00\x00\x00"
        elif tmp_len <= 16:
            x += b"\x00\x00"
        elif tmp_len <= 24:
            x += b"\x00"

        return inet_ntoa(x) 
Example #10
Source File: diameter.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def i2repr(self, pkt, x):
        if x.startswith(b'\x00\x01'):  # IPv4 address
            return inet_ntoa(x[2:])
        elif x.startswith(b'\x00\x02'):    # IPv6 address
            return inet_ntop(socket.AF_INET6, x[2:])
        else:   # Address format not yet decoded
            print('Warning: Address format not yet decoded.')
            return bytes_hex(x) 
Example #11
Source File: ber.py    From CyberScan with GNU General Public License v3.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #12
Source File: ber.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l, s, t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded",
                                     remaining=s)
        return cls.asn1_object(ipaddr_ascii), t 
Example #13
Source File: fields.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, name, default, wordbytes=1, length_from=None):
        _IPPrefixFieldBase.__init__(self, name, default, wordbytes, 4, inet_aton, inet_ntoa, length_from)  # noqa: E501 
Example #14
Source File: fields.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def m2i(self, pkt, x):
        return inet_ntoa(x) 
Example #15
Source File: ber.py    From mptcp-abuse with GNU General Public License v2.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #16
Source File: ber.py    From CVE-2016-6366 with MIT License 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t 
Example #17
Source File: ber.py    From smod-1 with GNU General Public License v2.0 5 votes vote down vote up
def do_dec(cls, s, context=None, safe=False):
        l,s,t = cls.check_type_check_len(s)
        try:
            ipaddr_ascii = inet_ntoa(s)
        except Exception:
            raise BER_Decoding_Error("IP address could not be decoded", decoded=obj)
        return cls.asn1_object(ipaddr_ascii), t