11import requests
2- from threading import Thread
2+ from threading import Thread , Lock
33from queue import Queue
44
55q = Queue ()
6+ list_lock = Lock ()
7+ discovered_domains = []
68
79def scan_subdomains (domain ):
810 global q
@@ -17,6 +19,9 @@ def scan_subdomains(domain):
1719 pass
1820 else :
1921 print ("[+] Discovered subdomain:" , url )
22+ # add the subdomain to the global list
23+ with list_lock :
24+ discovered_domains .append (url )
2025
2126 # we're done with scanning that subdomain
2227 q .task_done ()
@@ -44,12 +49,19 @@ def main(domain, n_threads, subdomains):
4449 parser .add_argument ("-l" , "--wordlist" , help = "File that contains all subdomains to scan, line by line. Default is subdomains.txt" ,
4550 default = "subdomains.txt" )
4651 parser .add_argument ("-t" , "--num-threads" , help = "Number of threads to use to scan the domain. Default is 10" , default = 10 , type = int )
52+ parser .add_argument ("-o" , "--output-file" , help = "Specify the output text file to write discovered subdomains" )
4753
4854 args = parser .parse_args ()
4955 domain = args .domain
5056 wordlist = args .wordlist
5157 num_threads = args .num_threads
58+ output_file = args .output_file
5259
5360 main (domain = domain , n_threads = num_threads , subdomains = open (wordlist ).read ().splitlines ())
5461 q .join ()
62+
63+ # save the file
64+ with open (output_file , "w" ) as f :
65+ for url in discovered_domains :
66+ print (url , file = f )
5567
0 commit comments