From fcd93e141fed038b00f316c15e922b93cc2cd758 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 10 Apr 2015 03:42:46 +0000 Subject: [PATCH] Use http.lua's default redirect follower for http-generator.nse --- scripts/http-generator.nse | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/scripts/http-generator.nse b/scripts/http-generator.nse index 8c002cc9a..214781ab9 100644 --- a/scripts/http-generator.nse +++ b/scripts/http-generator.nse @@ -46,20 +46,6 @@ categories = {"default", "discovery", "safe"} -- 2014-07-29 Fabian Affolter : -- + update generator pattern --- Helper function -local follow_redirects = function(host, port, path, n) - local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]" - local response = http.get(host, port, path) - - while (response['status-line'] or ""):match(pattern) and n > 0 do - n = n - 1 - local loc = response.header['location'] - response = http.get_url(loc) - end - - return response -end - portrule = shortport.http action = function(host, port) @@ -76,7 +62,7 @@ action = function(host, port) string.upper(c)) end) - response = follow_redirects(host, port, path, redirects) + response = http.get(host, port, path, {redirect_ok=redirects}) if ( response and response.body ) then return response.body:match(pattern) end