mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
Applied Fabian Affolter's patch to make generator entry more generic
This commit is contained in:
@@ -4,7 +4,8 @@ local stdnse = require "stdnse"
|
|||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Displays the contents of the "generator" meta tag of a web page (default: /) if there is one.
|
Displays the contents of the "generator" meta tag of a web page (default: /)
|
||||||
|
if there is one.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
author = "Michael Kohl"
|
author = "Michael Kohl"
|
||||||
@@ -42,12 +43,10 @@ categories = {"default", "discovery", "safe"}
|
|||||||
-- + improve redirect pattern
|
-- + improve redirect pattern
|
||||||
-- + update documentation
|
-- + update documentation
|
||||||
-- + add changelog
|
-- + add changelog
|
||||||
|
-- 2014-07-29 Fabian Affolter <fabian@affolter-engineering.ch>:
|
||||||
|
-- + update generator pattern
|
||||||
|
|
||||||
-- TODO:
|
-- Helper function
|
||||||
-- more generic generator pattern
|
|
||||||
|
|
||||||
|
|
||||||
-- helper function
|
|
||||||
local follow_redirects = function(host, port, path, n)
|
local follow_redirects = function(host, port, path, n)
|
||||||
local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]"
|
local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]"
|
||||||
local response = http.get(host, port, path)
|
local response = http.get(host, port, path)
|
||||||
@@ -69,9 +68,9 @@ action = function(host, port)
|
|||||||
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
||||||
|
|
||||||
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
||||||
local pattern = '<meta name="?generator"? content="([^\"]*)" ?/?>'
|
local pattern = '<meta name=[\"\']?generator[\"\']? content=[\"\']([^\"\']*)[\"\'] ?/?>'
|
||||||
|
|
||||||
-- make pattern case-insensitive
|
-- Make pattern case-insensitive
|
||||||
pattern = pattern:gsub("%a", function (c)
|
pattern = pattern:gsub("%a", function (c)
|
||||||
return string.format("[%s%s]", string.lower(c),
|
return string.format("[%s%s]", string.lower(c),
|
||||||
string.upper(c))
|
string.upper(c))
|
||||||
|
|||||||
Reference in New Issue
Block a user