mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
o Updated showHTMLTitle NSE script to follow one HTTP redirect if
necessary as long as it is on the same server. [Jah]
This commit is contained in:
parent
b3fc32e7a4
commit
6d52a3db77
2 changed files with 13 additions and 1 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue