1
0
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:
devin
2014-07-30 22:16:32 +00:00
parent 0e24910267
commit e441e2a81d

View File

@@ -4,7 +4,8 @@ local stdnse = require "stdnse"
local string = require "string"
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"
@@ -42,12 +43,10 @@ categories = {"default", "discovery", "safe"}
-- + improve redirect pattern
-- + update documentation
-- + add changelog
-- 2014-07-29 Fabian Affolter <fabian@affolter-engineering.ch>:
-- + update generator pattern
-- TODO:
-- more generic generator pattern
-- helper function
-- Helper function
local follow_redirects = function(host, port, path, n)
local pattern = "^[hH][tT][tT][pP]/1.[01] 30[12]"
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
-- 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)
return string.format("[%s%s]", string.lower(c),
string.upper(c))