Created
June 24, 2017 05:24
-
-
Save Fitblip/924777595f21f04cf158f7a34f7ac358 to your computer and use it in GitHub Desktop.
Find a specific keyword (paypal) in any certificates sent by Certstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import certstream | |
import base64 | |
NEEDLE = "paypal" | |
# Search for domains with a keyword in them and write the corresponding certificate to a file | |
def certstream_callback(message): | |
if message['message_type'] == "certificate_update": | |
all_domains = message['data']['leaf_cert']['all_domains'] | |
if NEEDLE.lower() in " ".join(all_domains).lower(): | |
cn = all_domains[0] | |
filename = "/tmp/{}".format(cn) | |
print("Found {} in cert for {}. Writing to {}.".format(NEEDLE, cn, filename)) | |
with open(filename, 'w') as f: | |
f.write(base64.b64decode(message['data']['leaf_cert']['as_der'])) | |
certstream.listen_for_events(certstream_callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment