Skip to content

Commit 2eee34b

Browse files
committed
added timeout options and rescue timeout
1 parent fe34d0e commit 2eee34b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/auxiliary/gather/dns_cache_scraper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def initialize(info = {})
3535

3636
register_advanced_options([
3737
OptBool.new('TCP_DNS', [false, "Run queries over TCP", false]),
38+
OptInt.new('DNS_TIMEOUT', [true, "DNS Timeout in seconds", 5])
3839
], self.class)
3940
end
4041

@@ -44,13 +45,17 @@ def scrape_dns(domain)
4445
# dns request with recursive disabled
4546
use_tcp = datastore['TCP_DNS']
4647
res = Net::DNS::Resolver.new(:nameservers => "#{datastore['NS']}", :recursive => false, :use_tcp => use_tcp)
48+
use_tcp ? res.tcp_timeout = datastore['DNS_TIMEOUT'] : res.udp_timeout = datastore['DNS_TIMEOUT']
4749

4850
# query dns
4951
begin
5052
query = res.send(domain)
5153
rescue ResolverArgumentError
5254
print_error("Invalid domain: #{domain}")
5355
return
56+
rescue NoResponseError
57+
print_error("DNS Timeout Issue: #{domain}")
58+
return
5459
end
5560

5661
# found or not found

0 commit comments

Comments
 (0)