diff --git a/CHANGELOG b/CHANGELOG index 3fdae7802..bb65c412a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o Updated showHTMLTitle NSE script to follow one HTTP redirect if + necessary as long as it is on the same server. [Jah] + o Added a UDP SNMPv3 probe to version detection, along with 9 vendor match lines. [Tom Sellers] diff --git a/scripts/showHTMLTitle.nse b/scripts/showHTMLTitle.nse index bcc2ac03c..a02e6559e 100644 --- a/scripts/showHTMLTitle.nse +++ b/scripts/showHTMLTitle.nse @@ -12,6 +12,7 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = {"default", "demo", "safe"} require 'http' +require 'url' portrule = function(host, port) if not (port.service == 'http' or port.service == 'https') then @@ -29,6 +30,14 @@ action = function(host, port) local data, result, title, protocol data = http.get( host, port, '/' ) + -- follow ONE redirect if host is not some other host + if data.status == 301 or data.status == 302 then + local url = url.parse( data.header.location ) + if url.host == host.targetname or url.host == ( host.name ~= '' and host.name ) or url.host == host.ip then + stdnse.print_debug("showHTMLTitle.nse: Default page is located at " .. url.scheme.. "://" .. url.authority .. url.path) + data = http.get( host, port, url.path ) + end + end result = data.body -- watch out, this doesn't really work for all html tags @@ -38,7 +47,7 @@ action = function(host, port) if title ~= nil then result = string.gsub(title , "[\n\r\t]", "") - if string.len(title) > 50 then + if string.len(title) > 65 then stdnse.print_debug("showHTMLTitle.nse: Title got truncated!"); result = string.sub(result, 1, 62) .. "..." end