Skip to content

ronin-rb/ronin-dns-proxy

Repository files navigation

ronin-dns-proxy

CI Code Climate

Description

ronin-dns-proxy is a configurable DNS proxy server library. It supports reutrning spoofing DNS results or passing DNS queries through to the upstream DNS nameserver.

Features

  • Supports returning spoofed results to specific DNS queries.
  • Supports matching queries with regular expressions.
  • Supports dynamic DNS server rules.
  • Passing through all other DNS queries.
  • Has 95% documentation coverage.
  • Has 100% test coverage.

Examples

require 'ronin/dns/proxy'

Ronin::DNS::Proxy.run('127.0.0.1', 2346) do |server|
  server.add_rule :A, 'example.com', '10.0.0.1'
  server.add_rule :AAAA, 'example.com', 'dead:beef::1'

  # return multiple values
  server.add_rule :A, 'ftp.example.com', ['10.0.0.42', '10.0.0.43']

  # match a query using a regex
  server.add_rule :TXT, /^spf\./, "v=spf1 include:10.0.0.1 ~all"

  # return an error for a valid hostname
  server.add_rule :A, 'updates.example.com', :ServFail

  # define a dynamic rule
  server.add_rule :CNAME, /^www\./, ->(type,name,transaction) {
    # append '.hax' to the domain name
    names = name.split('.').push('hax')

    transaction.respond!(names)
  }

  # return MX records
  server.add_rule :MX, 'example.com', ->(type,name,transaction) {
    transaction.respond!(10, Resolv::DNS::Name.create('email.evil.com' ))
  }
end

Then try running host -p 2346 example.com 127.0.0.1 once the server is running.

Requirements

Install

$ gem install ronin-dns-proxy

Gemfile

gem 'ronin-dns-proxy', '~> 0.1'

gemspec

gem.add_dependency 'ronin-dns-proxy', '~> 0.1'

Development

  1. Fork It!
  2. Clone It!
  3. cd ronin-dns-proxy/
  4. bundle install
  5. git checkout -b my_feature
  6. Code It!
  7. bundle exec rake spec
  8. git push origin my_feature

License

Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)

ronin-dns-proxy is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ronin-dns-proxy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with ronin-dns-proxy. If not, see https://www.gnu.org/licenses/.