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

Add timeout to DNS queries #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions subbrute.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import socket
import struct

# Maximum time to wait for a DNS query to complete
QUERY_TIMEOUT = 4

#Python 2.x and 3.x compatiablity
#We need the Queue library for exception handling
try:
Expand Down Expand Up @@ -63,7 +66,7 @@ def query(self, hostname, query_type = 'ANY', name_server = False, use_tcp = Tru
self.last_resolver = name_server
query = dnslib.DNSRecord.question(hostname, query_type.upper().strip())
try:
response_q = query.send(name_server, 53, use_tcp)
response_q = query.send(name_server, 53, use_tcp, QUERY_TIMEOUT)
if response_q:
response = dnslib.DNSRecord.parse(response_q)
else:
Expand Down Expand Up @@ -856,4 +859,4 @@ def signal_init():
target = target.strip()
if target:
trace(target, record_type, options.subs, options.resolvers, options.process_count, options.print_data, output, json_output)
print_target(target, record_type, options.subs, options.resolvers, options.process_count, options.print_data, output, json_output)
print_target(target, record_type, options.subs, options.resolvers, options.process_count, options.print_data, output, json_output)