Skip to content

Commit 1c2aaa0

Browse files
author
blark
committed
fixed logger name
1 parent b5aca7a commit 1c2aaa0

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

aiodnsbrute/cli.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, verbosity=0, max_tasks=512):
3232
self.sem = asyncio.BoundedSemaphore(max_tasks)
3333
self.max_tasks = max_tasks
3434
self.verbosity = verbosity
35-
self.new_logger = ConsoleLogger(verbosity)
35+
self.logger = ConsoleLogger(verbosity)
3636

3737
async def _dns_lookup(self, name):
3838
"""Performs a DNS request using aiodns, self.lookup_type is set by the run function.
@@ -69,19 +69,19 @@ def _dns_result_callback(self, name, future):
6969
err_number = future.exception().args[0]
7070
err_text = future.exception().args[1]
7171
except IndexError:
72-
self.new_logger.error(f"Couldn't parse exception: {future.exception()}")
72+
self.logger.error(f"Couldn't parse exception: {future.exception()}")
7373
# handle the DNS errors we expect to receive, show user unexpected errors
7474
if err_number == 4:
7575
# This is domain name not found, ignore it
7676
pass
7777
elif err_number == 12:
7878
# Timeout from DNS server
79-
self.new_logger.warn(f"Timeout for {name}")
79+
self.logger.warn(f"Timeout for {name}")
8080
elif err_number == 1:
8181
# Server answered with no data
8282
pass
8383
else:
84-
self.new_logger.error(
84+
self.logger.error(
8585
f"{name} generated an unexpected exception: {future.exception()}"
8686
)
8787
# for debugging/troubleshoooting keep a list of errors
@@ -108,13 +108,13 @@ def _dns_result_callback(self, name, future):
108108
row = f"{n:<30}\t{ip}"
109109
# store the result
110110
if ip not in self.ignore_hosts:
111-
self.new_logger.success(row)
111+
self.logger.success(row)
112112
dns_lookup_result = {"domain": name, "ip": [ip]}
113113
if self.lookup_type == "gethostbyname" and cname:
114114
dns_lookup_result["cname"] = r.name
115115
dns_lookup_result["aliases"] = r.aliases
116116
self.fqdn.append(dns_lookup_result)
117-
self.new_logger.debug(future.result())
117+
self.logger.debug(future.result())
118118
self.tasks.remove(future)
119119
if self.verbosity >= 1:
120120
self.pbar.update()
@@ -155,35 +155,35 @@ def run(
155155
Returns:
156156
dict containing result of lookups
157157
"""
158-
self.new_logger.info(
158+
self.logger.info(
159159
f"Brute forcing {domain} with a maximum of {self.max_tasks} concurrent tasks..."
160160
)
161161
if verify:
162-
self.new_logger.info(f"Using local resolver to verify {domain} exists.")
162+
self.logger.info(f"Using local resolver to verify {domain} exists.")
163163
try:
164164
socket.gethostbyname(domain)
165165
except socket.gaierror as err:
166-
self.new_logger.error(
166+
self.logger.error(
167167
f"Couldn't resolve {domain}, use the --no-verify switch to ignore this error."
168168
)
169169
raise SystemExit(
170-
self.new_logger.error(f"Error from host lookup: {err}")
170+
self.logger.error(f"Error from host lookup: {err}")
171171
)
172172
else:
173-
self.new_logger.warn("Skipping domain verification. YOLO!")
173+
self.logger.warn("Skipping domain verification. YOLO!")
174174
if resolvers:
175175
self.resolver.nameservers = resolvers
176-
self.new_logger.info(
176+
self.logger.info(
177177
f"Using recursive DNS with the following servers: {self.resolver.nameservers}"
178178
)
179179

180180
if query:
181-
self.new_logger.info(
181+
self.logger.info(
182182
"Using pycares `query` function to perform lookups, CNAMEs cannot be identified"
183183
)
184184
self.lookup_type = "query"
185185
else:
186-
self.new_logger.info(
186+
self.logger.info(
187187
"Using pycares `gethostbyname` function to perform lookups, CNAME data will be appended to results (** denotes CNAME, show actual name with -vv)"
188188
)
189189
self.lookup_type = "gethostbyname"
@@ -199,37 +199,37 @@ def run(
199199
)
200200
except aiodns.error.DNSError as err:
201201
# we expect that the record will not exist and error 4 will be thrown
202-
self.new_logger.info(
202+
self.logger.info(
203203
f"No wildcard response was detected for this domain."
204204
)
205205
wc_check = None
206206
finally:
207207
if wc_check is not None:
208208
self.ignore_hosts = [host.host for host in wc_check]
209-
self.new_logger.warn(
209+
self.logger.warn(
210210
f"Wildcard response detected, ignoring answers containing {self.ignore_hosts}"
211211
)
212212
else:
213-
self.new_logger.warn("Wildcard detection is disabled")
213+
self.logger.warn("Wildcard detection is disabled")
214214

215215
with open(wordlist, encoding="utf-8", errors="ignore") as words:
216216
w = words.read().splitlines()
217-
self.new_logger.info(f"Wordlist loaded, proceeding with {len(w)} DNS requests")
217+
self.logger.info(f"Wordlist loaded, proceeding with {len(w)} DNS requests")
218218
try:
219219
if self.verbosity >= 1:
220220
self.pbar = tqdm(
221221
total=len(w), unit="rec", maxinterval=0.1, mininterval=0
222222
)
223223
self.loop.run_until_complete(self._queue_lookups(w, domain))
224224
except KeyboardInterrupt:
225-
self.new_logger.warn("Caught keyboard interrupt, cleaning up...")
225+
self.logger.warn("Caught keyboard interrupt, cleaning up...")
226226
asyncio.gather(*asyncio.Task.all_tasks()).cancel()
227227
self.loop.stop()
228228
finally:
229229
self.loop.close()
230230
if self.verbosity >= 1:
231231
self.pbar.close()
232-
self.new_logger.info(f"Completed, {len(self.fqdn)} subdomains found")
232+
self.logger.info(f"Completed, {len(self.fqdn)} subdomains found")
233233
return self.fqdn
234234

235235

0 commit comments

Comments
 (0)