mirror of
https://github.com/nmap/nmap.git
synced 2025-12-17 21:19:01 +00:00
Fix http.lua which ignores port.protocol and assumes it to be 'tcp' even if it is 'udp'.
Now http.request() returns nil if port.protocol is not 'tcp'. Changed the portrule in html-title.nse to accept only TCP ports. Fixed a redirect rule in html-title.nse which was comparing the string url.port with the number port.number - which would always be false.
This commit is contained in:
@@ -123,6 +123,10 @@ request = function( host, port, data, options )
|
|||||||
|
|
||||||
local protocol = 'tcp'
|
local protocol = 'tcp'
|
||||||
if type(port) == 'table' then
|
if type(port) == 'table' then
|
||||||
|
if port.protocol and port.protocol ~= 'tcp' then
|
||||||
|
stdnse.print_debug(1, "http.request() supports the TCP protocol only, your request to %s cannot be completed.", host)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
if port.service == 'https' or ( port.version and port.version.service_tunnel == 'ssl' ) then
|
if port.service == 'https' or ( port.version and port.version.service_tunnel == 'ssl' ) then
|
||||||
protocol = 'ssl'
|
protocol = 'ssl'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ local ipOps = require 'ipOps'
|
|||||||
local stdnse = require 'stdnse'
|
local stdnse = require 'stdnse'
|
||||||
|
|
||||||
portrule = function(host, port)
|
portrule = function(host, port)
|
||||||
if not (port.service == 'http' or port.service == 'https') then
|
if port.protocol ~= 'tcp' or not (port.service == 'http' or port.service == 'https') then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
-- Don't bother running on SSL ports if we don't have SSL.
|
-- Don't bother running on SSL ports if we don't have SSL.
|
||||||
@@ -123,7 +123,7 @@ function redirect_ok(url, host, port)
|
|||||||
function (loc, url, host, port)
|
function (loc, url, host, port)
|
||||||
-- if present, url.port must be the same as the scanned port
|
-- if present, url.port must be the same as the scanned port
|
||||||
-- loc.port must be set if returning true
|
-- loc.port must be set if returning true
|
||||||
if (not url.port) or url.port == port.number then
|
if (not url.port) or tonumber(url.port) == port.number then
|
||||||
loc.port = port
|
loc.port = port
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user