PEP8 Refactor
This commit is contained in:
parent
e27f6ead26
commit
95c176f669
@ -9,7 +9,7 @@ from time import sleep
|
||||
from csv import DictWriter
|
||||
|
||||
try:
|
||||
from OpenSSL import SSL, crypto
|
||||
from OpenSSL import SSL
|
||||
except ImportError:
|
||||
print('Required module does not exist. Install: pip install pyopenssl')
|
||||
sys.exit(1)
|
||||
@ -87,12 +87,12 @@ def analyze_ssl(host, context):
|
||||
|
||||
return context
|
||||
|
||||
def get_cert_sans(x509cert):
|
||||
'''
|
||||
Get Subject Alt Names from Certificate. Shameless taken from stack overflow:
|
||||
https://stackoverflow.com/users/4547691/anatolii-chmykhalo
|
||||
'''
|
||||
|
||||
def get_cert_sans(x509cert):
|
||||
"""
|
||||
Get Subject Alt Names from Certificate. Shameless taken from stack overflow:
|
||||
https://stackoverflow.com/users/4547691/anatolii-chmykhalo
|
||||
"""
|
||||
san = ''
|
||||
ext_count = x509cert.get_extension_count()
|
||||
for i in range(0, ext_count):
|
||||
@ -103,6 +103,7 @@ def get_cert_sans(x509cert):
|
||||
san = san.replace(',', ';')
|
||||
return san
|
||||
|
||||
|
||||
def get_cert_info(host, cert):
|
||||
"""Get all the information about cert and create a JSON file."""
|
||||
context = {}
|
||||
@ -165,8 +166,8 @@ def print_status(host, context, analyze=False):
|
||||
|
||||
print('\t\tExpired: {}'.format(context[host]['cert_exp']))
|
||||
print('\t\tCertificate SANs: ')
|
||||
for san in context[host]['cert_sans'].split(';'): print('\t\t\t{}'.format(san))
|
||||
|
||||
for san in context[host]['cert_sans'].split(';'):
|
||||
print('\t\t\t{}'.format(san))
|
||||
|
||||
|
||||
def show_result(user_args):
|
||||
@ -221,8 +222,9 @@ def show_result(user_args):
|
||||
else:
|
||||
print(context)
|
||||
|
||||
|
||||
def export_csv(context, filename):
|
||||
""" Export all context results to CSV file."""
|
||||
"""Export all context results to CSV file."""
|
||||
# prepend dict keys to write column headers
|
||||
with open(filename, 'w') as csv_file:
|
||||
csv_writer = DictWriter(csv_file, context.items()[0][1].keys())
|
||||
@ -230,6 +232,7 @@ def export_csv(context, filename):
|
||||
for host in context.keys():
|
||||
csv_writer.writerow(context[host])
|
||||
|
||||
|
||||
def filter_hostname(host):
|
||||
"""Remove unused characters and split by address and port."""
|
||||
host = host.replace('http://', '').replace('https://', '').replace('/', '')
|
||||
@ -246,11 +249,10 @@ def get_args():
|
||||
description="""Collects useful information about given host's SSL certificates.""")
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
|
||||
group.add_argument('-H', '--host', dest='hosts', nargs='*', required=False,
|
||||
help='Hosts as input separated by space')
|
||||
group.add_argument('-f', '--host-file', dest='host_file', required=False,
|
||||
help='Hosts as input from file')
|
||||
group.add_argument('-H', '--host', dest='hosts', nargs='*',
|
||||
required=False, help='Hosts as input separated by space')
|
||||
group.add_argument('-f', '--host-file', dest='host_file',
|
||||
required=False, help='Hosts as input from file')
|
||||
parser.add_argument('-s', '--socks', dest='socks',
|
||||
default=False, metavar='HOST:PORT',
|
||||
help='Enable SOCKS proxy for connection')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user