Skip to main content

Python tool to monitor and analyze TLS certificates as they are issued via certstream.

Project description

certleak logo created by https://t.me/AboutTheDot

certleak - Cert-Monitoring Python Framework

Run tests and lint PyPI version Coverage Status

Certleak is a tool to monitor and analyze TLS certificates as they are issued. It is heavily inspired by Phishing Catcher by x0rz.

It utilizes the Certificate Transparency Network, which is an ecosystem for publicly monitoring issuance of TLS certificates.

A regular use case of this tool is to find phishing domains before they are actively used in the wild.

Instead of querying the single transparency log servers individually, certleak uses certstream for analyzing certificates in real time. To do that, it uses about 2600-3000 kbit/s of bandwidth. Since certleak uses certstream, it only enables you to analyze live data. There is no way to use this tool to analyze certificates that have been issued in the past or while being offline.

Extensibility

Creating new analyzers or actions is as easy as creating a new python file. Certleak is built with extensibility in mind. Check the analyzer docs as well as the actions docs.

Installation

Simply use pip to install this tool.

pip install certleak

Usage

After downloading and installing the package, you only need to create a small python script in which you import certleak and set up the analyzers and the belonging actions. Below you'll find an example configuration. Keep in mind that it's fully up to you what analyzers you want to add and which actions you want to be executed.

In general the workflow is as follows: New Certificate -> Analyzer matches -> Actions are executed

import logging
from pathlib import Path

from certleak import CertLeak
from certleak.actions import LogAction, DatabaseAction
from certleak.analyzers import (FullDomainAnalyzer, TLDAnalyzer, WildcardCertAnalyzer, X509Analyzer, LetsEncryptAnalyzer,
                                RegexDomainAnalyzer, DNStwistAnalyzer)
from certleak.database import SQLiteDB

certleak = CertLeak()

# Set up database
path = Path.cwd().absolute() / "phish.db"
db = SQLiteDB(str(path))

# Set up actions
db_action = DatabaseAction(db)
logaction = LogAction(level=logging.INFO, template="${analyzer_name} found: ${leaf_cert.subject.CN} () - ${leaf_cert.all_domains}")

# Set up analyzers
xyz_tld_analyzer = TLDAnalyzer(logaction, ["xyz"], blacklist="acmetestbykeychestdotnet") & X509Analyzer()
phishing_analyzer = FullDomainAnalyzer([db_action, logaction], ["paypal", "amazon"])
regex_analyzer = RegexDomainAnalyzer([db_action, logaction], r"([^.]*-)?pay[-_]?pa[l1i][-.].*")

wildcard_analyzer = WildcardCertAnalyzer([db_action, logaction]) & X509Analyzer()
letsencrypt_analyzer = LetsEncryptAnalyzer(db_action) & X509Analyzer()

# Set up DNStwist Analyzer - generates a list of potential phishing domains at start. Based on the DNStwist module.
dns = DNStwistAnalyzer(logaction, "paypal.com") & X509Analyzer()

certleak.add_analyzer(dns)
certleak.add_analyzer(xyz_tld_analyzer)
certleak.add_analyzer(phishing_analyzer)
certleak.add_analyzer(regex_analyzer)
certleak.add_analyzer(wildcard_analyzer)
certleak.add_analyzer(letsencrypt_analyzer)

certleak.start()

You can find full example files in this repo as well.

License

This tool is released under the MIT license.

If you found this tool helpful and want to support me, drop me a coffee at the link below.

Buy me a coffee

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

certleak-0.1.1.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

certleak-0.1.1-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file certleak-0.1.1.tar.gz.

File metadata

  • Download URL: certleak-0.1.1.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for certleak-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d24ba1b6521f2cc2b64439fd78194b31580be17fcf3bc72660f9bd9aedfe06ac
MD5 fe8641a64be1d75a1acd35be34c8f4fd
BLAKE2b-256 3b95c83ea9374fde23c9ee35e5cae0606aa3d752570f8405225bf590fe524087

See more details on using hashes here.

File details

Details for the file certleak-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: certleak-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 56.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for certleak-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5139b80abc5269a2079608f2272137f27fd62e062e3009ff94f09d1816d75631
MD5 e91ea4ff73600e0540bfce0ef91fbb53
BLAKE2b-256 a6325eda5f37c67bd81c5e8e5da8d190b52e5e2bbdc9c886e0117b6b8aa76f81

See more details on using hashes here.

Supported by

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