Save a request when running banner against unknown services

This commit is contained in:
dmiller 2015-02-12 20:04:28 +00:00
parent b26bf922bd
commit 430f8a1f13

View file

@ -2,6 +2,7 @@ local comm = require "comm"
local nmap = require "nmap"
local stdnse = require "stdnse"
local table = require "table"
local U = require "lpeg-utility"
description = [[
A simple banner grabber which connects to an open TCP port and prints out anything sent by the listening service within five seconds.
@ -61,6 +62,13 @@ end
-- @param port Port Table.
-- @return String or nil if data was not received.
function grab_banner(host, port)
-- Did the service engine already do the hard work?
if port.version and port.version.service_fp then
local response = U.get_response(port.version.service_fp, "NULL")
if response then
return response:match("^%s*(.-)%s*$");
end
end
local opts = {}
opts.timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout"))