Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying custom resolver port #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions aiodnsbrute/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
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 = []
self.fqdn = []
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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down