-
Notifications
You must be signed in to change notification settings - Fork 292
/
ctfr.py
78 lines (57 loc) · 1.79 KB
/
ctfr.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
CTFR - 04.03.18.02.10.00 - Sheila A. Berta (UnaPibaGeek)
------------------------------------------------------------------------------
"""
## # LIBRARIES # ##
import re
import requests
## # 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 banner():
global version
b = '''
____ _____ _____ ____
/ ___|_ _| ___| _ \
| | | | | |_ | |_) |
| |___ | | | _| | _ <
\____| |_| |_| |_| \_\\
Version {v} - Hey don't miss AXFR!
Made by Sheila A. Berta (UnaPibaGeek)
'''.format(v=version)
print(b)
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():
banner()
args = parse_args()
subdomains = []
target = clear_url(args.domain)
output = args.output
req = requests.get("https://crt.sh/?q=%.{d}&output=json".format(d=target))
if req.status_code != 200:
print("[X] Information not available!")
exit(1)
for (key,value) in enumerate(req.json()):
subdomains.append(value['name_value'])
print("\n[!] ---- TARGET: {d} ---- [!] \n".format(d=target))
subdomains = sorted(set(subdomains))
for subdomain in subdomains:
print("[-] {s}".format(s=subdomain))
if output is not None:
save_subdomains(subdomain,output)
print("\n\n[!] Done. Have a nice day! ;).")
main()