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


Python six.itervalues函数代码示例

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


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

示例1: auth_encrypt

    def auth_encrypt(self, P, A, seq_num):
        """
        Encrypt the data, and append the computed authentication code.
        TLS 1.3 does not use additional data, but we leave this option to the
        user nonetheless.

        Note that the cipher's authentication tag must be None when encrypting.
        """
        if False in six.itervalues(self.ready):
            raise CipherError(P, A)

        if hasattr(self, "pc_cls"):
            self._cipher.mode._tag = None
            self._cipher.mode._initialization_vector = self._get_nonce(seq_num)
            encryptor = self._cipher.encryptor()
            encryptor.authenticate_additional_data(A)
            res = encryptor.update(P) + encryptor.finalize()
            res += encryptor.tag
        else:
            if (conf.crypto_valid_advanced and
                    isinstance(self._cipher, AESCCM)):
                res = self._cipher.encrypt(self._get_nonce(seq_num), P, A,
                                           tag_length=self.tag_len)
            else:
                res = self._cipher.encrypt(self._get_nonce(seq_num), P, A)
        return res
开发者ID:plorinquer,项目名称:scapy,代码行数:26,代码来源:cipher_aead.py

示例2: _read_routes_xp

def _read_routes_xp():
    # The InterfaceIndex in Win32_IP4RouteTable does not match the
    # InterfaceIndex in Win32_NetworkAdapter under some platforms
    # (namely Windows XP): let's try an IP association
    routes = []
    partial_routes = []
    # map local IP addresses to interfaces
    local_addresses = {iface.ip: iface for iface in six.itervalues(IFACES)}
    iface_indexes = {}
    for line in exec_query(['Get-WmiObject', 'Win32_IP4RouteTable'],
                           ['Name', 'Mask', 'NextHop', 'InterfaceIndex', 'Metric1']):
        if line[2] in local_addresses:
            iface = local_addresses[line[2]]
            # This gives us an association InterfaceIndex <-> interface
            iface_indexes[line[3]] = iface
            routes.append((atol(line[0]), atol(line[1]), "0.0.0.0", iface,
                           iface.ip, int(line[4])))
        else:
            partial_routes.append((atol(line[0]), atol(line[1]), line[2],
                                   line[3], int(line[4])))
    for dst, mask, gw, ifidx, metric in partial_routes:
        if ifidx in iface_indexes:
            iface = iface_indexes[ifidx]
            routes.append((dst, mask, gw, iface, iface.ip, metric))
    return routes
开发者ID:dark-lbp,项目名称:scapy,代码行数:25,代码来源:__init__.py

示例3: getfield

 def getfield(self, pkt, s):
     if (pkt.tls_session.rcs.cipher.type != "aead" and
             False in six.itervalues(pkt.tls_session.rcs.cipher.ready)):
         # XXX Find a more proper way to handle the still-encrypted case
         return s, b""
     tmp_len = pkt.tls_session.rcs.mac_len
     return s[tmp_len:], self.m2i(pkt, s[:tmp_len])
开发者ID:commial,项目名称:scapy,代码行数:7,代码来源:basefields.py

示例4: dev_from_pcapname

 def dev_from_pcapname(self, pcap_name):
     """Return Windows device name for given pcap device name."""
     try:
         return next(iface for iface in six.itervalues(self)
                     if iface.pcap_name == pcap_name)
     except StopIteration:
         raise ValueError("Unknown pypcap network interface %r" % pcap_name)
开发者ID:plorinquer,项目名称:scapy,代码行数:7,代码来源:__init__.py

示例5: __init__

 def __init__(self, objlist=None):
     self.objlist = [
         x._asn1_obj
         for x in six.itervalues(ASN1_Class_UNIVERSAL.__rdict__)
         if hasattr(x, "_asn1_obj")
     ] if objlist is None else objlist
     self.chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"  # noqa: E501
开发者ID:plorinquer,项目名称:scapy,代码行数:7,代码来源:asn1.py

示例6: _get_valid_guid

def _get_valid_guid():
    if scapy.consts.LOOPBACK_INTERFACE:
        return scapy.consts.LOOPBACK_INTERFACE.guid
    else:
        for i in six.itervalues(IFACES):
            if not i.is_invalid():
                return i.guid
开发者ID:dark-lbp,项目名称:scapy,代码行数:7,代码来源:__init__.py

示例7: dev_from_name

 def dev_from_name(self, name):
     """Return the first pcap device name for a given Windows
     device name.
     """
     for iface in six.itervalues(self):
         if iface.name == name:
             return iface
     raise ValueError("Unknown network interface %r" % name)
开发者ID:dark-lbp,项目名称:scapy,代码行数:8,代码来源:__init__.py

示例8: dev_from_name

 def dev_from_name(self, name):
     """Return the first pcap device name for a given Windows
     device name.
     """
     try:
         return next(iface for iface in six.itervalues(self)
                     if iface.name == name)
     except StopIteration:
         raise ValueError("Unknown network interface %r" % name)
开发者ID:plorinquer,项目名称:scapy,代码行数:9,代码来源:__init__.py

示例9: encrypt

 def encrypt(self, data):
     """
     Encrypt the data. Also, update the cipher iv. This is needed for SSLv3
     and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build().
     """
     if False in six.itervalues(self.ready):
         raise CipherError(data)
     encryptor = self._cipher.encryptor()
     tmp = encryptor.update(data) + encryptor.finalize()
     self.iv = tmp[-self.block_size:]
     return tmp
开发者ID:6WIND,项目名称:scapy,代码行数:11,代码来源:cipher_block.py

示例10: randval

 def randval(self):
     randchoices = []
     for p in six.itervalues(self.choices):
         if hasattr(p, "ASN1_root"):   # should be ASN1_Packet class
             randchoices.append(packet.fuzz(p()))
         elif hasattr(p, "ASN1_tag"):
             if isinstance(p, type):       # should be (basic) ASN1F_field class  # noqa: E501
                 randchoices.append(p("dummy", None).randval())
             else:                     # should be ASN1F_PACKET instance
                 randchoices.append(p.randval())
     return RandChoice(*randchoices)
开发者ID:commial,项目名称:scapy,代码行数:11,代码来源:asn1fields.py

示例11: dev_from_index

 def dev_from_index(self, if_index):
     """Return interface name from interface index"""
     try:
         return next(iface for iface in six.itervalues(self)
                     if iface.win_index == str(if_index))
     except StopIteration:
         if str(if_index) == "1":
             # Test if the loopback interface is set up
             if isinstance(scapy.consts.LOOPBACK_INTERFACE, NetworkInterface):  # noqa: E501
                 return scapy.consts.LOOPBACK_INTERFACE
         raise ValueError("Unknown network interface index %r" % if_index)
开发者ID:plorinquer,项目名称:scapy,代码行数:11,代码来源:__init__.py

示例12: graph

    def graph(self, **kargs):
        s = 'digraph "%s" {\n'  % self.__class__.__name__
        
        se = "" # Keep initial nodes at the begining for better rendering
        for st in six.itervalues(self.states):
            if st.atmt_initial:
                se = ('\t"%s" [ style=filled, fillcolor=blue, shape=box, root=true];\n' % st.atmt_state)+se
            elif st.atmt_final:
                se += '\t"%s" [ style=filled, fillcolor=green, shape=octagon ];\n' % st.atmt_state
            elif st.atmt_error:
                se += '\t"%s" [ style=filled, fillcolor=red, shape=octagon ];\n' % st.atmt_state
        s += se

        for st in six.itervalues(self.states):
            for n in st.atmt_origfunc.__code__.co_names+st.atmt_origfunc.__code__.co_consts:
                if n in self.states:
                    s += '\t"%s" -> "%s" [ color=green ];\n' % (st.atmt_state,n)
            

        for c,k,v in ([("purple",k,v) for k,v in self.conditions.items()]+
                      [("red",k,v) for k,v in self.recv_conditions.items()]+
                      [("orange",k,v) for k,v in self.ioevents.items()]):
            for f in v:
                for n in f.__code__.co_names+f.__code__.co_consts:
                    if n in self.states:
                        l = f.atmt_condname
                        for x in self.actions[f.atmt_condname]:
                            l += "\\l>[%s]" % x.__name__
                        s += '\t"%s" -> "%s" [label="%s", color=%s];\n' % (k,n,l,c)
        for k,v in six.iteritems(self.timeout):
            for t,f in v:
                if f is None:
                    continue
                for n in f.__code__.co_names+f.__code__.co_consts:
                    if n in self.states:
                        l = "%s/%.1fs" % (f.atmt_condname,t)                        
                        for x in self.actions[f.atmt_condname]:
                            l += "\\l>[%s]" % x.__name__
                        s += '\t"%s" -> "%s" [label="%s",color=blue];\n' % (k,n,l)
        s += "}\n"
        return do_graph(s, **kargs)
开发者ID:mcpat,项目名称:scapy,代码行数:41,代码来源:automaton.py

示例13: decrypt

 def decrypt(self, data):
     """
     Decrypt the data. Also, update the cipher iv. This is needed for SSLv3
     and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.pre_dissect().
     If we lack the key, we raise a CipherError which contains the input.
     """
     if False in six.itervalues(self.ready):
         raise CipherError(data)
     decryptor = self._cipher.decryptor()
     tmp = decryptor.update(data) + decryptor.finalize()
     self.iv = data[-self.block_size:]
     return tmp
开发者ID:6WIND,项目名称:scapy,代码行数:12,代码来源:cipher_block.py

示例14: post_dissection

    def post_dissection(self, r):
        if not self.tls_session.frozen and self.server_share.pubkey:
            # if there is a pubkey, we assume the crypto library is ok
            pubshare = self.tls_session.tls13_server_pubshare
            if len(pubshare) > 0:
                pkt_info = r.firstlayer().summary()
                log_runtime.info("TLS: overwriting previous server key share [%s]", pkt_info)  # noqa: E501
            group_name = _tls_named_groups[self.server_share.group]
            pubshare[group_name] = self.server_share.pubkey

            if group_name in self.tls_session.tls13_client_privshares:
                pubkey = self.server_share.pubkey
                privkey = self.tls_session.tls13_client_privshares[group_name]
                if group_name in six.itervalues(_tls_named_ffdh_groups):
                    pms = privkey.exchange(pubkey)
                elif group_name in six.itervalues(_tls_named_curves):
                    if group_name == "x25519":
                        pms = privkey.exchange(pubkey)
                    else:
                        pms = privkey.exchange(ec.ECDH(), pubkey)
                self.tls_session.tls13_dhe_secret = pms
        return super(TLS_Ext_KeyShare_SH, self).post_dissection(r)
开发者ID:commial,项目名称:scapy,代码行数:22,代码来源:keyexchange_tls13.py

示例15: auth_decrypt

    def auth_decrypt(self, A, C, seq_num=None, add_length=True):
        """
        Decrypt the data and authenticate the associated data (i.e. A).
        If the verification fails, an AEADTagError is raised. It is the user's
        responsibility to catch it if deemed useful. If we lack the key, we
        raise a CipherError which contains the encrypted input.

        Note that we add the TLSCiphertext length to A although we're supposed
        to add the TLSCompressed length. Fortunately, they are the same,
        but the specifications actually messed up here. :'(

        The 'add_length' switch should always be True for TLS, but we provide
        it anyway (mostly for test cases, hum).

        The 'seq_num' should never be used here, it is only a safeguard needed
        because one cipher (ChaCha20Poly1305) using TLS 1.2 logic in record.py
        actually is a _AEADCipher_TLS13 (even though others are not).
        """
        nonce_explicit_str, C, mac = (C[:self.nonce_explicit_len],
                                      C[self.nonce_explicit_len:-self.tag_len],
                                      C[-self.tag_len:])

        if False in six.itervalues(self.ready):
            raise CipherError(nonce_explicit_str, C, mac)

        self.nonce_explicit = pkcs_os2ip(nonce_explicit_str)
        if add_length:
            A += struct.pack("!H", len(C))

        if hasattr(self, "pc_cls"):
            self._cipher.mode._initialization_vector = self._get_nonce()
            self._cipher.mode._tag = mac
            decryptor = self._cipher.decryptor()
            decryptor.authenticate_additional_data(A)
            P = decryptor.update(C)
            try:
                decryptor.finalize()
            except InvalidTag:
                raise AEADTagError(nonce_explicit_str, P, mac)
        else:
            try:
                if isinstance(self._cipher, AESCCM):
                    P = self._cipher.decrypt(self._get_nonce(), C + mac, A,
                                             tag_length=self.tag_len)
                else:
                    P = self._cipher.decrypt(self._get_nonce(), C + mac, A)
            except InvalidTag:
                raise AEADTagError(nonce_explicit_str,
                                   "<unauthenticated data>",
                                   mac)
        return nonce_explicit_str, P, mac
开发者ID:plorinquer,项目名称:scapy,代码行数:51,代码来源:cipher_aead.py


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