-
Notifications
You must be signed in to change notification settings - Fork 9
/
ctfr_script.py
48 lines (41 loc) · 1.34 KB
/
ctfr_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
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
CTFR - 04.03.18.02.10.00 - Sheila A. Berta (UnaPibaGeek)
------------------------------------------------------------------------------
"""
## # LIBRARIES # ##
import re
import json
import requests
import datetime
## # CONTEXT VARIABLES # ##
version = 1.2
## # MAIN FUNCTIONS # ##
def parse_args():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--domain', type=str, required=True, help="Target domain.")
parser.add_argument('-o', '--output', type=str, help="Output file.")
return parser.parse_args()
def clear_url(target):
return re.sub('.*www\.','',target,1).split('/')[0].strip()
def save_subdomains(subdomain,output_file):
with open(output_file,"a+") as f:
f.write(subdomain + '\n')
f.close()
def main(domain):
subdomains = []
target = domain
try:
req = requests.get("https://crt.sh/?q=%.{d}&output=json".format(d=target), timeout=30)
if req.status_code != 200:
print('')
except:
print('Request didnt dive n answer!')
json_data = json.loads('{}'.format(req.text.replace('}{', '},{')))
for (key,value) in enumerate(json_data):
subdomains.append(value['name_value'])
subdomains = sorted(set(subdomains))
return subdomains