metasploit-framework

https://github.com/rapid7/metasploit-framework

Ruby

Metasploit Framework

Net::DNS::Resolver#search

Performs a DNS query for the given name, applying the searchlist if
appropriate.  The search algorithm is as follows:

1. If the name contains at least one dot, try it as is.
2. If the name doesn't end in a dot then append each item in the search
   list to the name.  This is only done if +dns_search+ is true.
3. If the name doesn't contain any dots, try it as is.

The record type and class can be omitted; they default to +A+ and +IN+.

  packet = res.search('mailhost')
  packet = res.search('mailhost.example.com')
  packet = res.search('example.com', Net::DNS::MX)
  packet = res.search('user.passwd.example.com', Net::DNS::TXT, Net::DNS::HS)

If the name is an IP address (Ipv4 or IPv6), in the form of a string
or a +IPAddr+ object, then an appropriate PTR query will be performed:

  ip = IPAddr.new("172.16.100.2")
  packet = res.search(ip)
  packet = res.search("192.168.10.254")

Returns a Net::DNS::Packet object. If you need to examine the response packet
whether it contains any answers or not, use the send() method instead.

Source | Google | Stack overflow

Edit

git clone [email protected]:rapid7/metasploit-framework.git

cd metasploit-framework

open lib/net/dns/resolver.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Net--DNS--Resolver-search-for-pr


# Commit to git

git add lib/net/dns/resolver.rbgit commit -m "better docs for Net::DNS::Resolver#search"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Net--DNS--Resolver-search-for-pr

hub pull-request


# Celebrate!