22import re
33import socket
44import sys
5- from threading import Thread
5+ import threading
66from urllib .parse import urlsplit
77
88from anubis .scanners .anubis_db import search_anubisdb , send_to_anubisdb
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+
2753class Target (Base ):
2854 """Main enumeration module"""
2955 domains = list ()
@@ -68,49 +94,51 @@ def run(self):
6894 self .init ()
6995 for i in range (len (self .options ["TARGET" ])):
7096 # Default scans that run every time
71- threads = [
72- Thread (target = dns_zonetransfer (self , self .options ["TARGET" ][i ])),
73- Thread (target = search_subject_alt_name (self , self .options ["TARGET" ][i ])),
74- Thread (target = subdomain_hackertarget (self , self .options ["TARGET" ][i ])),
75- Thread (target = search_virustotal (self , self .options ["TARGET" ][i ])),
76- Thread (target = search_pkey (self , self .options ["TARGET" ][i ])),
77- Thread (target = search_netcraft (self , self .options ["TARGET" ][i ])),
78- Thread (target = search_crtsh (self , self .options ["TARGET" ][i ])),
79- Thread (target = search_dnsdumpster (self , self .options ["TARGET" ][i ])),
80- Thread (target = search_anubisdb (self , self .options ["TARGET" ][i ]))]
97+ target = self .options ["TARGET" ][i ]
98+ processes = [
99+ threading .Thread (target = dns_zonetransfer , args = (self , target )),
100+ threading .Thread (target = search_subject_alt_name , args = (self , target )),
101+ threading .Thread (target = subdomain_hackertarget , args = (self , target )),
102+ threading .Thread (target = search_virustotal , args = (self , target )),
103+ threading .Thread (target = search_pkey , args = (self , target )),
104+ threading .Thread (target = search_netcraft , args = (self , target )),
105+ threading .Thread (target = search_crtsh , args = (self , target )),
106+ threading .Thread (target = search_dnsdumpster , args = (self , target )),
107+ threading .Thread (target = search_anubisdb , args = (self , target ))]
108+ print ('test' )
81109 # Additional options - ssl cert scan
82110 if self .options ["--ssl" ]:
83- threads .append (Thread (target = ssl_scan (self , self . options [ "TARGET" ][ i ] )))
111+ processes .append (threading . Thread (target = ssl_scan , args = (self , target )))
84112
85113 # Additional options - shodan.io scan
86114 if self .options ["--additional-info" ]:
87- threads .append (Thread (target = search_shodan (self )))
115+ processes .append (threading . Thread (target = search_shodan , args = (self , )))
88116
89117 # Additional options - nmap scan of dnssec script and a host/port scan
90118 if self .options ["--with-nmap" ]:
91- threads .append ( Thread (
92- target = dnssecc_subdomain_enum (self , self . options [ "TARGET" ][ i ] )))
93- threads .append (Thread (target = scan_host (self )))
119+ processes .append (
120+ threading . Thread ( target = dnssecc_subdomain_enum , args = (self , target )))
121+ processes .append (threading . Thread (target = scan_host , args = (self )))
94122
95123 # Additional options - brute force common subdomains
96124 if self .options ["--brute-force" ]:
97- threads .append (
98- Thread (target = brute_force (self , self . options [ "TARGET" ][ i ] )))
125+ processes .append (
126+ threading . Thread (target = brute_force , args = (self , target )))
99127
100- # Start all threads
101- for x in threads :
128+ # Start all processes
129+ for x in processes :
102130 x .start ()
103131
104132 # Wait for all of them to finish
105- for x in threads :
133+ for x in processes :
106134 x .join ()
107135
108136 # remove duplicates and clean up
109137
110138 if self .options ["--recursive" ]:
111139 recursive_search (self )
112140
113- self .domains = self . clean_domains (self .domains )
141+ self .domains = clean_domains (self .domains )
114142 self .dedupe = set (self .domains )
115143
116144 print ("Found" , len (self .dedupe ), "subdomains" )
@@ -125,31 +153,6 @@ def run(self):
125153 if self .options ["--send-to-anubis-db" ]:
126154 send_to_anubisdb (self , self .options ["TARGET" ])
127155
128- def clean_domains (self , domains ):
129- cleaned = []
130- for subdomain in domains :
131- subdomain = subdomain .lower ()
132- if subdomain .find ("//" ) != - 1 :
133- subdomain = subdomain [subdomain .find ("//" ) + 2 :]
134- # Some pkey return instances like example.com. - remove the final .
135- if subdomain .endswith ('.' ):
136- subdomain = subdomain [:- 1 ]
137- # sometimes we'll get something like /www.example.com
138- if subdomain [0 ] in ["\\ " , "." , "/" , "#" , "$" , "%" ]:
139- subdomain = subdomain [1 :]
140- # If it's an email address, only take the domain part
141- if "@" in subdomain :
142- subdomain = subdomain .split ("@" )
143- # If it's an actual email like mail@example.com, take example.com
144- if len (subdomain ) > 1 :
145- subdomain = subdomain [1 ]
146- else :
147- # If for some reason it's example.com@, take example.com
148- subdomain = subdomain [0 ]
149-
150- cleaned .append (subdomain .strip ())
151- return cleaned
152-
153156 def resolve_ips (self ):
154157 unique_ips = set ()
155158 for domain in self .dedupe :
0 commit comments