From fbf2c3d6a7c296addeffbcc4847dc423005fd694 Mon Sep 17 00:00:00 2001 From: ron Date: Sun, 23 Aug 2009 16:58:53 +0000 Subject: [PATCH] Print the http status along with the result, if it isn't 200 OK. This was the original behaviour, but it got lost along the way. --- nselib/http.lua | 2 +- scripts/http-enum.nse | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index 8faf77f41..c6fd4876c 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -948,7 +948,7 @@ end -- --@param data The data returned by a HTTP request (can be nil or empty) --@return The status string, the status code, or "". -local function get_status_string(data) +function get_status_string(data) -- Make sure we have valid data if(data == nil) then return "" diff --git a/scripts/http-enum.nse b/scripts/http-enum.nse index 46d44f0be..d54df979a 100644 --- a/scripts/http-enum.nse +++ b/scripts/http-enum.nse @@ -52,6 +52,7 @@ local FILENAME_BASE = "nselib/data/" -- List of fingerprint files local fingerprint_files = { "http-fingerprints", "yokoso-fingerprints" } +--local fingerprint_files = { "test-fingerprints" } portrule = function(host, port) local svc = { std = { ["http"] = 1, ["http-alt"] = 1 }, @@ -173,13 +174,21 @@ action = function(host, port) for i, data in pairs(results) do if(http.page_exists(data, result_404, known_404, URLs[i].checkdir, nmap.registry.args.displayall)) then + -- Build the description + local description = string.format("%s", URLs[i].checkdir) if(URLs[i].checkdesc) then - stdnse.print_debug(1, "http-enum.nse: Found a valid page! (%s: %s)", URLs[i].checkdir, URLs[i].checkdesc) - response = response .. URLs[i].checkdir .. " " .. URLs[i].checkdesc .. "\n" - else - stdnse.print_debug(1, "http-enum.nse: Found a valid page! (%s: %s)", URLs[i].checkdir, URLs[i].checkdesc) - response = response .. URLs[i].checkdir .. "\n" + description = string.format("%s: %s", URLs[i].checkdir, URLs[i].checkdesc) end + + -- Build the status code, if it isn't a 200 + local status = "" + if(data.status ~= 200) then + status = " (" .. http.get_status_string(data) .. ")" + end + + stdnse.print_debug("Found a valid page! (%s)%s", description, status) + + response = response .. string.format("%s%s\n", description, status) end end