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


Python log_runtime.error方法代码示例

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


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

示例1: do_dissect_payload

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

示例2: _check_field_type

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def _check_field_type(self, pkt, index):
        """
        check if the field addressed by given index relative to this field
        shares type of this field so we can catch a mix of LEBitField
        and BitField/other types
        """
        my_idx = pkt.fields_desc.index(self)
        try:
            next_field = pkt.fields_desc[my_idx + index]
            if type(next_field) is not LEBitField and \
               next_field.__class__.__base__ is not LEBitField:
                raise LEBitFieldSequenceException('field after field {} must '
                                                  'be of type LEBitField or '
                                                  'derived classes'.format(self.name))  # noqa: E501
        except IndexError:
            # no more fields -> error
            raise LEBitFieldSequenceException('Missing further LEBitField '
                                              'based fields after field '
                                              '{} '.format(self.name)) 
开发者ID:secdev,项目名称:scapy,代码行数:21,代码来源:ethercat.py

示例3: recv

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def recv(self, x=MTU):
        pkt = self.ins.recv(x, socket.MSG_PEEK)
        x = len(pkt)
        if x == 0:
            raise socket.error((100,"Underlying stream socket tore down"))
        pkt = self.basecls(pkt)
        pad = pkt.getlayer(conf.padding_layer)
        if pad is not None and pad.underlayer is not None:
            del(pad.underlayer.payload)
        while pad is not None and not isinstance(pad, NoPayload):
            x -= len(pad.load)
            pad = pad.payload
        self.ins.recv(x)
        return pkt 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:16,代码来源:supersocket.py

示例4: send

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def send(self, x):
        try:
            sx = str(x)
            x.sent_time = time.time()
            self.outs.sendto(sx,(x.dst,0))
        except socket.error,msg:
            log_runtime.error(msg) 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:9,代码来源:supersocket.py

示例5: atol

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def atol(x):
    try:
        ip = inet_aton(x)
    except socket.error:
        ip = inet_aton(socket.gethostbyname(x))
    return struct.unpack("!I", ip)[0] 
开发者ID:secdev,项目名称:scapy,代码行数:8,代码来源:utils.py

示例6: valid_ip

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def valid_ip(addr):
    try:
        addr = plain_str(addr)
    except UnicodeDecodeError:
        return False
    try:
        atol(addr)
    except (OSError, ValueError, socket.error):
        return False
    return True 
开发者ID:secdev,项目名称:scapy,代码行数:12,代码来源:utils.py

示例7: valid_ip6

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def valid_ip6(addr):
    try:
        addr = plain_str(addr)
    except UnicodeDecodeError:
        return False
    try:
        inet_pton(socket.AF_INET6, addr)
    except socket.error:
        try:
            socket.getaddrinfo(addr, None, socket.AF_INET6)[0][4][0]
        except socket.error:
            return False
    return True 
开发者ID:secdev,项目名称:scapy,代码行数:15,代码来源:utils.py

示例8: __exit__

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
        if exc_value is None:
            return
        # Errored
        if isinstance(exc_value, EnvironmentError):
            msg = "Could not execute %s, is it installed?" % self.prog
        else:
            msg = "%s: execution failed (%s)" % (
                self.prog,
                exc_type.__class__.__name__
            )
        if not self.suppress:
            raise exc_type(msg)
        log_runtime.error(msg, exc_info=True)
        return True  # Suppress the exception 
开发者ID:secdev,项目名称:scapy,代码行数:17,代码来源:utils.py

示例9: import_hexcap

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def import_hexcap(input_string=None):
    """Imports a tcpdump like hexadecimal view

    e.g: exported via hexdump() or tcpdump or wireshark's "export as hex"

    :param input_string: String containing the hexdump input to parse. If None,
        read from standard input.
    """
    re_extract_hexcap = re.compile(r"^((0x)?[0-9a-fA-F]{2,}[ :\t]{,3}|) *(([0-9a-fA-F]{2} {,2}){,16})")  # noqa: E501
    p = ""
    try:
        if input_string:
            input_function = six.StringIO(input_string).readline
        else:
            input_function = input
        while True:
            line = input_function().strip()
            if not line:
                break
            try:
                p += re_extract_hexcap.match(line).groups()[2]
            except Exception:
                warning("Parsing error during hexcap")
                continue
    except EOFError:
        pass

    p = p.replace(" ", "")
    return hex_bytes(p) 
开发者ID:secdev,项目名称:scapy,代码行数:31,代码来源:utils.py

示例10: select

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def select(sockets, remain=conf.recv_poll_rate):
        """This function is called during sendrecv() routine to select
        the available sockets.

        :param sockets: an array of sockets that need to be selected
        :returns: an array of sockets that were selected and
            the function to be called next to get the packets (i.g. recv)
        """
        try:
            inp, _, _ = select(sockets, [], [], remain)
        except (IOError, select_error) as exc:
            # select.error has no .errno attribute
            if not exc.args or exc.args[0] != errno.EINTR:
                raise
        return inp, None 
开发者ID:secdev,项目名称:scapy,代码行数:17,代码来源:supersocket.py

示例11: send

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def send(self, x):
        try:
            sx = raw(x)
            x.sent_time = time.time()
            return self.outs.sendto(sx, (x.dst, 0))
        except socket.error as msg:
            log_runtime.error(msg) 
开发者ID:secdev,项目名称:scapy,代码行数:9,代码来源:supersocket.py

示例12: recv

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def recv(self, x=65535):
        pkt = None
        if self._buf != b"":
            try:
                pkt = self.basecls(self._buf)
            except Exception:
                # We assume that the exception is generated by a buffer underflow  # noqa: E501
                pass

        if not pkt:
            buf = self.ins.recv(x)
            if len(buf) == 0:
                raise socket.error((100, "Underlying stream socket tore down"))
            self._buf += buf

        x = len(self._buf)
        pkt = self.basecls(self._buf)
        pad = pkt.getlayer(conf.padding_layer)

        if pad is not None and pad.underlayer is not None:
            del(pad.underlayer.payload)
        while pad is not None and not isinstance(pad, scapy.packet.NoPayload):
            x -= len(pad.load)
            pad = pad.payload
        self._buf = self._buf[x:]
        return pkt 
开发者ID:secdev,项目名称:scapy,代码行数:28,代码来源:supersocket.py

示例13: setmonitor

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def setmonitor(self, enable=True):
        """Alias for setmode('monitor') or setmode('managed')
        Only available with Npcap"""
        # We must reset the monitor cache
        if enable:
            res = self.setmode('monitor')
        else:
            res = self.setmode('managed')
        if not res:
            log_runtime.error("Npcap WlanHelper returned with an error code !")
        self.cache_mode = None
        tmp = self.cache_mode = self.ismonitor()
        return tmp if enable else (not tmp) 
开发者ID:secdev,项目名称:scapy,代码行数:15,代码来源:__init__.py

示例14: guess_payload_class

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def guess_payload_class(self, payload):

        try:
            dlpdu_type = payload[0]
            return EtherCat.ETHERCAT_TYPE12_DLPDU_TYPES[dlpdu_type]

        except KeyError:
            log_runtime.error(
                '{}.guess_payload_class() - unknown or invalid '
                'DLPDU type'.format(self.__class__.__name__))
            return Packet.guess_payload_class(self, payload)

    # structure templates lacking leading cmd-attribute 
开发者ID:secdev,项目名称:scapy,代码行数:15,代码来源:ethercat.py

示例15: send

# 需要导入模块: from scapy.error import log_runtime [as 别名]
# 或者: from scapy.error.log_runtime import error [as 别名]
def send(self, x):
        try:
            #sx = str(x)
            sx = bytes(x)
            x.sent_time = time.time()
            self.outs.sendto(sx,(x.dst,0))
        except socket.error as msg:
            log_runtime.error(msg) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:10,代码来源:supersocket.py


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