6
6
import lib .generics as gen
7
7
import lib .custom_logger as custom_logger
8
8
import time
9
-
9
+ import uuid
10
10
logger = custom_logger .logger
11
11
12
+ ips = set ()
13
+ def is_wildcard (fqdn : str ) -> bool :
14
+ """
15
+ Checks if the fqdn is a wildcard.
12
16
17
+ :param fqdn: A string representing the fully qualified domain name.
18
+ :return: A boolean indicating if the fqdn is a wildcard.
19
+ """
20
+ try :
21
+ random_subdomain = str (uuid .uuid4 ())
22
+ answer = dns .resolver .resolve (random_subdomain + "." + fqdn )
23
+ if answer :
24
+ # Test 100 random subdomains and store the ips inside ips set
25
+ for i in range (100 ):
26
+ random_subdomain = str (uuid .uuid4 ())
27
+ answer = dns .resolver .resolve (random_subdomain + "." + fqdn )
28
+ if answer :
29
+ ips .add (str (answer [0 ]))
30
+ return True
31
+ else :
32
+ return False
33
+
34
+ except :
35
+ return False
13
36
def resolve_and_store (
14
37
resolver : dns .resolver .Resolver ,
15
38
subdomain : str ,
16
39
fqdn : str ,
17
40
config : gen .configuration ,
18
41
res : result ,
19
42
pbar : tqdm ,
43
+ wildcard : bool = False ,
20
44
) -> None :
21
45
"""
22
46
Resolves the subdomain and stores the result inside res.result.
@@ -31,14 +55,15 @@ def resolve_and_store(
31
55
try :
32
56
answer = resolver .resolve (subdomain + "." + fqdn )
33
57
ip = str (answer [0 ])
58
+ if ip in ips and wildcard :
59
+ return
34
60
name = str (answer .qname )
35
61
ip = ip_lib .ip (ip , config )
36
62
res .add_fqdn (ip , name )
37
- # simulate some work being done
38
- time .sleep (0.1 )
39
- pbar .update (1 )
40
63
except :
41
64
pass
65
+ finally :
66
+ pbar .update (1 )
42
67
43
68
44
69
def main (config : gen .configuration , res : result , name : str ) -> result :
@@ -63,6 +88,11 @@ def main(config: gen.configuration, res: result, name: str) -> result:
63
88
logger .info ("[*] Skipping brute_subs" )
64
89
return
65
90
logger .info (f"[*] Bruteforcing subdomains for { name } " )
91
+ wildcard = False
92
+ if is_wildcard (name ):
93
+ logger .info (f"[*] { name } is a wildcard" )
94
+ wildcard = True
95
+
66
96
# get wordlist inside tools/worldlists
67
97
wordlist = f"tools/wordlists/{ this_tool_config ['wordlist_name' ]} "
68
98
# get resolver inside tools/resolvers
@@ -82,7 +112,7 @@ def main(config: gen.configuration, res: result, name: str) -> result:
82
112
with tqdm (total = len (subdomains ), leave = False ) as pbar :
83
113
futures = [
84
114
executor .submit (
85
- resolve_and_store , resolver , subdomain , fqdn , config , res , pbar
115
+ resolve_and_store , resolver , subdomain , fqdn , config , res , pbar , wildcard
86
116
)
87
117
for subdomain in subdomains
88
118
]
0 commit comments