56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
import requests
|
|
import sys
|
|
|
|
def get_subdomains_certspotter(domain):
|
|
url = f"https://api.certspotter.com/v1/issuances?domain={domain}&include_subdomains=true&expand=dns_names"
|
|
print(f"[*] Interrogation de Cert Spotter pour {domain}...")
|
|
|
|
try:
|
|
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}
|
|
response = requests.get(url, headers=headers, timeout=15)
|
|
|
|
if response.status_code == 429:
|
|
print("[-] Erreur 429 : Limite de requêtes atteinte. Patiente un peu avant de réessayer.")
|
|
return
|
|
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
|
|
if not data:
|
|
print("[-] Aucun certificat trouvé pour ce domaine.")
|
|
return
|
|
|
|
subdomains = set()
|
|
|
|
for entry in data:
|
|
for name in entry.get('dns_names', []):
|
|
name = name.strip().lower()
|
|
|
|
if not name.startswith('*.') and name.endswith(domain):
|
|
subdomains.add(name)
|
|
|
|
subdomains = sorted(list(subdomains))
|
|
|
|
print(f"[+] {len(subdomains)} sous-domaines uniques trouvés :")
|
|
for sub in subdomains:
|
|
print(f" {sub}")
|
|
|
|
output_file = f"{domain.replace('.', '_')}_certspotter.txt"
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
for sub in subdomains:
|
|
f.write(f"{sub}\n")
|
|
|
|
print(f"[*] Export → {output_file}")
|
|
|
|
except requests.exceptions.Timeout:
|
|
print("[-] Erreur : Délai d'attente dépassé.")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"[-] Erreur réseau :\n {e}")
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print(f"Usage: python {sys.argv[0]} <domaine>")
|
|
sys.exit(1)
|
|
|
|
target_domain = sys.argv[1]
|
|
get_subdomains_certspotter(target_domain) |