scapy.layers.tls.handshake

TLS handshake fields & logic.

This module covers the handshake TLS subprotocol, except for the key exchange mechanisms which are addressed with keyexchange.py.

class scapy.layers.tls.handshake.SupDataEntry(_pkt, /, *, sdtype=None, len=None, data=b'')[源代码]

基类:Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             SDTYPE            |              LEN              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. SupDataEntry                         
SupDataEntry fields

sdtype

ShortField

None

len

FieldLenField

None

data

StrLenField

b''

guess_payload_class(p)[源代码]
class scapy.layers.tls.handshake.SupDataEntryUM(_pkt, /, *, sdtype=None, len=None, dlen=None, data=[])[源代码]

基类:Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             SDTYPE            |              LEN              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              DLEN             |              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. SupDataEntryUM                        
SupDataEntryUM fields

sdtype

ShortField

None

len

FieldLenField

None

dlen

FieldLenField

None

data

PacketListField

[]

guess_payload_class(p)[源代码]
class scapy.layers.tls.handshake.TLS13Certificate(_pkt, /, *, msgtype=11, msglen=None, cert_req_ctxt_len=None, cert_req_ctxt=b'', certslen=None, certs=[])[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |CERT REQ CTXT L|         CERT REQ CTXT         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            CERTSLEN                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             CERTS             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. TLS13Certificate                       
TLS13Certificate fields

msgtype

ByteEnumField

11

msglen

ThreeBytesField

None

cert_req_ctxt_len

FieldLenField

None

cert_req_ctxt

StrLenField

b''

certslen

_ASN1CertLenField

None

certs

_ASN1CertAndExtListField

[]

post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLS13CertificateRequest(_pkt, /, *, msgtype=13, msglen=None, cert_req_ctxt_len=None, cert_req_ctxt=b'', extlen=None, ext=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |CERT REQ CTXT L|         CERT REQ CTXT         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             EXTLEN            |              EXT              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. TLS13CertificateRequest                   
TLS13CertificateRequest fields

msgtype

ByteEnumField

13

msglen

ThreeBytesField

None

cert_req_ctxt_len

FieldLenField

None

cert_req_ctxt

StrLenField

b''

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

class scapy.layers.tls.handshake.TLS13ClientHello(_pkt, /, *, msgtype=1, msglen=None, version=None, random_bytes=None, sidlen=None, sid=b'', cipherslen=None, ciphers=None, complen=None, comp=[0], extlen=None, ext=None)[源代码]

基类:_TLSHandshake

TLS 1.3 ClientHello, with abilities to handle extensions.

The Random structure is 32 random bytes without any GMT time

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            VERSION            |  RANDOM BYTES |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |     SIDLEN    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              SID              |           CIPHERSLEN          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            CIPHERS            |    COMPLEN    |      COMP     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             EXTLEN            |      EXT      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                      Fig. TLS13ClientHello                       
TLS13ClientHello fields

msgtype

ByteEnumField

1

msglen

ThreeBytesField

None

version

_TLSClientVersionField

None

random_bytes

_TLSRandomBytesField

None

sidlen

FieldLenField

None

sid

_SessionIDField

b''

cipherslen

FieldLenField

None

ciphers

_CipherSuitesField

None

complen

FieldLenField

None

comp

_CompressionMethodsField

[0]

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_build(p, pay)[源代码]
tls_session_update(msg_str)[源代码]

Either for parsing or building, we store the client_random along with the raw string representing this handshake message.

class scapy.layers.tls.handshake.TLS13EndOfEarlyData(_pkt, /, *, msgtype=5, msglen=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                     Fig. TLS13EndOfEarlyData                     
TLS13EndOfEarlyData fields

msgtype

ByteEnumField

5

msglen

ThreeBytesField

None

class scapy.layers.tls.handshake.TLS13HelloRetryRequest(_pkt, /, *, msgtype=2, msglen=None, version=771, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[源代码]

基类:_TLSHandshake

aliastypes
build()[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            VERSION            |  RANDOM BYTES |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |     SIDLEN    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              SID              |             CIPHER            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              COMP             |             EXTLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              EXT              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. TLS13HelloRetryRequest                    
TLS13HelloRetryRequest fields

msgtype

ByteEnumField

2

msglen

ThreeBytesField

None

version

_TLSVersionField

771

random_bytes

_TLSRandomBytesField

None

sidlen

FieldLenField

None

sid

_SessionIDField

b''

cipher

ShortEnumField

None

comp

_CompressionMethodsField

[0]

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLS13KeyUpdate(_pkt, /, *, msgtype=24, msglen=None, request_update=0)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               | REQUEST UPDATE|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. TLS13KeyUpdate                        
TLS13KeyUpdate fields

msgtype

ByteEnumField

24

msglen

ThreeBytesField

None

request_update

ByteEnumField

0

post_build_tls_session_update(msg_str)[源代码]
post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLS13NewSessionTicket(_pkt, /, *, msgtype=4, msglen=None, ticket_lifetime=4294967295, ticket_age_add=0, noncelen=None, ticket_nonce=b'', ticketlen=None, ticket=b'', extlen=None, ext=None)[源代码]

基类:_TLSHandshake

Uncomment the TicketField line for parsing a RFC 5077 ticket.

aliastypes
build()[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                TICKET LIFETIME                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                 TICKET AGE ADD                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |    NONCELEN   |          TICKET NONCE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           TICKETLEN           |             TICKET            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             EXTLEN            |              EXT              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLS13NewSessionTicket                    
TLS13NewSessionTicket fields

msgtype

ByteEnumField

4

msglen

ThreeBytesField

None

ticket_lifetime

IntField

4294967295

ticket_age_add

IntField

0

noncelen

FieldLenField

None

ticket_nonce

StrLenField

b''

ticketlen

FieldLenField

None

ticket

StrLenField

b''

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLS13ServerHello(_pkt, /, *, msgtype=2, msglen=None, version=771, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[源代码]

基类:TLSServerHello

TLS 1.3 ServerHello

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            VERSION            |  RANDOM BYTES |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |     SIDLEN    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              SID              |             CIPHER            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              COMP             |             EXTLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              EXT              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. TLS13ServerHello                       
TLS13ServerHello fields

msgtype

ByteEnumField

2

msglen

ThreeBytesField

None

version

_TLSVersionField

771

random_bytes

_TLSRandomBytesField

None

sidlen

FieldLenField

None

sid

_SessionIDField

b''

cipher

ShortEnumField

None

comp

_CompressionMethodsField

[0]

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_build(p, pay)[源代码]
tls_session_update(msg_str)[源代码]

Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states.

class scapy.layers.tls.handshake.TLSCertificate(_pkt, /, *, msgtype=11, msglen=None, certslen=None, certs=[])[源代码]

基类:_TLSHandshake

XXX We do not support RFC 5081, i.e. OpenPGP certificates.

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                    CERTSLEN                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             CERTS             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. TLSCertificate                        
TLSCertificate fields

msgtype

ByteEnumField

11

msglen

ThreeBytesField

None

certslen

_ASN1CertLenField

None

certs

_ASN1CertListField

[]

post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLSCertificateRequest(_pkt, /, *, msgtype=13, msglen=None, ctypeslen=None, ctypes=[1, 64], sig_algs_len=None, sig_algs=[1027, 1025, 513], certauthlen=None, certauth=[])[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |   CTYPESLEN   |             CTYPES            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          SIG ALGS LEN         |            SIG ALGS           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          CERTAUTHLEN          |            CERTAUTH           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLSCertificateRequest                    
TLSCertificateRequest fields

msgtype

ByteEnumField

13

msglen

ThreeBytesField

None

ctypeslen

FieldLenField

None

ctypes

_CertTypesField

[1, 64]

sig_algs_len

SigAndHashAlgsLenField

None

sig_algs

SigAndHashAlgsField

[1027, 1025, 513]

certauthlen

FieldLenField

None

certauth

_CertAuthoritiesField

[]

class scapy.layers.tls.handshake.TLSCertificateStatus(_pkt, /, *, msgtype=22, msglen=None, status_type=1, responselen=None, response=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |  STATUS TYPE  |          RESPONSELEN          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |            RESPONSE           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLSCertificateStatus                     
TLSCertificateStatus fields

msgtype

ByteEnumField

22

msglen

ThreeBytesField

None

status_type

ByteEnumField

1

responselen

ThreeBytesLenField

None

response

_StatusField

None

class scapy.layers.tls.handshake.TLSCertificateURL(_pkt, /, *, msgtype=21, msglen=None, certchaintype=None, uahlen=None, uah=[])[源代码]

基类:_TLSHandshake

Defined in RFC 4366. PkiPath structure of section 8 is not implemented yet.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               | CERTCHAINTYPE |             UAHLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              UAH              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. TLSCertificateURL                      
TLSCertificateURL fields

msgtype

ByteEnumField

21

msglen

ThreeBytesField

None

certchaintype

ByteEnumField

None

uahlen

FieldLenField

None

uah

PacketListField

[]

class scapy.layers.tls.handshake.TLSCertificateVerify(_pkt, /, *, msgtype=15, msglen=None, sig=None)[源代码]

基类:_TLSHandshake

aliastypes
build(*args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |              SIG              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLSCertificateVerify                     
TLSCertificateVerify fields

msgtype

ByteEnumField

15

msglen

ThreeBytesField

None

sig

_TLSSignatureField

None

post_dissection(pkt)[源代码]
class scapy.layers.tls.handshake.TLSClientHello(_pkt, /, *, msgtype=1, msglen=None, version=None, gmt_unix_time=None, random_bytes=None, sidlen=None, sid=b'', cipherslen=None, ciphers=None, complen=None, comp=[0], extlen=None, ext=None)[源代码]

基类:_TLSHandshake

TLS ClientHello, with abilities to handle extensions.

The Random structure follows the RFC 5246: while it is 32-byte long, many implementations use the first 4 bytes as a gmt_unix_time, and then the remaining 28 byts should be completely random. This was designed in order to (sort of) mitigate broken RNGs. If you prefer to show the full 32 random bytes without any GMT time, just comment in/out the lines below.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            VERSION            | GMT UNIX TIME |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                               |  RANDOM BYTES |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |     SIDLEN    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              SID              |           CIPHERSLEN          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            CIPHERS            |    COMPLEN    |      COMP     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             EXTLEN            |      EXT      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                       Fig. TLSClientHello                        
TLSClientHello fields

msgtype

ByteEnumField

1

msglen

ThreeBytesField

None

version

_TLSClientVersionField

None

gmt_unix_time

_GMTUnixTimeField

None

random_bytes

_TLSRandomBytesField

None

sidlen

FieldLenField

None

sid

_SessionIDField

b''

cipherslen

FieldLenField

None

ciphers

_CipherSuitesField

None

complen

FieldLenField

None

comp

_CompressionMethodsField

[0]

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_build(p, pay)[源代码]
tls_session_update(msg_str)[源代码]

Either for parsing or building, we store the client_random along with the raw string representing this handshake message.

class scapy.layers.tls.handshake.TLSClientKeyExchange(_pkt, /, *, msgtype=16, msglen=None, exchkeys=None)[源代码]

基类:_TLSHandshake

This class mostly works like TLSServerKeyExchange and its 'params' field.

aliastypes
build(*args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            EXCHKEYS           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLSClientKeyExchange                     
TLSClientKeyExchange fields

msgtype

ByteEnumField

16

msglen

ThreeBytesField

None

exchkeys

_TLSCKExchKeysField

None

tls_session_update(msg_str)[源代码]

Finalize the EXTMS messages and compute the hash

class scapy.layers.tls.handshake.TLSEncryptedExtensions(_pkt, /, *, msgtype=8, msglen=None, extlen=None, ext=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             EXTLEN            |      EXT      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                   Fig. TLSEncryptedExtensions                    
TLSEncryptedExtensions fields

msgtype

ByteEnumField

8

msglen

ThreeBytesField

None

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_build_tls_session_update(msg_str)[源代码]
post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLSFinished(_pkt, /, *, msgtype=20, msglen=None, vdata=None)[源代码]

基类:_TLSHandshake

aliastypes
build(*args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             VDATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. TLSFinished                         
TLSFinished fields

msgtype

ByteEnumField

20

msglen

ThreeBytesField

None

vdata

_VerifyDataField

None

post_build_tls_session_update(msg_str)[源代码]
post_dissection(pkt)[源代码]
post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLSHelloRequest(_pkt, /, *, msgtype=0, msglen=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                       Fig. TLSHelloRequest                       
TLSHelloRequest fields

msgtype

ByteEnumField

0

msglen

ThreeBytesField

None

tls_session_update(msg_str)[源代码]

Message should not be added to the list of handshake messages that will be hashed in the finished and certificate verify messages.

class scapy.layers.tls.handshake.TLSHelloVerifyRequest(_pkt, /, *, msgtype=21, msglen=None, cookielen=None, cookie=b'')[源代码]

基类:_TLSHandshake

Defined for DTLS, see RFC 6347.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |   COOKIELEN   |             COOKIE            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. TLSHelloVerifyRequest                    
TLSHelloVerifyRequest fields

msgtype

ByteEnumField

21

msglen

ThreeBytesField

None

cookielen

FieldLenField

None

cookie

StrLenField

b''

class scapy.layers.tls.handshake.TLSNewSessionTicket(_pkt, /, *, msgtype=4, msglen=None, lifetime=4294967295, ticketlen=None, ticket=b'')[源代码]

基类:_TLSHandshake

XXX When knowing the right secret, we should be able to read the ticket.

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                    LIFETIME                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |           TICKETLEN           |     TICKET    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                     Fig. TLSNewSessionTicket                     
TLSNewSessionTicket fields

msgtype

ByteEnumField

4

msglen

ThreeBytesField

None

lifetime

IntField

4294967295

ticketlen

FieldLenField

None

ticket

StrLenField

b''

post_dissection_tls_session_update(msg_str)[源代码]
class scapy.layers.tls.handshake.TLSServerHello(_pkt, /, *, msgtype=2, msglen=None, version=None, gmt_unix_time=None, random_bytes=None, sidlen=None, sid=b'', cipher=None, comp=[0], extlen=None, ext=None)[源代码]

基类:_TLSHandshake

TLS ServerHello, with abilities to handle extensions.

The Random structure follows the RFC 5246: while it is 32-byte long, many implementations use the first 4 bytes as a gmt_unix_time, and then the remaining 28 byts should be completely random. This was designed in order to (sort of) mitigate broken RNGs. If you prefer to show the full 32 random bytes without any GMT time, just comment in/out the lines below.

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |            VERSION            | GMT UNIX TIME |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                               |  RANDOM BYTES |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |     SIDLEN    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              SID              |             CIPHER            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              COMP             |             EXTLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              EXT              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. TLSServerHello                        
TLSServerHello fields

msgtype

ByteEnumField

2

msglen

ThreeBytesField

None

version

_TLSVersionField

None

gmt_unix_time

_GMTUnixTimeField

None

random_bytes

_TLSRandomBytesField

None

sidlen

FieldLenField

None

sid

_SessionIDField

b''

cipher

ShortEnumField

None

comp

_CompressionMethodsField

[0]

extlen

_ExtensionsLenField

None

ext

_ExtensionsField

None

post_build(p, pay)[源代码]
tls_session_update(msg_str)[源代码]

Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate the pending write and read connection states. Usually they get updated later on in the negotiation when we learn the session keys, and eventually they are committed once a ChangeCipherSpec has been sent/received.

class scapy.layers.tls.handshake.TLSServerHelloDone(_pkt, /, *, msgtype=14, msglen=None)[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                     Fig. TLSServerHelloDone                      
TLSServerHelloDone fields

msgtype

ByteEnumField

14

msglen

ThreeBytesField

None

class scapy.layers.tls.handshake.TLSServerKeyExchange(_pkt, /, *, msgtype=12, msglen=None, params=None, sig=None)[源代码]

基类:_TLSHandshake

aliastypes
build(*args, **kargs)[源代码]

We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet.

The 'params' field is built according to key_exchange.server_kx_msg_cls which should have been set after receiving a cipher suite in a previous ServerHello. Usual cases are:

  • None: for RSA encryption or fixed FF/ECDH. This should never happen, as no ServerKeyExchange should be generated in the first place.

  • ServerDHParams: for ephemeral FFDH. In that case, the parameter to server_kx_msg_cls does not matter.

  • ServerECDH*Params: for ephemeral ECDH. There are actually three classes, which are dispatched by _tls_server_ecdh_cls_guess on the first byte retrieved. The default here is b"03", which corresponds to ServerECDHNamedCurveParams (implicit curves).

When the Server*DHParams are built via .fill_missing(), the session server_kx_privkey will be updated accordingly.

fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             PARAMS            |      SIG      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                    Fig. TLSServerKeyExchange                     
TLSServerKeyExchange fields

msgtype

ByteEnumField

12

msglen

ThreeBytesField

None

params

_TLSServerParamsField

None

sig

_TLSSignatureField

None

post_dissection(pkt)[源代码]

While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated.

XXX Add a 'fixed_dh' OR condition to the 'anonymous' test.

class scapy.layers.tls.handshake.TLSSupplementalData(_pkt, /, *, msgtype=23, msglen=None, sdatalen=None, sdata=[])[源代码]

基类:_TLSHandshake

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    MSGTYPE    |                     MSGLEN                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                    SDATALEN                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |             SDATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. TLSSupplementalData                     
TLSSupplementalData fields

msgtype

ByteEnumField

23

msglen

ThreeBytesField

None

sdatalen

ThreeBytesLenField

None

sdata

PacketListField

[]

class scapy.layers.tls.handshake.ThreeBytesLenField(name, default, length_of=None, adjust=<function ThreeBytesLenField.<lambda>>)[源代码]

基类:FieldLenField

addfield(pkt, s, val)[源代码]
getfield(pkt, s)[源代码]
i2repr(pkt, x)[源代码]
class scapy.layers.tls.handshake.URLAndOptionalHash(_pkt, /, *, urllen=None, url=b'', hash_present=None, hash=b'')[源代码]

基类:Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             URLLEN            |              URL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  HASH PRESENT |              HASH             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. URLAndOptionalHash                      
URLAndOptionalHash fields

urllen

FieldLenField

None

url

StrLenField

b''

hash_present

FieldLenField

None

hash

StrLenField

b''

guess_payload_class(p)[源代码]
class scapy.layers.tls.handshake.UserMappingData(_pkt, /, *, version=None, len=None, data=b'')[源代码]

基类:Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    VERSION    |              LEN              |      DATA     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                       Fig. UserMappingData                       
UserMappingData fields

version

ByteField

None

len

FieldLenField

None

data

StrLenField

b''

guess_payload_class(p)[源代码]