mirror of
https://github.com/nmap/nmap.git
synced 2026-01-03 05:09:14 +00:00
Change how ms-sql NSE scripts run
MS SQL NSE scripts run on database instances, which can be TCP or named pipes. With this change, all TCP instances on scanned ports will have script output attached under the port as a portrule script. Named pipe instances and TCP instances on unscanned ports will be displayed in the hostrule script output at the end of the host's output. Utility function mssql.Helper.InitScript makes it easy to write scripts that just work on a per-instance basis, without bothering where to put the output. Discovery will be done once per host, regardless of how many scripts are run, and can be guaranteed to be done before the script's action takes place.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
local os = require "os"
|
||||
local datetime = require "datetime"
|
||||
local mssql = require "mssql"
|
||||
local shortport = require "shortport"
|
||||
local stdnse = require "stdnse"
|
||||
local smbauth = require "smbauth"
|
||||
local string = require "string"
|
||||
@@ -46,9 +45,9 @@ author = "Justin Cacak"
|
||||
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
||||
categories = {"default", "discovery", "safe"}
|
||||
|
||||
portrule = shortport.port_or_service(1433, "ms-sql-s")
|
||||
dependencies = {"broadcast-ms-sql-discover"}
|
||||
|
||||
action = function(host, port)
|
||||
local do_action = function(host, port)
|
||||
|
||||
local output = stdnse.output_table()
|
||||
|
||||
@@ -127,3 +126,9 @@ action = function(host, port)
|
||||
return output
|
||||
|
||||
end
|
||||
|
||||
local function process_instance(instance)
|
||||
return do_action(instance.host, instance.port)
|
||||
end
|
||||
|
||||
action, portrule = mssql.Helper.InitScript(process_instance)
|
||||
|
||||
Reference in New Issue
Block a user