1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00

Added a 'path' script-arg to http-headers.nse. Changed it to use 'HEAD' by default, and fail to using 'GET' the same way other scripts do (also added a 'useget' script-arg to turn it off). Also fixed some print_debugs in http.lua that were prefixed with 'http-enum.nse:'.

This commit is contained in:
ron
2009-08-27 15:39:17 +00:00
parent fc2b575fba
commit 62dedb9dc1
2 changed files with 63 additions and 33 deletions

View File

@@ -17,7 +17,8 @@ Does a GET request for the root folder ("/"), and displays the HTTP headers retu
-- | last-modified: Mon, 19 May 2008 04:49:49 GMT
-- |_ server: Apache/2.2.2 (Fedora)
--
--
--@arg path The path to request, such as '/index.php'. Default: '/'.
--@arg useget Set to force GET requests instead of HEAD.
author = "Ron Bowes <ron@skullsecurity.org>"
@@ -45,25 +46,45 @@ portrule = function(host, port)
end
action = function(host, port)
local result = http.get(host, port, "/")
local path = nmap.registry.args.path
local request_type = "HEAD"
if(path == nil) then
path = '/'
end
local status = false
local result
-- Check if the user didn't want HEAD to be used
if(nmap.registry.args.useget == nil) then
-- Try using HEAD first
status, result = http.can_use_head(host, port, path)
end
-- If head failed, try using GET
if(status == false) then
stdnse.print_debug(1, "http-headers.nse: HEAD request failed, falling back to GET")
result = http.get(host, port, path)
request_type = "GET"
end
if(result == nil) then
if(nmap.debugging() > 0) then
return "ERROR: GET request failed"
return "ERROR: Header request failed"
else
return nil
end
end
if(result.header == nil) then
if(result.rawheader == nil) then
if(nmap.debugging() > 0) then
return "ERROR: GET request didn't return a proper header"
return "ERROR: Header request didn't return a proper header"
else
return nil
end
end
local response = " \n"
local response = "(" .. request_type .. " used)\n"
for _, header in pairs(result.rawheader) do
response = response .. header .. "\n"
end