1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-21 23:19:03 +00:00

Structured output for nat-pmp-info, sip-methods, smb-security-mode

This commit is contained in:
dmiller
2014-09-04 18:35:20 +00:00
parent adc213d536
commit b913b23d58
3 changed files with 66 additions and 19 deletions

View File

@@ -20,6 +20,11 @@ The NAT-PMP protocol is supported by a broad range of routers including:
--- ---
--@usage --@usage
-- nmap -sU -p 5351 --script=nat-pmp-info <target> -- nmap -sU -p 5351 --script=nat-pmp-info <target>
-- @output
-- | nat-pmp-info:
-- |_ WAN IP: 192.0.2.13
-- @xmloutput
-- <elem key="WAN IP">192.0.2.13</elem>
author = "Patrik Karlsson" author = "Patrik Karlsson"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
@@ -37,6 +42,6 @@ action = function(host, port)
port.version.name = "nat-pmp" port.version.name = "nat-pmp"
nmap.set_port_version(host, port) nmap.set_port_version(host, port)
return stdnse.format_output(true, ("WAN IP: %s"):format(response.ip)) return {["WAN IP"] = response.ip}
end end
end end

View File

@@ -19,6 +19,17 @@ the value of the Allow header in the response.
-- 5060/udp open sip -- 5060/udp open sip
-- | sip-methods: -- | sip-methods:
-- |_ INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO -- |_ INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
--
-- @xmloutput
-- <elem>INVITE</elem>
-- <elem>ACK</elem>
-- <elem>CANCEL</elem>
-- <elem>OPTIONS</elem>
-- <elem>BYE</elem>
-- <elem>REFER</elem>
-- <elem>SUBSCRIBE</elem>
-- <elem>NOTIFY</elem>
-- <elem>INFO</elem>
author = "Hani Benhabiles" author = "Hani Benhabiles"
@@ -48,7 +59,7 @@ action = function(host, port)
-- Check if allow header exists in response -- Check if allow header exists in response
local allow = response:getHeader("allow") local allow = response:getHeader("allow")
if allow then if allow then
return stdnse.format_output(true, allow) return stdnse.strsplit(",%s*", allow), allow
end end
end end
end end

View File

@@ -47,13 +47,18 @@ them.
-- sudo nmap -sU -sS --script smb-security-mode.nse -p U:137,T:139 127.0.0.1 -- sudo nmap -sU -sS --script smb-security-mode.nse -p U:137,T:139 127.0.0.1
-- --
--@output --@output
-- Host script results: -- | smb-security-mode:
-- | smb-security-mode: -- | account_used: guest
-- | | Account that was used for smb scripts: administrator -- | authentication_level: user
-- | | User-level authentication -- | challenge_response: supported
-- | | SMB Security: Challenge/response passwords supported -- |_ message_signing: disabled (dangerous, but default)
-- |_ |_ Message signing disabled (dangerous, but default) --
----------------------------------------------------------------------- --@xmloutput
-- <elem key="account_used">guest</elem>
-- <elem key="authentication_level">user</elem>
-- <elem key="challenge_response">supported</elem>
-- <elem key="message_signing">disabled</elem>
--
author = "Ron Bowes" author = "Ron Bowes"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
@@ -66,6 +71,19 @@ hostrule = function(host)
return smb.get_port(host) ~= nil return smb.get_port(host) ~= nil
end end
local function label_warnings (t, w)
local out = {}
for k, v in pairs(t) do
local warn = w[k]
if warn then
warn = string.format(" (%s)", warn)
else
warn = ""
end
out[#out+1] = string.format("\n %s: %s%s", k, v, warn)
end
return table.concat(out)
end
action = function(host) action = function(host)
@@ -86,38 +104,51 @@ action = function(host)
local security_mode = state['security_mode'] local security_mode = state['security_mode']
local response = {} local response = stdnse.output_table()
local result, username, domain = smb.get_account(host) local result, username, domain = smb.get_account(host)
if(result ~= false) then if(result ~= false) then
table.insert(response, string.format("Account that was used for smb scripts: %s%s", domain, stdnse.string_or_blank(username, '<blank>'))) if domain and domain ~= "" then
domain = domain .. "\\"
end
response.account_used = string.format("%s%s", domain, stdnse.string_or_blank(username, '<blank>'))
end end
local warnings = {}
-- User-level authentication or share-level authentication -- User-level authentication or share-level authentication
if(bit.band(security_mode, 1) == 1) then if(bit.band(security_mode, 1) == 1) then
table.insert(response, "User-level authentication") response.authentication_level = "user"
else else
table.insert(response, "Share-level authentication (dangerous)") response.authentication_level = "share"
warnings.authentication_level = "dangerous"
end end
-- Challenge/response supported? -- Challenge/response supported?
if(bit.band(security_mode, 2) == 0) then if(bit.band(security_mode, 2) == 0) then
table.insert(response, "Plaintext passwords required (dangerous)") response.challenge_response = "plaintext-only"
warnings.challenge_response = "dangerous"
else else
table.insert(response, "SMB Security: Challenge/response passwords supported") response.challenge_response = "supported"
end end
-- Message signing supported/required? -- Message signing supported/required?
if(bit.band(security_mode, 8) == 8) then if(bit.band(security_mode, 8) == 8) then
table.insert(response, "Message signing required") response.message_signing = "required"
elseif(bit.band(security_mode, 4) == 4) then elseif(bit.band(security_mode, 4) == 4) then
table.insert(response, "Message signing supported") response.message_signing = "supported"
else else
table.insert(response, "Message signing disabled (dangerous, but default)") response.message_signing = "disabled"
warnings.message_signing = "dangerous, but default"
end end
smb.stop(state) smb.stop(state)
return stdnse.format_output(true, response)
local rmeta = getmetatable(response)
rmeta.__tostring = function (t)
return label_warnings(t, warnings)
end
setmetatable(response, rmeta)
return response
end end