diff --git a/CHANGELOG b/CHANGELOG index ada915568..3d7acce2e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o [NSE] Added gopher-ls.nse by Toni Ruotto, which lists the root of a + Gopher server. + o [NSE] Added modbus-discover.nse by Alexander Rudakov. This script enumerates Modbus slave ids and then tries to find device information about each of them. diff --git a/scripts/gopher-ls.nse b/scripts/gopher-ls.nse new file mode 100644 index 000000000..8b9a2221b --- /dev/null +++ b/scripts/gopher-ls.nse @@ -0,0 +1,59 @@ +description = [[ +Lists files and directories at the root of a gopher service. +]] + +--- +-- @output +-- 70/tcp open gopher +-- |_gopher-ls: [txt] Gopher, the next big thing?, [dir] Tax Forms + +author = "Toni Ruottu" +license = "Same as Nmap--See http://nmap.org/book/man-legal.html" +categories = {"default", "discovery", "safe"} + +require("nmap") +require("stdnse") +require("shortport") + +portrule = shortport.port_or_service (70, "gopher", {"tcp"}) + +local function typelabel(type) + if type == "0" then + return "[txt]" + end + if type == "1" then + return "[dir]" + end + return string.format("[%s]", type) + +end + +action = function( host, port ) + + local socket = nmap.new_socket() + local status, err = socket:connect(host.ip, port.number) + if not status then + return + end + + socket:send("\r\n") + + local buffer, _ = stdnse.make_buffer(socket, "\r\n") + local line = buffer() + local files = {} + + while line ~= nil do + local fields = stdnse.strsplit("\t", line) + local first = fields[1] + if #first > 1 then + local type = string.sub(first, 1, 1) + if type ~= "i" then + local label = string.sub(first, 2) + table.insert(files, string.format("%s %s", typelabel(type), label)) + end + end + line = buffer() + end + return stdnse.strjoin(", ", files) +end + diff --git a/scripts/script.db b/scripts/script.db index 369adfbb2..4c54685c7 100644 --- a/scripts/script.db +++ b/scripts/script.db @@ -42,6 +42,7 @@ Entry { filename = "ftp-brute.nse", categories = { "auth", "intrusive", } } Entry { filename = "ftp-libopie.nse", categories = { "intrusive", "vuln", } } Entry { filename = "ftp-proftpd-backdoor.nse", categories = { "discovery", "intrusive", } } Entry { filename = "giop-info.nse", categories = { "discovery", "safe", } } +Entry { filename = "gopher-ls.nse", categories = { "default", "discovery", "safe", } } Entry { filename = "hddtemp-info.nse", categories = { "default", "discovery", "safe", } } Entry { filename = "hostmap.nse", categories = { "discovery", "external", "intrusive", } } Entry { filename = "http-auth.nse", categories = { "auth", "default", "intrusive", } }