From 0e7549c485360298ab5fd7720ce5813042440ca7 Mon Sep 17 00:00:00 2001 From: pgpickering Date: Thu, 21 Aug 2008 09:25:28 +0000 Subject: [PATCH] added nmap.get_dns_servers() to the NSE --- nse_nmaplib.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index a1441b5e1..871a769d4 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -13,6 +13,9 @@ #include "output.h" #include "portlist.h" +#include "nmap_dns.h" + + #define SCRIPT_ENGINE_GETSTRING(name) \ char* name; \ lua_getfield(L, -1, #name); \ @@ -43,6 +46,7 @@ static int l_get_debugging(lua_State *); static int l_get_have_ssl(lua_State *L); static int l_fetchfile(lua_State *L); static int l_get_timing_level(lua_State *L); +static int l_get_dns_servers(lua_State *L); int l_clock_ms(lua_State *L); @@ -132,6 +136,7 @@ int luaopen_nmap (lua_State *L) {"fetchfile", l_fetchfile}, {"timing_level", l_get_timing_level}, {"mutex", l_mutex}, + {"get_dns_servers", l_get_dns_servers}, {NULL, NULL} }; @@ -636,3 +641,23 @@ static int l_get_timing_level(lua_State *L) lua_pushnumber(L, o.timing_level); return 1; } + + +// returns a table with DNS servers known to nmap +static int l_get_dns_servers(lua_State *L) +{ + std::list servs2 = get_dns_servers(); + std::list::iterator servI2; + + int i = 1; + lua_newtable(L); + + for(servI2 = servs2.begin(); servI2 != servs2.end(); servI2++) { + lua_pushinteger(L, i); + const char *s = (*servI2).c_str(); + lua_pushstring(L, s); + lua_settable(L, -3); + i++; + } + return 1; +}