Skip to content

Instantly share code, notes, and snippets.

@pixitha
Last active March 18, 2024 17:06
Show Gist options
  • Save pixitha/207e578aa951b3dfda4fdbda4e0a8828 to your computer and use it in GitHub Desktop.
Save pixitha/207e578aa951b3dfda4fdbda4e0a8828 to your computer and use it in GitHub Desktop.
Get list of CT logs, then ask how many total certs they have.
import requests
import json
import locale
def set_locale():
locales_to_try = ['en_US.UTF-8', 'en_US.utf8', 'English_United States.1252']
for loc in locales_to_try:
try:
locale.setlocale(locale.LC_ALL, loc)
return True
except locale.Error:
continue
return False
locale_set = set_locale()
ctl_log = requests.get('https://www.gstatic.com/ct/log_list/v3/log_list.json').json()
total_certs = 0
def human_format(number):
if locale_set:
return locale.format_string('%d', number, grouping=True)
else:
# Locale not set, fallback to manual formatting
return "{:,}".format(number)
#human_format = lambda x: locale.format_string('%d', x, grouping=True)
# Accessing 'logs' key under 'operators'
for operator in ctl_log['operators']:
for log in operator['logs']:
log_url = log['url']
# Remove extra 'https://' prefix
log_url = log_url.replace('https://', '')
state = log.get('state', {}).get('usable', False)
if state:
try:
# Remove the extra slash from the URL
if log_url.endswith('/'):
log_url = log_url[:-1]
log_info = requests.get('https://{}/ct/v1/get-sth'.format(log_url), timeout=3)
log_info.raise_for_status() # Raise an error for bad status codes
log_info_json = log_info.json()
total_certs += int(log_info_json['tree_size'])
print("{} has {} certificates".format(log_url, human_format(log_info_json['tree_size'])))
except requests.exceptions.RequestException as e:
print("Error fetching data from {}: {}".format(log_url, e))
if hasattr(e, 'response') and e.response:
print("Response content: {}".format(e.response.text)) # Print response content
except (json.decoder.JSONDecodeError, KeyError) as e:
print("Error processing data from {}: {}".format(log_url, e))
else:
print("Skipping {} as it is not in a usable state.".format(log_url))
print("Total certs -> {}".format(human_format(total_certs)))
@pixitha
Copy link
Author

pixitha commented Mar 3, 2024

python3 list2_ct.py
                                     
ct.googleapis.com/logs/us1/argon2024 has 1,104,818,063 certificates
ct.googleapis.com/logs/us1/argon2025h1 has 50,453,804 certificates
ct.googleapis.com/logs/us1/argon2025h2 has 87,737 certificates
ct.googleapis.com/logs/eu1/xenon2024 has 1,231,206,046 certificates
ct.googleapis.com/logs/eu1/xenon2025h1 has 39,953,362 certificates
ct.googleapis.com/logs/eu1/xenon2025h2 has 87,553 certificates
ct.cloudflare.com/logs/nimbus2024 has 490,364,786 certificates
ct.cloudflare.com/logs/nimbus2025 has 13,150,925 certificates
yeti2024.ct.digicert.com/log has 651,108,976 certificates
yeti2025.ct.digicert.com/log has 42,052,711 certificates
Skipping nessie2024.ct.digicert.com/log/ as it is not in a usable state.
nessie2025.ct.digicert.com/log has 23,927,499 certificates
sabre.ct.comodo.com has 480,535,688 certificates
sabre2024h1.ct.sectigo.com has 128,580,534 certificates
sabre2024h2.ct.sectigo.com has 192,431 certificates
sabre2025h1.ct.sectigo.com has 461,491 certificates
sabre2025h2.ct.sectigo.com has 87,275 certificates
Skipping mammoth.ct.comodo.com/ as it is not in a usable state.
Skipping mammoth2024h1.ct.sectigo.com/ as it is not in a usable state.
Skipping mammoth2024h1b.ct.sectigo.com/ as it is not in a usable state.
mammoth2024h2.ct.sectigo.com has 191,295 certificates
mammoth2025h1.ct.sectigo.com has 471,046 certificates
mammoth2025h2.ct.sectigo.com has 87,268 certificates
oak.ct.letsencrypt.org/2024h1 has 594,061,811 certificates
oak.ct.letsencrypt.org/2024h2 has 80,125,796 certificates
oak.ct.letsencrypt.org/2025h1 has 26,371,345 certificates
oak.ct.letsencrypt.org/2025h2 has 142,585 certificates
ct2024.trustasia.com/log2024 has 23,782,307 certificates
ct2025-a.trustasia.com/log2025a has 448,933 certificates
ct2025-b.trustasia.com/log2025b has 403,157 certificates
Total certs -> 4,983,154,424

@pixitha
Copy link
Author

pixitha commented Mar 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment