-
Notifications
You must be signed in to change notification settings - Fork 7
/
subdomains
93 lines (80 loc) · 2.49 KB
/
subdomains
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Usage:
# subdomains domain.com
# echo domain.com | subdomains
import sys, requests, json, urllib3, select
from urllib.parse import urlparse
from rich.console import Console
from rich.table import Table
from rich.progress import track
C99_KEY = ""
def ambilSubdo(domain):
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
}
try:
x = requests.get("https://api.c99.nl/subdomainfinder?key=" + C99_KEY + " &domain=" + domain + "&json", headers=headers, verify=False, timeout=30).text
except requests.exceptions.RequestException as e:
raise SystemExit(e)
output = json.loads(x)
if output['success']:
table = Table()
table.add_column("#", justify="center")
table.add_column("Subdomains")
table.add_column("IP")
for each in track(output['subdomains'], description="Processing..."):
cek_sc = checkProtocol(each['subdomain'])
if cek_sc != None:
sc = str(cek_sc['sc'])
if sc[0] == "2":
sc = f"[bright_green]{sc}"
elif sc[0] == "3":
sc = f"[cyan]{sc}"
elif sc[0] == "4":
sc = f"[yellow]{sc}"
else:
sc = f"[red1]{sc}"
if each['cloudflare']:
cf = " ([bright_green]CF[white])"
else:
cf = ""
table.add_row(sc, cek_sc['domain'], each['ip'] + cf)
else:
table.add_row("-", each['subdomain'], "-")
print("\n▶ Result")
console = Console()
console.print(table)
else:
sys.exit("Something wrong! Check your input.")
def checkProtocol(site):
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
}
try:
r = requests.get("http://" + site, headers=headers, verify=False, timeout=5)
if site in r.url:
sc_cek = {}
sc_cek['sc'] = r.status_code
parsed_url = urlparse(r.url)
sc_cek['domain'] = parsed_url.scheme + "://" + parsed_url.netloc
return sc_cek
except Exception as e:
pass
def main():
if len(sys.argv) > 1:
print("▶ Starting")
ambilSubdo(sys.argv[1])
else:
if select.select([sys.stdin, ], [], [], 0.0)[0]:
print("▶ Starting")
domain = sys.stdin.readline().replace('\n', '')
ambilSubdo(domain)
else:
sys.exit('Usage:\n./subdomains domain.com\nOR\necho domain.com | subdomains')
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.exit("▶ CTRL + C Detected!")