From 60646d493cbcf0fa9bf5ec4188132d9dc3efc8f5 Mon Sep 17 00:00:00 2001 From: umfc Date: Mon, 23 Oct 2023 02:33:36 +0300 Subject: [PATCH] Allow specifying custom resolver port --- README.md | 1 + aiodnsbrute/cli.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9f14d2..bb7e010 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Get help: Options: -w, --wordlist TEXT Wordlist to use for brute force. -t, --max-tasks INTEGER Maximum number of tasks to run asynchronosly. + -p, --port INTEGER DNS resolver's custom port. Default: 53 -r, --resolver-file FILENAME A text file containing a list of DNS resolvers to use, one per line, comments start with #. Default: use system resolvers diff --git a/aiodnsbrute/cli.py b/aiodnsbrute/cli.py index 706b1f3..12e4bde 100644 --- a/aiodnsbrute/cli.py +++ b/aiodnsbrute/cli.py @@ -15,12 +15,13 @@ class aioDNSBrute(object): """aiodnsbrute implements fast domain name brute forcing using Python's asyncio module.""" - def __init__(self, verbosity=0, max_tasks=512): + def __init__(self, verbosity=0, max_tasks=512, port=53): """Constructor. Args: verbosity: set output verbosity: 0 (default) is none, 3 is debug max_tasks: the maximum number of tasks asyncio will queue (default 512) + port: DNS resolver's custom port (default 53) """ self.tasks = [] self.errors = [] @@ -28,7 +29,7 @@ def __init__(self, verbosity=0, max_tasks=512): self.ignore_hosts = [] asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) self.loop = asyncio.get_event_loop() - self.resolver = aiodns.DNSResolver(loop=self.loop, rotate=True) + self.resolver = aiodns.DNSResolver(loop=self.loop, rotate=True, tcp_port=port, udp_port=port) self.sem = asyncio.BoundedSemaphore(max_tasks) self.max_tasks = max_tasks self.verbosity = verbosity @@ -247,6 +248,12 @@ def run( default=512, help="Maximum number of tasks to run asynchronosly.", ) +@click.option( + "--port", + "-p", + default=53, + help="DNS resolver's custom port. Default: 53", +) @click.option( "--resolver-file", "-r", @@ -307,7 +314,7 @@ def main(**kwargs): lines = resolvers.read().splitlines() resolvers = [x.strip() for x in lines if (x and not x.startswith("#"))] - bf = aioDNSBrute(verbosity=verbosity, max_tasks=kwargs.get("max_tasks")) + bf = aioDNSBrute(verbosity=verbosity, max_tasks=kwargs.get("max_tasks"), port=kwargs.get("port")) results = bf.run( wordlist=kwargs.get("wordlist"), domain=kwargs.get("domain"),