Hi!
I've been working on a DNS library for NSE.
The most interesting function for you probably is
dns.query(dname, dtype, host, port, tries)
where all but the first arguments are optional:
* dname is the domain name to query
* dtype is the number of the DNS record type you want.
Usually you use dns.types.* (e.g. dns.types.MX).
It also accepts strings (e.g. "A", "PTR", ...) which it looks
up in the dns.types table.
* host and port are the nameserver you want to ask
* tries is the number of tries, so it won't get into an
infinite loop on circular references
It then tries to find a nice answer depending on the answer it
received and the DNS record type.
If no nameserver is given it tries to use the nameservers known
to Nmap. This works only if you apply the patch I attached,
which is against the current svn version (rev 9443).
For a reverse lookup you need dns.reverse(ip) to
prepare the IP address for a PTR query:
dns.query(dns.reverse(ip), dns.types.PTR))
One detail I'd like to change is instead of passing four optional
arguments to pass only one option table (maybe with some
more options, e.g. set "no recurse" option or omit trying to
format the answer).
Please test and comment.
cheers,
Philip
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
- application/octet-stream attachment: dns_lua
Received on Aug 11 2008