diff --git a/CHANGELOG b/CHANGELOG index 455706ddd..0ee3aa0a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o [NSE] Host tables now have a host.traceroute member when --traceroute + is used. This array contains the IP address, reverse DNS name, and RTT + for each traceroute hop. [Henri Doreau] + o [NSE] Made the ftp-anon script return a directory listing when anonymous login is allowed. [Gutek, David] diff --git a/docs/scripting.xml b/docs/scripting.xml index 8201afc26..943da6a1e 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -1551,6 +1551,21 @@ LUALIB_API int luaopen_openssl(lua_State *L) { + + + + + + This is an array of traceroute hops, present when the + option was used. Each entry is a + host table with fields name, + ip and times.srtt (round + trip time). The TTL for an entry is implicit given its position + in the table. An empty table represents a timed-out hop. + + + + diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index e108e0994..6ea35c6d2 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -154,6 +154,32 @@ void set_hostinfo(lua_State *L, Target *currenths) { FingerPrintResults *FPR = currenths->FPR; + /* add distance (in hops) if traceroute has been performed */ + if (currenths->traceroute_hops.size() > 0) + { + std::list::iterator it; + int i = 1; + + lua_newtable(L); + for (it = currenths->traceroute_hops.begin(); it != currenths->traceroute_hops.end(); it++) + { + lua_pushinteger(L, i++); + lua_newtable(L); + /* fill the table if the hop has not timed out, otherwise an empty table + * is inserted */ + if (!it->timedout) { + setsfield(L, -1, "ip", inet_ntop_ez(&it->addr, sizeof(it->addr))); + if (!it->name.empty()) + setsfield(L, -1, "name", it->name.c_str()); + lua_newtable(L); + setnfield(L, -1, "srtt", it->rtt / 1000.0); + lua_setfield(L, -2, "times"); + } + lua_settable(L, -3); + } + lua_setfield(L, -2, "traceroute"); + } + /* if there has been an os scan which returned a pretty certain * result, we will use it in the scripts * matches which aren't perfect are not needed in the scripts