mirror of
https://github.com/nmap/nmap.git
synced 2026-01-04 13:49:03 +00:00
Convert netbus-info to XML output
This commit is contained in:
@@ -50,6 +50,32 @@ and an smtp-server used for notification delivery.
|
||||
-- | Wave: 0
|
||||
-- | Synth: 0
|
||||
-- |_ Cd: 0
|
||||
-- @xmloutput
|
||||
-- <table key="ACL">
|
||||
-- <elem>127.0.0.1</elem>
|
||||
-- </table>
|
||||
-- <table key="APPLICATIONS">
|
||||
-- <elem>PuTTY Configuration</elem>
|
||||
-- </table>
|
||||
-- <table key="INFO">
|
||||
-- <elem key="Program Path">Z:\home\joeuser\Desktop\Patch.exe</elem>
|
||||
-- <elem key="Restart persistent">Yes</elem>
|
||||
-- <elem key="Login ID">joeuser</elem>
|
||||
-- <elem key="Clients connected to this host">1</elem>
|
||||
-- </table>
|
||||
-- <table key="SETUP">
|
||||
-- <elem key="TCP-port">12345</elem>
|
||||
-- <elem key="Log traffic">1</elem>
|
||||
-- <elem key="Password">password123</elem>
|
||||
-- <elem key="Notify to">admin@example.com</elem>
|
||||
-- <elem key="Notify from">spoofed@example.org</elem>
|
||||
-- <elem key="SMTP-server">smtp.example.net</elem>
|
||||
-- </table>
|
||||
-- <table key="VOLUME">
|
||||
-- <elem key="Wave">0</elem>
|
||||
-- <elem key="Synth">0</elem>
|
||||
-- <elem key="Cd">0</elem>
|
||||
-- </table>
|
||||
--
|
||||
-- @args netbus-info.password The password used for authentication
|
||||
|
||||
@@ -64,68 +90,63 @@ portrule = shortport.port_or_service (12345, "netbus", {"tcp"})
|
||||
|
||||
local function format_acl(acl)
|
||||
if acl == nil then
|
||||
return {}
|
||||
return nil
|
||||
end
|
||||
local payload = string.sub(acl, 9) --skip header
|
||||
local fields = stdnse.strsplit("|", payload)
|
||||
table.remove(fields, (# fields))
|
||||
fields["name"] = "ACL"
|
||||
return fields
|
||||
end
|
||||
|
||||
local function format_apps(apps)
|
||||
if apps == nil then
|
||||
return {}
|
||||
return nil
|
||||
end
|
||||
local payload = string.sub(apps, 10) --skip header
|
||||
local fields = stdnse.strsplit("|", payload)
|
||||
table.remove(fields, (# fields))
|
||||
fields["name"] = "APPLICATIONS"
|
||||
return fields
|
||||
end
|
||||
|
||||
local function format_info(info)
|
||||
if info == nil then
|
||||
return {}
|
||||
return nil
|
||||
end
|
||||
local payload = string.sub(info, 6) --skip header
|
||||
local fields = stdnse.strsplit("|", payload)
|
||||
fields["name"] = "INFO"
|
||||
return fields
|
||||
end
|
||||
|
||||
local function format_setup(setup)
|
||||
local formatted = {}
|
||||
if setup == nil then
|
||||
return formatted
|
||||
return nil
|
||||
end
|
||||
local fields = stdnse.strsplit(";", setup)
|
||||
if # fields < 7 then
|
||||
return formatted
|
||||
return nil
|
||||
end
|
||||
formatted["name"] = "SETUP"
|
||||
table.insert(formatted, string.format("TCP-port: %s", fields[2]))
|
||||
table.insert(formatted, string.format("Log traffic: %s", fields[3]))
|
||||
table.insert(formatted, string.format("Password: %s", fields[4]))
|
||||
table.insert(formatted, string.format("Notify to: %s", fields[5]))
|
||||
table.insert(formatted, string.format("Notify from: %s", fields[6]))
|
||||
table.insert(formatted, string.format("SMTP-server: %s", fields[7]))
|
||||
local formatted = stdnse.output_table()
|
||||
formatted["TCP-port"] = fields[2]
|
||||
formatted["Log traffic"] = fields[3]
|
||||
formatted["Password"] = fields[4]
|
||||
formatted["Notify to"] = fields[5]
|
||||
formatted["Notify from"] = fields[6]
|
||||
formatted["SMTP-server"] = fields[7]
|
||||
return formatted
|
||||
end
|
||||
|
||||
local function format_volume(volume)
|
||||
local formatted = {}
|
||||
if volume == nil then
|
||||
return formatted
|
||||
return nil
|
||||
end
|
||||
local fields = stdnse.strsplit(";", volume)
|
||||
if # fields < 4 then
|
||||
return formatted
|
||||
return nil
|
||||
end
|
||||
formatted["name"] = "VOLUME"
|
||||
table.insert(formatted, string.format("Wave: %s", fields[2]))
|
||||
table.insert(formatted, string.format("Synth: %s", fields[3]))
|
||||
table.insert(formatted, string.format("Cd: %s", fields[4]))
|
||||
local formatted = stdnse.output_table()
|
||||
formatted["Wave"] = fields[2]
|
||||
formatted["Synth"] = fields[3]
|
||||
formatted["Cd"] = fields[4]
|
||||
return formatted
|
||||
end
|
||||
|
||||
@@ -161,14 +182,14 @@ action = function( host, port )
|
||||
local volume = buffer()
|
||||
socket:close()
|
||||
|
||||
local response = {}
|
||||
table.insert(response, format_acl(acl))
|
||||
table.insert(response, format_apps(apps))
|
||||
table.insert(response, format_info(info))
|
||||
table.insert(response, format_setup(setup))
|
||||
table.insert(response, format_volume(volume))
|
||||
local response = stdnse.output_table()
|
||||
response["ACL"] = format_acl(acl)
|
||||
response["APPLICATIONS"] = format_apps(apps)
|
||||
response["INFO"] = format_info(info)
|
||||
response["SETUP"] = format_setup(setup)
|
||||
response["VOLUME"] = format_volume(volume)
|
||||
|
||||
return stdnse.format_output(true, response)
|
||||
return response
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user