updated dns extension to use async-dns instead of old rubydns

This commit is contained in:
Haoxi Tan
2020-01-10 09:43:45 +10:00
parent 39ef3fe4f6
commit f5de5eb7c0
3 changed files with 24 additions and 15 deletions

View File

@@ -52,7 +52,7 @@ end
# DNS extension
group :ext_dns do
gem 'rubydns', '~> 0.7.3'
gem 'async-dns'
end
# QRcode extension

View File

@@ -11,7 +11,7 @@ module BeEF
# using a rule-based system. A list of user-defined rules is used to match against incoming
# DNS requests. These rules generate a response that is either a resource record or a
# failure code.
class Server < RubyDNS::Server
class Server < Async::DNS::Server
include Singleton
@@ -127,15 +127,19 @@ module BeEF
Thread.new do
EventMachine.next_tick do
upstream = options[:upstream] || nil
listen = options[:listen] || nil
# listen is called enpoints in Async::DNS
@endpoints = listen
if upstream
resolver = RubyDNS::Resolver.new(upstream)
resolver = Async::DNS::Resolver.new(upstream)
@otherwise = Proc.new { |t| t.passthrough!(resolver) }
end
begin
super(:listen => listen)
# super(:listen => listen)
Thread.new { super() }
rescue RuntimeError => e
if e.message =~ /no datagram socket/ || e.message =~ /no acceptor/ # the port is in use
print_error "[DNS] Another process is already listening on port #{options[:listen]}"
@@ -146,6 +150,7 @@ module BeEF
end
end
end
end
end
@@ -159,6 +164,9 @@ module BeEF
# @param transaction [RubyDNS::Transaction] internal RubyDNS class detailing DNS question/answer
def process(name, resource, transaction)
@lock.synchronize do
resource = resource.to_s
print_debug "Received DNS request (name: #{name} type: #{format_resource(resource)})"
# no need to parse AAAA resources when data is extruded from client. Also we check if the FQDN starts with the 0xb3 string.

View File

@@ -3,7 +3,8 @@
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
require 'rubydns'
require 'async/dns'
module BeEF
module Extension