Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a python program to obtain a collection of TLS certificates. You dont need to save every field of the certificate, but you should
Create a python program to obtain a collection of TLS certificates. You dont need to save every field of the certificate, but you should consider which fields might be useful for foren- sics/analytics later on. There is no required number of certificates, but you will need a large collection for the higher level machine learning tasks. Submit a document containing the following. 1. Your code and a screenshot of it running. 2. A description of what part of the certificates you have saved. 3. A print out of all the certs you have collected. You may find the following code helpful in getting started. import ss1 hostname = 'www.google.com port 443 f = open('cert.der', 'wb'). cert = ssl.get_server_certificate ((hostname, port)) f.write(ssl.PEM_cert_to_DER_cert (cert)) f.close() ### or alternatively ### # Import modules import socket import pyshark # Docs: https://github.com/KimiNewt/pyshark/ from pprint import pprint data = pyshark. FileCapture (unipcap.pcap) #Loop through each item (packet) for pkt in data: if TLS in pkt: # Look for attribute of x509 if hasattr(pkt['TLS' ], 'x509sat_utf8string'): print (pkt[TLS]) pprint(dir (pkt['TLS'])) print (pkt['TLS'].x589sat_utf8string) print (NEW CERT)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To obtain a collection of TLS certificates and save relevant information from the certificates you can use the ssl module in Python to establish a con...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started