Skip to main content

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

Metadata

Release files for certleak 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for certleak 0.1.1
File Size Uploaded
certleak-0.1.1.tar.gz 80.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for certleak 0.1.1
File Interpreter ABI Platform
certleak-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 136.9 kB

Release files / certleak-0.1.1.tar.gz

Download URL certleak-0.1.1.tar.gz
Size 80.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d24ba1b6521f2cc2b64439fd78194b31580be17fcf3bc72660f9bd9aedfe06ac
BLAKE2b-256 checksum
How to use checksums
3b95c83ea9374fde23c9ee35e5cae0606aa3d752570f8405225bf590fe524087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / certleak-0.1.1-py3-none-any.whl

Download URL certleak-0.1.1-py3-none-any.whl
Size 56.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5139b80abc5269a2079608f2272137f27fd62e062e3009ff94f09d1816d75631
BLAKE2b-256 checksum
How to use checksums
a6325eda5f37c67bd81c5e8e5da8d190b52e5e2bbdc9c886e0117b6b8aa76f81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page