-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
opensquat.py
executable file
·178 lines (147 loc) · 6.67 KB
/
opensquat.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# opensquat.py
"""
openSquat.
* https://github.com/atenreiro/opensquat
software licensed under GNU version 3
"""
import time
import signal
import functools
import concurrent.futures
from colorama import init, Fore, Style
from opensquat import __VERSION__, vt
from opensquat import arg_parser, output, app, phishing, check_update
from opensquat import port_check
def signal_handler(sig, frame):
"""Function to catch CTR+C and terminate."""
print("\n[*] openSquat is terminating...\n")
exit(0)
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
init()
RED, WHITE, GREEN, END, YELLOW, BOLD = (
"\033[91m",
"\33[97m",
"\033[1;32m",
"\033[0m",
"\33[93m",
"\033[1m",
)
logo = (
Style.BRIGHT + Fore.GREEN +
"""
█████████ █████
███░░░░░███ ░░███
██████ ████████ ██████ ████████ ░███ ░░░ ████████ █████ ████ ██████ ███████
███░░███░░███░░███ ███░░███░░███░░███ ░░█████████ ███░░███ ░░███ ░███ ░░░░░███ ░░░███░
░███ ░███ ░███ ░███░███████ ░███ ░███ ░░░░░░░░███░███ ░███ ░███ ░███ ███████ ░███
░███ ░███ ░███ ░███░███░░░ ░███ ░███ ███ ░███░███ ░███ ░███ ░███ ███░░███ ░███ ███
░░██████ ░███████ ░░██████ ████ █████░░█████████ ░░███████ ░░████████░░████████ ░░█████
░░░░░░ ░███░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░░░░ ░░░░░███ ░░░░░░░░ ░░░░░░░░ ░░░░░
░███ ░███
█████ █████
░░░░░ ░░░░░
(c) Andre Tenreiro - https://github.com/atenreiro/opensquat
""" + Style.RESET_ALL
)
print(logo)
print("\t\t\tversion " + __VERSION__ + "\n")
args = arg_parser.get_args()
start_time_squatting = time.time()
file_content = app.Domain().main(
args.keywords,
args.confidence,
args.domains,
args.period,
args.method,
args.dns,
args.ct
)
if args.subdomains or args.vt or args.subdomains or args.phishing \
or args.portcheck:
print("\n[*] Total found:", len(file_content))
# Check for subdomains
if (args.subdomains):
list_aux = []
print("\n+---------- Checking for Subdomains ----------+")
time.sleep(1)
for domain in file_content:
print("[*]", domain)
subdomains = vt.VirusTotal().main(domain, "subdomains")
if subdomains:
for subdomain in subdomains:
print(
Style.BRIGHT + Fore.YELLOW +
" \\_", subdomain +
Style.RESET_ALL,
)
list_aux.append(subdomain)
file_content = list_aux
print("[*] Total found:", len(file_content))
# Check for VirusTotal (if domain is flagged as malicious)
if (args.vt):
list_aux = []
print("\n+---------- VirusTotal ----------+")
time.sleep(1)
for domain in file_content:
total_votes = vt.VirusTotal().main(domain)
# total votes
harmless = total_votes[0]
malicious = total_votes[1]
if malicious > 0:
print(
Style.BRIGHT + Fore.RED +
"[*] found:", domain, "({})".format(str(malicious)) +
Style.RESET_ALL,
)
list_aux.append(domain)
elif malicious < 0:
print(
Style.BRIGHT + Fore.YELLOW +
"[*] VT is throttling the response:", domain +
Style.RESET_ALL,
)
list_aux.append(domain)
file_content = list_aux
print("[*] Total found:", len(file_content))
# Check for phishing
if (args.phishing != ""):
file_phishing = phishing.Phishing().main(args.keywords)
output.SaveFile().main(args.phishing, "txt", file_phishing)
# Check if domain has webserver port opened
if (args.portcheck):
list_aux = []
print("\n+---------- Domains with open webserver ports ----------+")
time.sleep(1)
with concurrent.futures.ThreadPoolExecutor() as executor:
futs = [ (domain, executor.submit(functools.partial(port_check.PortCheck().main, domain)))
for domain in file_content ]
for tested_domain, result_domain_port_check in futs:
ports = result_domain_port_check.result()
if ports:
list_aux.append(tested_domain)
print(
Fore.YELLOW +
"[*]", tested_domain, ports, "" +
Style.RESET_ALL
)
file_content = list_aux
print("[*] Total found:", len(file_content))
output.SaveFile().main(args.output, args.type, file_content)
end_time_squatting = round(time.time() - start_time_squatting, 2)
# Print summary
print("\n")
print(
Style.BRIGHT+Fore.GREEN +
"+---------- Summary Squatting ----------+" +
Style.RESET_ALL)
print("[*] Domains flagged:", len(file_content))
print("[*] Domains result:", args.output)
if (args.phishing != ""):
print("[*] Phishing results:", args.phishing)
print("[*] Active Phishing sites:", len(file_phishing))
print("[*] Running time: %s seconds" % end_time_squatting)
print("")
check_update.CheckUpdate().main()