-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathosint-certstream.py
52 lines (37 loc) · 1.5 KB
/
osint-certstream.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# Original code for this was taken from https://github.com/CaliDog/certstream-python
# To run this requires you to do "pip3 install certstream" firsts
import logging
import sys
import datetime
import certstream
import argparse
keywords = []
logging.basicConfig(
format='[%(levelname)s:%(name)s] %(asctime)s - %(message)s', level=logging.INFO)
def load_keywords(filename):
keywords_file = open(filename, 'r').readlines()
for keyword in keywords_file:
keywords.append(keyword.strip('\n'))
def certstream_callback(message, context):
logging.debug("Message -> {}".format(message))
if message['message_type'] == "heartbeat":
return
if message['message_type'] == "certificate_update":
domains = message['data']['leaf_cert']['all_domains']
domain = domains[0]
if [k for k in keywords if k in ' '.join(domains)]:
sys.stdout.write(u"[{}] {} {} \n".format(datetime.datetime.now().strftime(
'%m/%d/%y %H:%M:%S'), domain, ','.join(domains)))
sys.stdout.flush()
def main(filename):
load_keywords(filename)
print('[+] Found {0} keywords to use..'.format(len(keywords)))
print('[+] Searching Certstream for {0}..'.format(','.join(keywords)))
certstream.listen_for_events(
certstream_callback, url='wss://certstream.calidog.io/')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("filename")
args = parser.parse_args()
main(args.filename)