2424from .base import Base
2525
2626
27- def clean_domains (domains ):
28- cleaned = []
29- for subdomain in domains :
30- subdomain = subdomain .lower ()
31- if subdomain .find ("//" ) != - 1 :
32- subdomain = subdomain [subdomain .find ("//" ) + 2 :]
33- # Some pkey return instances like example.com. - remove the final .
34- if subdomain .endswith ('.' ):
35- subdomain = subdomain [:- 1 ]
36- # sometimes we'll get something like /www.example.com
37- if subdomain [0 ] in ["\\ " , "." , "/" , "#" , "$" , "%" ]:
38- subdomain = subdomain [1 :]
39- # If it's an email address, only take the domain part
40- if "@" in subdomain :
41- subdomain = subdomain .split ("@" )
42- # If it's an actual email like mail@example.com, take example.com
43- if len (subdomain ) > 1 :
44- subdomain = subdomain [1 ]
45- else :
46- # If for some reason it's example.com@, take example.com
47- subdomain = subdomain [0 ]
48-
49- cleaned .append (subdomain .strip ())
50- return cleaned
51-
52-
5327class Target (Base ):
5428 """Main enumeration module"""
5529 domains = list ()
@@ -95,8 +69,7 @@ def run(self):
9569 for i in range (len (self .options ["TARGET" ])):
9670 # Default scans that run every time
9771 target = self .options ["TARGET" ][i ]
98- processes = [
99- threading .Thread (target = dns_zonetransfer , args = (self , target )),
72+ threads = [threading .Thread (target = dns_zonetransfer , args = (self , target )),
10073 threading .Thread (target = search_subject_alt_name , args = (self , target )),
10174 threading .Thread (target = subdomain_hackertarget , args = (self , target )),
10275 threading .Thread (target = search_virustotal , args = (self , target )),
@@ -108,37 +81,37 @@ def run(self):
10881 print ('test' )
10982 # Additional options - ssl cert scan
11083 if self .options ["--ssl" ]:
111- processes .append (threading .Thread (target = ssl_scan , args = (self , target )))
84+ threads .append (threading .Thread (target = ssl_scan , args = (self , target )))
11285
11386 # Additional options - shodan.io scan
11487 if self .options ["--additional-info" ]:
115- processes .append (threading .Thread (target = search_shodan , args = (self ,)))
88+ threads .append (threading .Thread (target = search_shodan , args = (self ,)))
11689
11790 # Additional options - nmap scan of dnssec script and a host/port scan
11891 if self .options ["--with-nmap" ]:
119- processes .append (
92+ threads .append (
12093 threading .Thread (target = dnssecc_subdomain_enum , args = (self , target )))
121- processes .append (threading .Thread (target = scan_host , args = (self )))
94+ threads .append (threading .Thread (target = scan_host , args = (self , )))
12295
12396 # Additional options - brute force common subdomains
12497 if self .options ["--brute-force" ]:
125- processes .append (
98+ threads .append (
12699 threading .Thread (target = brute_force , args = (self , target )))
127100
128- # Start all processes
129- for x in processes :
101+ # Start all threads
102+ for x in threads :
130103 x .start ()
131104
132105 # Wait for all of them to finish
133- for x in processes :
106+ for x in threads :
134107 x .join ()
135108
136109 # remove duplicates and clean up
137110
138111 if self .options ["--recursive" ]:
139112 recursive_search (self )
140113
141- self .domains = clean_domains (self .domains )
114+ self .domains = self . clean_domains (self .domains )
142115 self .dedupe = set (self .domains )
143116
144117 print ("Found" , len (self .dedupe ), "subdomains" )
@@ -172,3 +145,29 @@ def resolve_ips(self):
172145 # String truthiness ignores empty strings
173146 if ip :
174147 ColorPrint .green (ip )
148+
149+ @staticmethod
150+ def clean_domains (domains ):
151+ cleaned = []
152+ for subdomain in domains :
153+ subdomain = subdomain .lower ()
154+ if subdomain .find ("//" ) != - 1 :
155+ subdomain = subdomain [subdomain .find ("//" ) + 2 :]
156+ # Some pkey return instances like example.com. - remove the final .
157+ if subdomain .endswith ('.' ):
158+ subdomain = subdomain [:- 1 ]
159+ # sometimes we'll get something like /www.example.com
160+ if subdomain [0 ] in ["\\ " , "." , "/" , "#" , "$" , "%" ]:
161+ subdomain = subdomain [1 :]
162+ # If it's an email address, only take the domain part
163+ if "@" in subdomain :
164+ subdomain = subdomain .split ("@" )
165+ # If it's an actual email like mail@example.com, take example.com
166+ if len (subdomain ) > 1 :
167+ subdomain = subdomain [1 ]
168+ else :
169+ # If for some reason it's example.com@, take example.com
170+ subdomain = subdomain [0 ]
171+
172+ cleaned .append (subdomain .strip ())
173+ return cleaned
0 commit comments