-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathlistcerts.py
executable file
·31 lines (28 loc) · 1.05 KB
/
listcerts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import argparse
import operator
from pycrtsh import Crtsh
from collections import Counter
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='List certificates for a domain')
parser.add_argument('DOMAIN', help='an integer for the accumulator')
args = parser.parse_args()
crt = Crtsh()
index = crt.search(args.DOMAIN)
domains = []
print("Certificates")
for c in index:
data = crt.get(c["id"], type="id")
print("%s\t%s\t%s\t%s" % (
data["subject"]["commonName"],
data["not_before"].isoformat(),
data["not_after"].isoformat(),
data["sha1"]
)
)
if "alternative_names" in data["extensions"]:
domains += list(set([a[2:] if a.startswith("*.") else a for a in data["extensions"]["alternative_names"]]))
print("\nDomains")
count = Counter(domains)
for d in sorted(count.items(), key=operator.itemgetter(1), reverse=True):
print("-%s: %i occurences" % (d[0], d[1]))