mirror of
https://github.com/nmap/nmap.git
synced 2025-12-23 16:09:02 +00:00
Reindent some scripts. Whitespace only.
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
@@ -61,54 +61,54 @@ prerule = function() return true end
|
||||
-- converted to Yes/No; if the value is nil, nothing is added to the table.
|
||||
local function add_to_output_table( outputTable, outputLabel, outputData )
|
||||
|
||||
if outputData ~= nil then
|
||||
if outputData == true then
|
||||
outputData = "Yes"
|
||||
elseif outputData == false then
|
||||
outputData = "No"
|
||||
end
|
||||
if outputData ~= nil then
|
||||
if outputData == true then
|
||||
outputData = "Yes"
|
||||
elseif outputData == false then
|
||||
outputData = "No"
|
||||
end
|
||||
|
||||
table.insert(outputTable, string.format( "%s: %s", outputLabel, outputData ) )
|
||||
end
|
||||
table.insert(outputTable, string.format( "%s: %s", outputLabel, outputData ) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Returns formatted output for the given instance
|
||||
local function create_instance_output_table( instance )
|
||||
|
||||
local instanceOutput = {}
|
||||
local instanceOutput = {}
|
||||
|
||||
instanceOutput["name"] = string.format( "[%s]", instance:GetName() )
|
||||
add_to_output_table( instanceOutput, "Name", instance.instanceName )
|
||||
if instance.version then add_to_output_table( instanceOutput, "Product", instance.version.productName ) end
|
||||
if instance.port then add_to_output_table( instanceOutput, "TCP port", instance.port.number ) end
|
||||
add_to_output_table( instanceOutput, "Named pipe", instance.pipeName )
|
||||
instanceOutput["name"] = string.format( "[%s]", instance:GetName() )
|
||||
add_to_output_table( instanceOutput, "Name", instance.instanceName )
|
||||
if instance.version then add_to_output_table( instanceOutput, "Product", instance.version.productName ) end
|
||||
if instance.port then add_to_output_table( instanceOutput, "TCP port", instance.port.number ) end
|
||||
add_to_output_table( instanceOutput, "Named pipe", instance.pipeName )
|
||||
|
||||
return instanceOutput
|
||||
return instanceOutput
|
||||
|
||||
end
|
||||
|
||||
action = function()
|
||||
|
||||
local host = { ip = "255.255.255.255" }
|
||||
local port = { number = 1434, protocol = "udp" }
|
||||
local host = { ip = "255.255.255.255" }
|
||||
local port = { number = 1434, protocol = "udp" }
|
||||
|
||||
local status, result = mssql.Helper.DiscoverBySsrp(host, port, true)
|
||||
if ( not(status) ) then return end
|
||||
local status, result = mssql.Helper.DiscoverBySsrp(host, port, true)
|
||||
if ( not(status) ) then return end
|
||||
|
||||
local scriptOutput = {}
|
||||
for ip, instanceList in pairs(result) do
|
||||
local serverOutput, serverName = {}, nil
|
||||
target.add( ip )
|
||||
for _, instance in ipairs( instanceList ) do
|
||||
serverName = serverName or instance.serverName
|
||||
local instanceOutput = create_instance_output_table( instance )
|
||||
table.insert(serverOutput, instanceOutput)
|
||||
end
|
||||
serverOutput.name = string.format( "%s (%s)", ip, serverName )
|
||||
table.insert( scriptOutput, serverOutput )
|
||||
end
|
||||
local scriptOutput = {}
|
||||
for ip, instanceList in pairs(result) do
|
||||
local serverOutput, serverName = {}, nil
|
||||
target.add( ip )
|
||||
for _, instance in ipairs( instanceList ) do
|
||||
serverName = serverName or instance.serverName
|
||||
local instanceOutput = create_instance_output_table( instance )
|
||||
table.insert(serverOutput, instanceOutput)
|
||||
end
|
||||
serverOutput.name = string.format( "%s (%s)", ip, serverName )
|
||||
table.insert( scriptOutput, serverOutput )
|
||||
end
|
||||
|
||||
return stdnse.format_output( true, scriptOutput )
|
||||
return stdnse.format_output( true, scriptOutput )
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user