Skip to main content

Simulate a TLS client and scan a TLS server

Project description

Build Status Coverage License Black

tlsmate

Overview

This project provides a python framework for simulating TLS endpoints. It provides a comfortable way of creating arbitrary TLS handshake scenarios and executes the scenarios against TLS servers or clients (well, at the current state of the project only client simulations are supported).

A plugin is provided which scans a TLS server for its configurations (i.e., support of TLS protocol versions, cipher suites, and much more) as well as for some commonly known TLS vulnerabilities.

A word of warning

This package is intended for test purposes only. Never ever use it to transmit sensitive data! Here are some reasons:

  • secret keying material isn’t appropriately protected, e.g., it is not deleted when not used anymore. Such sensitive data are even logged for debugging purpose.

  • quite a lot of checks are missing which are essential for productive use cases.

  • random values are not always random

  • Side channels? Definitely. Constant time implementation? No.

  • Extensive tests and proven in practice? No!

  • etc.

Features

tlsmate comes with its own TLS protocol stack implementation. For a list of supported TLS protocol elements refer to TLS features .

The following basic features are supported:

  • TLS versions: SSLv2 (rudimentary only), SSLv3, TLS1.0, TLS1.1, TLS1.2, TLS1.3

  • arbitrary L4-ports are supported

  • customized trust store for root certificates

  • client authentication

  • certificate revocation check by CRL and via OCSP

  • scan result is provided as JSON/Yaml format to simplify tool-based post-processing

  • plugin concept for either proprietary test cases or for extending the scanner plugin

  • writing keying material to a key logging file to allow wireshark to decode encrypted packets

  • configuration of tlsmate through an ini-file or through environment variables

  • slowing down a scan to circumvent rate limitings

  • several logging levels

  • HTTP-proxy support

  • Docker image provided

For creating customized handshake scenarios the following features are provided:

  • TLS messages can be sent/received in any arbitrary order

  • all TLS message parameters can be set to any arbitrary value

  • sending and receiving application data

  • predefined client profiles (legacy, interoperability, modern, TLS1.3-only)

  • basic settings (version, ciphersuites, etc.) can be taken from the server profile to minimize interoperability issues with the server

  • different levels for defining a handshake: from a one liner for the complete handshake to defining the deepest bit in a message

  • various conditions when waiting for a message (timeout, optional message)

  • background handling of some messages (e.g., NewSessionTicket)

  • simple python API to use tlsmate from other python applications

The following features are currently not yet supported but will likely be added in the future:

  • simulating a TLS server (thus allowing to test TLS clients)

Installation

This package requires Python3.6 or higher. The recommended way installing tlsmate is using pip:

$ pip install tlsmate

In case this does not work, check if the problem is caused by the cryptographic library cryptography, and refer to Installation of cryptography.

Minimal configuration

By default tlsmate comes with an empty trust store, and thus all certificate chain validations will fail.

There are two different ways recommended to configure the trust store.

Using the system’s set of root certificates

In case the root CA certificates are installed on the system, their location depend on the OS. If openssl is installed on the system, use the following command:

$ openssl version -d

This will print the openssl directory, e.g. /usr/lib/ssl. The certificates are located in the subdirectory certs, and there typically a file is provided which contains all certificates concatenated. On Ubuntu, this file is named ca-certificates.crt, on CentOS the name is ca-bundle.crt.

This file needs to be configured in the tlsmate-ini file, see below.

Download the Mozilla root CA certificates

As an alternative the root CA certificates used by Mozilla can be used. Download the file and calculate its SHA256 checksum:

$ curl -s -o cacert.pem https://curl.se/ca/cacert.pem && sha256sum cacert.pem

Compare the SHA256 hash value with the value provided at https://curl.se/ca/cacert.pem.sha256.

If the value matches, configure the downloaded file in the tlsmate-ini file, see below.

Configuring the trust store in the .tlsmate.ini file

Let’s assume the name of the trust store file is /usr/lib/ssl/certs/ca-certificates.crt. Now create a new ini file in your home directory:

$ echo -e "[tlsmate]\nca_certs = /usr/lib/ssl/certs/ca-certificates.crt" > ~/.tlsmate.ini
$ cat ~/.tlsmate.ini
[tlsmate]
ca_certs = /usr/lib/ssl/certs/ca-certificates.crt

More information on the use of ini-files is provided here.

Basic usage

For a full documentation of the tlsmate command refer to the documentation here. There you will find a detailed description how to use the package directly from other python applications.

In the following only some basic examples for using the CLI are given. Use the tlsmate --help command to get all supported subcommands.

$ tlsmate scan --progress mytlsmatedomain.net

This command will perform a TLS scan against the domain mytlsmatedomain.net, and the result will be displayed as colored console output. For an example refer to the output of the scan command.

If you want to use the provided Docker container instead, use the following command:

$ docker run -it guballa/tlsmate tlsmate scan --progress mytlsmatedomain.net

Using the tlsmate library from other python applications is described in the Python API documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tlsmate-1.2.0rc4.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

tlsmate-1.2.0rc4-py3-none-any.whl (183.9 kB view details)

Uploaded Python 3

File details

Details for the file tlsmate-1.2.0rc4.tar.gz.

File metadata

  • Download URL: tlsmate-1.2.0rc4.tar.gz
  • Upload date:
  • Size: 4.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tlsmate-1.2.0rc4.tar.gz
Algorithm Hash digest
SHA256 7f378bc8ba2ab65f73aaa867bd945f0465d56978338290357656fcec1ebb2637
MD5 a98ccec1d2dee6f7802eaeea37568e94
BLAKE2b-256 88d01d7c24ea11b7561152999df10273df83767a2919b2d69d3503cce6c5f268

See more details on using hashes here.

File details

Details for the file tlsmate-1.2.0rc4-py3-none-any.whl.

File metadata

  • Download URL: tlsmate-1.2.0rc4-py3-none-any.whl
  • Upload date:
  • Size: 183.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tlsmate-1.2.0rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 7436d249467a8d9e6a9031711dd2a50cbf123f0d545fdd513bac1ee2016e4e6a
MD5 0249302855e4cc30f927d91745d70a68
BLAKE2b-256 09dfa9b2ef54871cfeff868ca8aa90a3209ec32cedbf18ca74d51421b8a8bb00

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page