mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Save a request when running banner against unknown services
This commit is contained in:
parent
b26bf922bd
commit
430f8a1f13
1 changed files with 8 additions and 0 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue