Exemplo n.º 1
0
    get_local_ip,
    get_random_high_port,
)

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

DTLS_VERSIONS = {
    # DTLS
    0xFEFF: "DTLS_1_0",
    0xFEFD: "DTLS_1_1",
}

ENUM_DTLS_VERSIONS = EnumStruct(DTLS_VERSIONS)
DTLS_COMPRESSION_METHODS = registry.TLS_COMPRESSION_METHOD_IDENTIFIERS
DTLS_CIPHER_SUITES = TLS_CIPHER_SUITES


class DTLSHandshakes(TLSDecryptablePacket):
    """ Representation of DTLS Handshake """

    name = "DTLS Handshakes"
    fields_desc = [PacketListFieldContext("handshakes", None, DTLSHandshake)]


class DTLS(Packet):
    """Representation of DTLS message"""

    name = "DTLS"
Exemplo n.º 2
0
from .common_utils import print_verbose, Protocol, show_verbose
from .cotopaxi_tester import CotopaxiTester
from .dtls_utils import (
    ENUM_DTLS_VERSIONS,
    DTLS,
    DTLSClient,
    DTLSServerHello,
    DTLS_VERSIONS,
    DTLS_CIPHER_SUITES,
    DTLSHandshakes,
    DTLS_COMPRESSION_METHODS,
)
from .service_ping import service_ping

TLS_HANDSHAKE_TYPES.update({0x3: "hello_verify_request"})
ENUM_DTLS_HANDSHAKE_TYPES = EnumStruct(TLS_HANDSHAKE_TYPES)

# bind records
bind_layers(DTLSRecord, TLSChangeCipherSpec,
            {"content_type": TLSContentType.CHANGE_CIPHER_SPEC})
bind_layers(DTLSRecord, TLSCiphertext,
            {"content_type": TLSContentType.APPLICATION_DATA})
bind_layers(DTLSRecord, TLSHeartBeat,
            {"content_type": TLSContentType.HEARTBEAT})
bind_layers(DTLSRecord, TLSAlert, {"content_type": TLSContentType.ALERT})
bind_layers(DTLSRecord, DTLSHandshake,
            {"content_type": TLSContentType.HANDSHAKE})

# bind handshakes
bind_layers(DTLSHandshake, DTLSClientHello,
            {"type": TLSHandshakeType.CLIENT_HELLO})