Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import certstream
  2. import base64
  3.  
  4. NEEDLE = "paypal"
  5.  
  6. # Search for domains with a keyword in them and write the corresponding certificate to a file
  7. def certstream_callback(message):
  8. if message['message_type'] == "certificate_update":
  9. all_domains = message['data']['leaf_cert']['all_domains']
  10. if NEEDLE.lower() in " ".join(all_domains).lower():
  11. cn = all_domains[0]
  12. filename = "/tmp/{}".format(cn)
  13.  
  14. print("Found {} in cert for {}. Writing to {}.".format(NEEDLE, cn, filename))
  15.  
  16. with open(filename, 'w') as f:
  17. f.write(base64.b64decode(message['data']['leaf_cert']['as_der']))
  18.  
  19. certstream.listen_for_events(certstream_callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement