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


Python conf.default_l2方法代碼示例

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


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

示例1: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [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 default_l2 [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: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [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

示例4: guess_cls

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [as 別名]
def guess_cls(self):
        """Guess the packet class that must be used on the interface"""

        # Get the data link type
        try:
            ret = fcntl.ioctl(self.ins, BIOCGDLT, struct.pack('I', 0))
            ret = struct.unpack('I', ret)[0]
        except IOError:
            cls = conf.default_l2
            warning("BIOCGDLT failed: unable to guess type. Using %s !",
                    cls.name)
            return cls

        # Retrieve the corresponding class
        try:
            return conf.l2types[ret]
        except KeyError:
            cls = conf.default_l2
            warning("Unable to guess type (type %i). Using %s", ret, cls.name) 
開發者ID:secdev,項目名稱:scapy,代碼行數:21,代碼來源:supersocket.py

示例5: recv_raw

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [as 別名]
def recv_raw(self, x=MTU):
        """Receives a packet, then returns a tuple containing (cls, pkt_data, time)"""  # noqa: E501
        if self.cls is None:
            ll = self.ins.datalink()
            if ll in conf.l2types:
                self.cls = conf.l2types[ll]
            else:
                self.cls = conf.default_l2
                warning(
                    "Unable to guess datalink type "
                    "(interface=%s linktype=%i). Using %s",
                    self.iface, ll, self.cls.name
                )

        ts, pkt = self.ins.next()
        if pkt is None:
            return None, None, None
        return self.cls, pkt, ts 
開發者ID:secdev,項目名稱:scapy,代碼行數:20,代碼來源:pcapdnet.py

示例6: recv

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [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 
開發者ID:entynetproject,項目名稱:arissploit,代碼行數:26,代碼來源:pcapdnet.py

示例7: __init__

# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import default_l2 [as 別名]
def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0):
        if iface is None:
            iface = conf.iface
        self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
        self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 0)
        _flush_fd(self.ins)
        if not nofilter: 
            if conf.except_filter:
                if filter:
                    filter = "(%s) and not (%s)" % (filter, conf.except_filter)
                else:
                    filter = "not (%s)" % conf.except_filter
            if filter is not None:
                attach_filter(self.ins, filter)
        self.ins.bind((iface, type))
        self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2**30)
        self.outs = self.ins
        self.outs.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 2**30)
        sa_ll = self.outs.getsockname()
        if sa_ll[3] in conf.l2types:
            self.LL = conf.l2types[sa_ll[3]]
        elif sa_ll[1] in conf.l3types:
            self.LL = conf.l3types[sa_ll[1]]
        else:
            self.LL = 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],self.LL.name)) 
開發者ID:medbenali,項目名稱:CyberScan,代碼行數:28,代碼來源:linux.py


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