-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
60 lines (43 loc) · 1.38 KB
/
script.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
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import requests
import sys
def check_arguments(arguments):
if arguments[1] == '-o':
return arguments[2], True
else:
return arguments[1], False
class Subdomz:
URL = "https://crt.sh/?Identity={}&output=json"
RESULT = []
def __init__(self, url, output_name):
self.url = url
self.output_name = output_name
def fetch(self):
return requests.get(self.URL.format(self.url)).json()
def check_duplicate_values(self, response):
for r in response:
if r['common_name'] not in self.RESULT:
self.RESULT.append(r['common_name'])
return
def print(self):
for r in self.RESULT:
if self.output_name != False:
self.save_file()
print(r)
return
def save_file(self):
with open(f'{self.url}.txt', 'w+') as f:
for r in self.RESULT:
f.write(f'{r}\n')
return
if __name__ == '__main__':
arguments = sys.argv
if len(arguments) <= 1:
print('Normal Usage : script.py <domain_url>')
print('Saving Output : script.py -o <domain_url>')
else:
url, is_output = check_arguments(arguments)
application = Subdomz(url, is_output)
response = application.fetch()
application.check_duplicate_values(response)
application.print()