1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Add http-alt and https-alt to the services handled by html-title.nse

Modified http.request() to connect using ssl for the https-alt service.
html-title.nse can now deal with a redirect which changes the url scheme
as long as a port is present in the url and it is the port being scanned.
This commit is contained in:
jah
2008-11-17 22:06:58 +00:00
parent 5464198f6b
commit fece92c4f7
2 changed files with 24 additions and 19 deletions

View File

@@ -27,15 +27,18 @@ local ipOps = require 'ipOps'
local stdnse = require 'stdnse'
portrule = function(host, port)
if port.protocol ~= 'tcp' or not (port.service == 'http' or port.service == 'https') then
return false
end
-- Don't bother running on SSL ports if we don't have SSL.
if (port.service == 'https' or port.version.service_tunnel == 'ssl')
and not nmap.have_ssl() then
return false
end
return true
local svc = { std = { ["http"] = 1, ["http-alt"] = 1 },
ssl = { ["https"] = 1, ["https-alt"] = 1 } }
if port.protocol ~= 'tcp'
or not ( svc.std[port.service] or svc.ssl[port.service] ) then
return false
end
-- Don't bother running on SSL ports if we don't have SSL.
if (svc.ssl[port.service] or port.version.service_tunnel == 'ssl')
and not nmap.have_ssl() then
return false
end
return true
end
action = function(host, port)
@@ -51,7 +54,7 @@ action = function(host, port)
local loc = redirect_ok( url, host, port )
if loc then
-- follow redirect
redir = ("Requested resource was %s://%s%s"):format( url.scheme or port.service, loc.host, loc.path )
redir = ("Requested resource was %s://%s%s%s"):format( url.scheme or port.service, loc.host, (url.port and (":%s"):format(url.port)) or "", loc.path )
data = http.get( loc.host, loc.port, loc.path )
else
loc = nil -- killed so we know we didn't follow a redirect
@@ -91,12 +94,6 @@ function redirect_ok(url, host, port)
-- A battery of tests a URL is subjected to in order to decide if it may be
-- redirected to. They incrementally fill in loc.host, loc.port, and loc.path.
local rules = {
function (loc, url, host, port)
-- if url.scheme is present then it must match the scanned port
if url.scheme and url.scheme ~= port.service then return false end
return true
end,
function (loc, url, host, port)
-- bail if userinfo is present
return ( url.userinfo and false ) or true
@@ -130,6 +127,13 @@ function redirect_ok(url, host, port)
return false
end,
function (loc, url, host, port)
-- if url.scheme is present then it must match the scanned port
if url.scheme and url.port then return true end
if url.scheme and url.scheme ~= port.service then return false end
return true
end,
function (loc, url, host, port)
-- path cannot be unchanged unless host has changed
-- loc.path must be set if returning true