From 4fa478cea4879015a127ab90775320595968e1e8 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 22 Jul 2016 15:52:30 +0000 Subject: [PATCH] Check for non-404 file nonexistence responses in http-config-backup --- scripts/http-config-backup.nse | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/http-config-backup.nse b/scripts/http-config-backup.nse index 0fb85889d..716c93a74 100644 --- a/scripts/http-config-backup.nse +++ b/scripts/http-config-backup.nse @@ -196,6 +196,12 @@ action = function (host, port) save = save .. "/"; end + local status_404, result_404, known_404 = http.identify_404(host, port) + if not status_404 then + stdnse.debug1("Can't distinguish 404 response. Quitting.") + return stdnse.format_output(false, "Can't determine file existence") + end + -- for each config file for _, cfg in ipairs(CONFIGS) do -- for each alteration of the filename @@ -203,10 +209,12 @@ action = function (host, port) local url_path url_path = url.build({path = path .. entry}); + -- http request local response = http.get(host, port, url_path); - if (response.status == 200) then + -- if it's not 200, don't bother. If it is, check that it's not a false 404 + if response.status == 200 and http.page_exists(response, result_404, known_404, url_path) then -- check it if is valid before inserting if cfg.check(response.body) then local filename = stdnse.escape_filename((host.targetname or host.ip) .. url_path)