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


Python error.warning函数代码示例

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


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

示例1: _ssl_PRF

def _ssl_PRF(secret, seed, req_len):
    """
    Provides the implementation of SSLv3 PRF function:

     SSLv3-PRF(secret, seed) =
        MD5(secret || SHA-1("A" || secret || seed)) ||
        MD5(secret || SHA-1("BB" || secret || seed)) ||
        MD5(secret || SHA-1("CCC" || secret || seed)) || ...

    req_len should not be more than  26 x 16 = 416.

    """
    if req_len > 416:
        warning("_ssl_PRF() is not expected to provide more than 416 bytes")
        return ""

    d = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
         "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
    res = ""
    hash_md5 = tls_hash_algs["MD5"]
    rounds = (req_len + hash_md5.hash_len - 1) / hash_md5.hash_len

    for i in range(rounds):
        label = d[i] * (i+1)
        tmp = tls_hash_algs["SHA"]().digest(label + secret + seed)
        res += tls_hash_algs["MD5"]().digest(secret + tmp)

    return res[:req_len]
开发者ID:thibaultdelmas,项目名称:scapy,代码行数:28,代码来源:prf.py

示例2: __init__

 def __init__(self, filename, fdesc, magic):
     RawPcapReader.__init__(self, filename, fdesc, magic)
     try:
         self.LLcls = conf.l2types[self.linktype]
     except KeyError:
         warning("PcapReader: unknown LL type [%i]/[%#x]. Using Raw packets" % (self.linktype,self.linktype))
         self.LLcls = conf.raw_layer
开发者ID:mcpat,项目名称:scapy,代码行数:7,代码来源:utils.py

示例3: process

    def process(self):
        """Entry point of SelectableSelector"""
        if WINDOWS:
            select_inputs = []
            for i in self.inputs:
                if not isinstance(i, SelectableObject):
                    warning("Unknown ignored object type: %s", type(i))
                elif i.__selectable_force_select__:
                    # Then use select.select
                    select_inputs.append(i)
                elif not self.remain and i.check_recv():
                    self.results.append(i)
                else:
                    i.wait_return(self._exit_door)
            if select_inputs:
                # Use default select function
                self.results.extend(select(select_inputs, [], [], self.remain)[0])  # noqa: E501
            if not self.remain:
                return self.results

            threading.Thread(target=self._timeout_thread, args=(self.remain,)).start()  # noqa: E501
            if not self._ended:
                self.available_lock.acquire()
            return self.results
        else:
            r, _, _ = select(self.inputs, [], [], self.remain)
            return r
开发者ID:netkey,项目名称:scapy,代码行数:27,代码来源:automaton.py

示例4: get_if_raw_addr

 def get_if_raw_addr(ifname):
     i = dnet.intf()
     try:
         return i.get(ifname)["addr"].data
     except OSError:
         warning("No MAC address found on %s !" % ifname)
         return b"\0\0\0\0"
开发者ID:thibaultdelmas,项目名称:scapy,代码行数:7,代码来源:pcapdnet.py

示例5: m2i

 def m2i(self, pkt, s):
     family = None
     if pkt.type == 1: # A
         family = socket.AF_INET
     elif pkt.type == 12: # PTR
         l = orb(s[0])
         if l & 0xc0 and hasattr(pkt, "_orig_s") and pkt._orig_s: # Compression detected
             p = ((l & ~0xc0) << 8) + orb(s[1]) - 12
             s = DNSgetstr(pkt._orig_s, p)[0]
         else: # No compression / Cannot decompress
             if hasattr(pkt, "_orig_s") and pkt._orig_s:
                 s = DNSgetstr(pkt._orig_s, pkt._orig_p)[0]
             else:
                 s = DNSgetstr(s, 0)[0]
     elif pkt.type == 16: # TXT
         ret_s = b""
         tmp_s = s
         # RDATA contains a list of strings, each are prepended with
         # a byte containing the size of the following string.
         while tmp_s:
             tmp_len = orb(tmp_s[0]) + 1
             if tmp_len > len(tmp_s):
               warning("DNS RR TXT prematured end of character-string (size=%i, remaining bytes=%i)" % (tmp_len, len(tmp_s)))
             ret_s += tmp_s[1:tmp_len]
             tmp_s = tmp_s[tmp_len:]
         s = ret_s
     elif pkt.type == 28: # AAAA
         family = socket.AF_INET6
     if family is not None:
         s = inet_ntop(family, s)
     return s
开发者ID:6WIND,项目名称:scapy,代码行数:31,代码来源:dns.py

示例6: lazy_init

 def lazy_init(self):
     try:
         f=open(self.filename)
     except IOError:
         warning("Can't open base %s" % self.filename)
         return
     try:
         self.base = []
         for l in f:
             if l[0] in ["#","\n"]:
                 continue
             l = tuple(l.split(":"))
             if len(l) < 8:
                 continue
             def a2i(x):
                 if x.isdigit():
                     return int(x)
                 return x
             li = [ a2i(i) for i in l[1:4] ]
             #if li[0] not in self.ttl_range:
             #    self.ttl_range.append(li[0])
             #    self.ttl_range.sort()
             self.base.append((l[0], li[0], li[1], li[2], l[4], l[5], l[6], l[7][:-1]))
     except:
         warning("Can't parse p0f database (new p0f version ?)")
         self.base = None
     f.close()
开发者ID:437049211,项目名称:PyQYT,代码行数:27,代码来源:p0f.py

示例7: tls_session_update

    def tls_session_update(self, msg_str):
        super(SSLv2ClientMasterKey, self).tls_session_update(msg_str)

        s = self.tls_session
        cs_val = self.cipher
        if cs_val not in _tls_cipher_suites_cls:
            warning("Unknown cipher suite %d from ClientMasterKey" % cs_val)
        else:
            cs_cls = _tls_cipher_suites_cls[cs_val]

        tls_version = s.tls_version
        connection_end = s.connection_end
        wcs_seq_num = s.wcs.seq_num
        s.pwcs = writeConnState(ciphersuite=cs_cls,
                                            connection_end=connection_end,
                                            seq_num=wcs_seq_num,
                                            tls_version=tls_version)
        rcs_seq_num = s.rcs.seq_num
        s.prcs = readConnState(ciphersuite=cs_cls,
                                           connection_end=connection_end,
                                           seq_num=rcs_seq_num,
                                           tls_version=tls_version)

        if self.decryptedkey is not None:
            s.master_secret = self.clearkey + self.decryptedkey
            s.compute_sslv2_km_and_derive_keys()

            if s.pwcs.cipher.type == "block":
                s.pwcs.cipher.iv = self.keyarg
            if s.prcs.cipher.type == "block":
                s.prcs.cipher.iv = self.keyarg

            s.triggered_prcs_commit = True
            s.triggered_pwcs_commit = True
开发者ID:mcpat,项目名称:scapy,代码行数:34,代码来源:handshake_sslv2.py

示例8: decompressSourceAddr

    def decompressSourceAddr(self, packet):
        try:
            tmp_ip = inet_pton(socket.AF_INET6, self.sourceAddr)
        except socket.error:
            tmp_ip = b"\x00" * 16

        if self.sac == 0:
            if self.sam == 0x0:
                pass
            elif self.sam == 0x1:
                tmp_ip = LINK_LOCAL_PREFIX[0:8] + tmp_ip[16 - source_addr_mode2(self):16]  # noqa: E501
            elif self.sam == 0x2:
                tmp = LINK_LOCAL_PREFIX[0:8] + b"\x00\x00\x00\xff\xfe\x00"
                tmp_ip = tmp + tmp_ip[16 - source_addr_mode2(self):16]
            elif self.sam == 0x3:  # EXTRACT ADDRESS FROM Dot15d4
                tmp_ip = _extract_dot15d4address(self, source=True)
            else:
                warning("Unknown source address compression mode !")
        else:  # self.sac == 1:
            if self.sam == 0x0:
                pass
            elif self.sam == 0x2:
                # TODO: take context IID
                tmp = LINK_LOCAL_PREFIX[0:8] + b"\x00\x00\x00\xff\xfe\x00"
                tmp_ip = tmp + tmp_ip[16 - source_addr_mode2(self):16]
            elif self.sam == 0x3:
                tmp_ip = LINK_LOCAL_PREFIX[0:8] + b"\x00" * 8  # TODO: CONTEXT ID  # noqa: E501
            else:
                raise Exception('Unimplemented')
        self.sourceAddr = inet_ntop(socket.AF_INET6, tmp_ip)
        return self.sourceAddr
开发者ID:segment-routing,项目名称:scapy,代码行数:31,代码来源:sixlowpan.py

示例9: pre_dissect

    def pre_dissect(self, m):
        s = self.tls_session
        tbd = m
        if s.tls_version >= 0x0301:
            if len(m) < 2:      # Should not happen
                return m
            l = struct.unpack("!H", m[:2])[0]
            if len(m) != l + 2:
                err = "TLS 1.0+, but RSA Encrypted PMS with no explicit length"
                warning(err)
            else:
                tbd = m[2:]
        if s.server_tmp_rsa_key is not None:
            # priority is given to the tmp_key, if there is one
            decrypted = s.server_tmp_rsa_key.decrypt(tbd)
            pms = decrypted[-48:]
        elif s.server_rsa_key is not None:
            decrypted = s.server_rsa_key.decrypt(tbd)
            pms = decrypted[-48:]
        else:
            # the dispatch_hook is supposed to prevent this case
            pms = b"\x00" * 48
            err = "No server RSA key to decrypt Pre Master Secret. Skipping."
            warning(err)

        s.pre_master_secret = pms
        s.compute_ms_and_derive_keys()

        return pms
开发者ID:plorinquer,项目名称:scapy,代码行数:29,代码来源:keyexchange.py

示例10: compute_tls13_handshake_secrets

    def compute_tls13_handshake_secrets(self):
        """
        Ciphers key and IV are updated accordingly for Handshake data.
        self.handshake_messages should be ClientHello...ServerHello.
        """
        if self.tls13_early_secret is None:
            warning("No early secret. This is abnormal.")

        hkdf = self.prcs.hkdf

        self.tls13_handshake_secret = hkdf.extract(self.tls13_early_secret,
                                                   self.tls13_dhe_secret)

        chts = hkdf.derive_secret(self.tls13_handshake_secret,
                                  "client handshake traffic secret",
                                  "".join(self.handshake_messages))
        self.tls13_derived_secrets["client_handshake_traffic_secret"] = chts

        shts = hkdf.derive_secret(self.tls13_handshake_secret,
                                  "server handshake traffic secret",
                                  "".join(self.handshake_messages))
        self.tls13_derived_secrets["server_handshake_traffic_secret"] = shts

        if self.connection_end == "server":
            self.prcs.tls13_derive_keys(chts)
            self.pwcs.tls13_derive_keys(shts)
        elif self.connection_end == "client":
            self.pwcs.tls13_derive_keys(chts)
            self.prcs.tls13_derive_keys(shts)
开发者ID:mcpat,项目名称:scapy,代码行数:29,代码来源:session.py

示例11: start

 def start(self):
     if self.thread_lock.acquire(0):
         _t = Thread(target=self.run)
         _t.start()
         self.threadid = _t.ident
     else:
         warning("Pipe engine already running")
开发者ID:thibaultdelmas,项目名称:scapy,代码行数:7,代码来源:pipetool.py

示例12: fill_and_store

    def fill_and_store(self, modulus=None, modulusLen=None, pubExp=None,
                             prime1=None, prime2=None, coefficient=None,
                             exponent1=None, exponent2=None, privExp=None):
        pubExp = pubExp or 65537
        if None in [modulus, prime1, prime2, coefficient, privExp,
                    exponent1, exponent2]:
            # note that the library requires every parameter
            # in order to call RSAPrivateNumbers(...)
            # if one of these is missing, we generate a whole new key
            real_modulusLen = modulusLen or 2048
            self.key = rsa.generate_private_key(public_exponent=pubExp,
                                                key_size=real_modulusLen,
                                                backend=default_backend())
            self.pubkey = self.key.public_key()
        else:
            real_modulusLen = len(binrepr(modulus))
            if modulusLen and real_modulusLen != modulusLen:
                warning("modulus and modulusLen do not match!")
            pubNum = rsa.RSAPublicNumbers(n=modulus, e=pubExp)
            privNum = rsa.RSAPrivateNumbers(p=prime1, q=prime2,
                                            dmp1=exponent1, dmq1=exponent2,
                                            iqmp=coefficient, d=privExp,
                                            public_numbers=pubNum)
            self.key = privNum.private_key(default_backend())
            self.pubkey = self.key.public_key()

        # Lines below are only useful for the legacy part of pkcs1.py
        pubNum = self.pubkey.public_numbers()
        self._modulusLen = real_modulusLen
        self._modulus = pubNum.n
        self._pubExp = pubNum.e
开发者ID:6WIND,项目名称:scapy,代码行数:31,代码来源:cert.py

示例13: __init__

 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) e nao (%s)" % (filter, conf.except_filter)
             else:
                 filter = "nao (%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("Impossivel saber o tipo (interface=%s protocol=%#x familia=%i). Usando %s" % (sa_ll[0],sa_ll[1],sa_ll[3],self.LL.name))
开发者ID:Marcus1911,项目名称:mptcp-scapy,代码行数:26,代码来源:linux.py

示例14: recv

    def recv(self, x=MTU):
        pkt, sa_ll = self.ins.recvfrom(x)
        if sa_ll[2] == socket.PACKET_OUTGOING:
            return None
        if sa_ll[3] in conf.l2types:
            cls = conf.l2types[sa_ll[3]]
            lvl = 2
        elif sa_ll[1] in conf.l3types:
            cls = conf.l3types[sa_ll[1]]
            lvl = 3
        else:
            cls = conf.default_l2
            warning(" Impossivel saber o tipo (interface=%s protocol=%#x familia=%i). Usando %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name))
            lvl = 2

        try:
            pkt = cls(pkt)
        except KeyboardInterrupt:
            raise
        except:
            if conf.debug_dissector:
                raise
            pkt = conf.raw_layer(pkt)
        if lvl == 2:
            pkt = pkt.payload
            
        if pkt is not None:
            pkt.time = get_last_packet_timestamp(self.ins)
        return pkt
开发者ID:Marcus1911,项目名称:mptcp-scapy,代码行数:29,代码来源:linux.py

示例15: guess_payload_class

 def guess_payload_class(self, payload):
     if self.type == TZSP.TYPE_KEEPALIVE:
         if len(payload):
             warning('payload (%i bytes) in KEEPALIVE/NULL packet' % len(payload))  # noqa: E501
         return Raw
     else:
         return _tzsp_guess_next_tag(payload)
开发者ID:segment-routing,项目名称:scapy,代码行数:7,代码来源:tzsp.py


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