当前位置: 首页>>代码示例>>Python>>正文


Python conf.l2types方法代码示例

本文整理汇总了Python中scapy.config.conf.l2types方法的典型用法代码示例。如果您正苦于以下问题:Python conf.l2types方法的具体用法?Python conf.l2types怎么用?Python conf.l2types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.config.conf的用法示例。


在下文中一共展示了conf.l2types方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [as 别名]
def send(self, x):
        iff,a,gw  = x.route()
        if iff is None:
            iff = conf.iface
        sdto = (iff, self.type)
        self.outs.bind(sdto)
        sn = self.outs.getsockname()
        ll = lambda x:x
        if type(x) in conf.l3types:
            sdto = (iff, conf.l3types[type(x)])
        if sn[3] in conf.l2types:
            ll = lambda x:conf.l2types[sn[3]]()/x
        try:
            sx = str(ll(x))
            x.sent_time = time.time()
            self.outs.sendto(sx, sdto)
        except socket.error,msg:
            x.sent_time = time.time()  # bad approximation
            if conf.auto_fragment and msg[0] == 90:
                for p in x.fragment():
                    self.outs.sendto(str(ll(p)), sdto)
            else:
                raise 
开发者ID:medbenali,项目名称:CyberScan,代码行数:25,代码来源:linux.py

示例2: recv

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例3: recv

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例4: recv

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例5: read_packet

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例6: guess_cls

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例7: recv_raw

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [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

示例8: send

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import l2types [as 别名]
def send(self, x):
            iff,a,gw  = x.route()
            if iff is None:
                iff = conf.iface
            ifs,cls = self.iflist.get(iff,(None,None))
            if ifs is None:
                iftype = self.intf.get(iff)["type"]
                if iftype == dnet.INTF_TYPE_ETH:
                    try:
                        cls = conf.l2types[1]
                    except KeyError:
                        warning("Unable to find Ethernet class. Using nothing")
                    ifs = dnet.eth(iff)
                else:
                    ifs = dnet.ip()
                self.iflist[iff] = ifs,cls
            if cls is None:
                sx = str(x)
            else:
                sx = str(cls()/x)
            x.sent_time = time.time()
            ifs.send(sx) 
开发者ID:gpwclark,项目名称:dash-hack,代码行数:24,代码来源:pcapdnet.py


注:本文中的scapy.config.conf.l2types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。