當前位置: 首頁>>代碼示例>>Python>>正文


Python conf.raw_layer方法代碼示例

本文整理匯總了Python中scapy.config.conf.raw_layer方法的典型用法代碼示例。如果您正苦於以下問題:Python conf.raw_layer方法的具體用法?Python conf.raw_layer怎麽用?Python conf.raw_layer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scapy.config.conf的用法示例。


在下文中一共展示了conf.raw_layer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def recv(self, x):
        pkt, sa_ll = self.ins.recvfrom(x)
        if sa_ll[3] in conf.l2types :
            cls = conf.l2types[sa_ll[3]]
        elif sa_ll[1] in conf.l3types:
            cls = conf.l3types[sa_ll[1]]
        else:
            cls = conf.default_l2
            warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))

        try:
            pkt = cls(pkt)
        except KeyboardInterrupt:
            raise
        except:
            if conf.debug_dissector:
                raise
            pkt = conf.raw_layer(pkt)
        pkt.time = get_last_packet_timestamp(self.ins)
        return pkt 
開發者ID:medbenali,項目名稱:CyberScan,代碼行數:22,代碼來源:linux.py

示例2: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def recv(self,x=MTU):
            ll = self.ins.datalink()
            if ll in conf.l2types:
                cls = conf.l2types[ll]
            else:
                cls = conf.default_l2
                warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name))
    
            pkt = self.ins.next()
            if pkt is not None:
                ts,pkt = pkt
            if pkt is None:
                return
    
            try:
                pkt = cls(pkt)
            except KeyboardInterrupt:
                raise
            except:
                if conf.debug_dissector:
                    raise
                pkt = conf.raw_layer(pkt)
            pkt.time = ts
            return pkt.payload 
開發者ID:medbenali,項目名稱:CyberScan,代碼行數:26,代碼來源:pcapdnet.py

示例3: fragment

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def fragment(pkt, fragsize=1480):
    """Fragment a big IP datagram"""
    fragsize = (fragsize+7)/8*8
    lst = []
    for p in pkt:
        s = str(p[IP].payload)
        nb = (len(s)+fragsize-1)/fragsize
        for i in range(nb):            
            q = p.copy()
            del(q[IP].payload)
            del(q[IP].chksum)
            del(q[IP].len)
            if i == nb-1:
                q[IP].flags &= ~1
            else:
                q[IP].flags |= 1 
            q[IP].frag = i*fragsize/8
            r = conf.raw_layer(load=s[i*fragsize:(i+1)*fragsize])
            r.overload_fields = p[IP].payload.overload_fields.copy()
            q.add_payload(r)
            lst.append(q)
    return lst 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:24,代碼來源:inet.py

示例4: m2i

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def m2i(self, pkt, x):
        opt = []
        while x:
            o = ord(x[0]) # Option type
            cls = self.cls
            if moboptcls.has_key(o):
                cls = moboptcls[o]
            try:
                op = cls(x)
            except:
                op = self.cls(x)
            opt.append(op)
            if isinstance(op.payload, conf.raw_layer):
                x = op.payload.load
                del(op.payload)
            else:
                x = ""
        return opt 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:20,代碼來源:inet6.py

示例5: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def recv(self, x=MTU):
        pkt, sa_ll = self.ins.recvfrom(x)
        if sa_ll[3] in conf.l2types :
            cls = conf.l2types[sa_ll[3]]
        elif sa_ll[1] in conf.l3types:
            cls = conf.l3types[sa_ll[1]]
        else:
            cls = conf.default_l2
            warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))

        try:
            pkt = cls(pkt)
        except KeyboardInterrupt:
            raise
        except:
            if conf.debug_dissector:
                raise
            pkt = conf.raw_layer(pkt)
        pkt.time = get_last_packet_timestamp(self.ins)
        return pkt 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:22,代碼來源:linux.py

示例6: _PPIGuessPayloadClass

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def _PPIGuessPayloadClass(p, **kargs):
    """ This function tells the PacketListField how it should extract the
        TLVs from the payload.  We pass cls only the length string
        pfh_len says it needs.  If a payload is returned, that means
        part of the sting was unused.  This converts to a Raw layer, and
        the remainder of p is added as Raw's payload.  If there is no
        payload, the remainder of p is added as out's payload.
    """
    if len(p) >= 4:
        t,pfh_len = struct.unpack("<HH", p[:4])
        # Find out if the value t is in the dict _ppi_types.
        # If not, return the default TLV class
        cls = getPPIType(t, "default")
        pfh_len += 4
        out = cls(p[:pfh_len], **kargs)
        if (out.payload):
            out.payload = conf.raw_layer(out.payload.load)
            if (len(p) > pfh_len):
                out.payload.payload = conf.padding_layer(p[pfh_len:])
        elif (len(p) > pfh_len):
            out.payload = conf.padding_layer(p[pfh_len:])
        
    else:
        out = conf.raw_layer(p, **kargs)
    return out 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:27,代碼來源:ppi.py

示例7: read_packet

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def read_packet(self, size=MTU):
        rp = super(PcapNgReader, self).read_packet(size=size)
        if rp is None:
            raise EOFError
        s, (linktype, tsresol, tshigh, tslow, wirelen) = rp
        try:
            p = conf.l2types[linktype](s)
        except KeyboardInterrupt:
            raise
        except Exception:
            if conf.debug_dissector:
                raise
            p = conf.raw_layer(s)
        if tshigh is not None:
            p.time = EDecimal((tshigh << 32) + tslow) / tsresol
        p.wirelen = wirelen
        return p 
開發者ID:secdev,項目名稱:scapy,代碼行數:19,代碼來源:utils.py

示例8: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def recv(self, x=MTU):
        cls, val, ts = self.recv_raw(x)
        if not val or not cls:
            return
        try:
            pkt = cls(val)
        except KeyboardInterrupt:
            raise
        except Exception:
            if conf.debug_dissector:
                from scapy.sendrecv import debug
                debug.crashed_on = (cls, val)
                raise
            pkt = conf.raw_layer(val)
        if ts:
            pkt.time = ts
        return pkt 
開發者ID:secdev,項目名稱:scapy,代碼行數:19,代碼來源:supersocket.py

示例9: add_payload

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def add_payload(self, payload):
        if payload is None:
            return
        elif not isinstance(self.payload, NoPayload):
            self.payload.add_payload(payload)
        else:
            if isinstance(payload, Packet):
                self.payload = payload
                payload.add_underlayer(self)
                for t in self.aliastypes:
                    if t in payload.overload_fields:
                        self.overloaded_fields = payload.overload_fields[t]
                        break
            elif isinstance(payload, bytes):
                self.payload = conf.raw_layer(load=payload)
            else:
                raise TypeError("payload must be either 'Packet' or 'bytes', not [%s]" % repr(payload))  # noqa: E501 
開發者ID:secdev,項目名稱:scapy,代碼行數:19,代碼來源:packet.py

示例10: do_dissect_payload

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def do_dissect_payload(self, s):
        """
        Perform the dissection of the layer's payload

        :param str s: the raw layer
        """
        if s:
            cls = self.guess_payload_class(s)
            try:
                p = cls(s, _internal=1, _underlayer=self)
            except KeyboardInterrupt:
                raise
            except Exception:
                if conf.debug_dissector:
                    if issubtype(cls, Packet):
                        log_runtime.error("%s dissector failed" % cls.__name__)
                    else:
                        log_runtime.error("%s.guess_payload_class() returned [%s]" % (self.__class__.__name__, repr(cls)))  # noqa: E501
                    if cls is not None:
                        raise
                p = conf.raw_layer(s, _internal=1, _underlayer=self)
            self.add_payload(p) 
開發者ID:secdev,項目名稱:scapy,代碼行數:24,代碼來源:packet.py

示例11: do_dissect_payload

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def do_dissect_payload(self, s):
        """
        Try to dissect the following data as a TLS message.
        Note that overloading .guess_payload_class() would not be enough,
        as the TLS session to be used would get lost.
        """
        if s:
            try:
                p = TLS(s, _internal=1, _underlayer=self,
                        tls_session=self.tls_session)
            except KeyboardInterrupt:
                raise
            except Exception:
                p = conf.raw_layer(s, _internal=1, _underlayer=self)
            self.add_payload(p)

    # Building methods 
開發者ID:secdev,項目名稱:scapy,代碼行數:19,代碼來源:record_tls13.py

示例12: getfield

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def getfield(self, pkt, s):
        length = self.length_from(pkt)
        i = None
        if length > 0:
            # RFC 1305
            # The maximum number of data octets is 468.
            #
            # include/ntp_control.h
            # u_char data[480 + MAX_MAC_LEN]; /* data + auth */
            #
            # Set the minimum length to 480 - 468
            length = max(12, length)
            if length % 4:
                length += (4 - length % 4)
        try:
            i = self.m2i(pkt, s[:length])
        except Exception:
            if conf.debug_dissector:
                raise
            i = conf.raw_layer(load=s[:length])
        return s[length:], i 
開發者ID:secdev,項目名稱:scapy,代碼行數:23,代碼來源:ntp.py

示例13: fragment

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def fragment(pkt, fragsize=1480):
    """Fragment a big IP datagram"""
    lastfragsz = fragsize
    fragsize -= fragsize % 8
    lst = []
    for p in pkt:
        s = raw(p[IP].payload)
        nb = (len(s) - lastfragsz + fragsize - 1) // fragsize + 1
        for i in range(nb):
            q = p.copy()
            del(q[IP].payload)
            del(q[IP].chksum)
            del(q[IP].len)
            if i != nb - 1:
                q[IP].flags |= 1
                fragend = (i + 1) * fragsize
            else:
                fragend = i * fragsize + lastfragsz
            q[IP].frag += i * fragsize // 8
            r = conf.raw_layer(load=s[i * fragsize:fragend])
            r.overload_fields = p[IP].payload.overload_fields.copy()
            q.add_payload(r)
            lst.append(q)
    return lst 
開發者ID:secdev,項目名稱:scapy,代碼行數:26,代碼來源:inet.py

示例14: m2i

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def m2i(self, pkt, m):
        ret = None
        type_code = pkt.type_code

        # Reserved
        if type_code == 0 or type_code == 255:
            ret = conf.raw_layer(m)
        # Unassigned
        elif (type_code >= 30 and type_code <= 39) or\
            (type_code >= 41 and type_code <= 127) or\
                (type_code >= 129 and type_code <= 254):
            ret = conf.raw_layer(m)
        # Known path attributes
        else:
            if type_code == 0x02 and not bgp_module_conf.use_2_bytes_asn:
                ret = BGPPAAS4BytesPath(m)
            else:
                ret = _get_cls(
                    _path_attr_objects.get(type_code, conf.raw_layer))(m)

        return ret 
開發者ID:secdev,項目名稱:scapy,代碼行數:23,代碼來源:bgp.py

示例15: nmap_udppacket_sig

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import raw_layer [as 別名]
def nmap_udppacket_sig(S,T):
    r={}
    if T is None:
        r["Resp"] = "N"
    else:
        r["DF"] = (T.flags & 2) and "Y" or "N"
        r["TOS"] = "%X" % T.tos
        r["IPLEN"] = "%X" % T.len
        r["RIPTL"] = "%X" % T.payload.payload.len
        r["RID"] = S.id == T.payload.payload.id and "E" or "F"
        r["RIPCK"] = S.chksum == T.getlayer(IPerror).chksum and "E" or T.getlayer(IPerror).chksum == 0 and "0" or "F"
        r["UCK"] = S.payload.chksum == T.getlayer(UDPerror).chksum and "E" or T.getlayer(UDPerror).chksum ==0 and "0" or "F"
        r["ULEN"] = "%X" % T.getlayer(UDPerror).len
        r["DAT"] = T.getlayer(conf.raw_layer) is None and "E" or S.getlayer(conf.raw_layer).load == T.getlayer(conf.raw_layer).load and "E" or "F"
    return r 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:17,代碼來源:nmap.py


注:本文中的scapy.config.conf.raw_layer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。