diff --git a/CHANGELOG b/CHANGELOG index e2ecc0fd7..ae10c330a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o [NSE][GH#930] Fix ndmp-version and ndmp-fs-info when scanning Veritas Backup + Exec Agent 15 or 16. [Andrew Orr] + o [NSE][GH#943] Added new SMB2/3 library and scripts: + smb-protocols discovers if a server supports dialects NT LM 0.12 (SMBv1), 2.02, 2.10, 3.00, 3.02 and 3.11. diff --git a/nselib/ndmp.lua b/nselib/ndmp.lua index e079f7ec8..5d7c84343 100644 --- a/nselib/ndmp.lua +++ b/nselib/ndmp.lua @@ -24,6 +24,11 @@ NDMP = { CONNECT_CLIENT_AUTH = 0x00000901, }, + -- Error types + ErrorType = { + NOT_AUTHORIZED_ERROR = 0x00000004 + }, + -- The fragment header, 4 bytes where the highest bit is used to determine -- whether the fragment is the last or not. FragmentHeader = { @@ -166,6 +171,10 @@ NDMP.Message.ConfigGetHostInfo = { msg.frag_header = NDMP.FragmentHeader.parse(data) data = data:sub(NDMP.FragmentHeader.size + 1) msg.header = NDMP.Header.parse(data) + if ( msg.header.error == NDMP.ErrorType.NOT_AUTHORIZED_ERROR ) then + -- no data to parse + return msg + end msg.data = data:sub(NDMP.Header.size + 1) msg.hostinfo = {} @@ -202,6 +211,10 @@ NDMP.Message.ConfigGetFsInfo = { msg.frag_header = NDMP.FragmentHeader.parse(data) data = data:sub(NDMP.FragmentHeader.size + 1) msg.header = NDMP.Header.parse(data) + if ( msg.header.error == NDMP.ErrorType.NOT_AUTHORIZED_ERROR ) then + -- no data to parse + return msg + end msg.data = data:sub(NDMP.Header.size + 1) local pos, err, count = bin.unpack(">II", msg.data) diff --git a/scripts/ndmp-fs-info.nse b/scripts/ndmp-fs-info.nse index 91ca57ebc..8ff6a9142 100644 --- a/scripts/ndmp-fs-info.nse +++ b/scripts/ndmp-fs-info.nse @@ -54,6 +54,7 @@ action = function(host, port) status, msg = helper:getFsInfo() if ( not(status) ) then return fail("Failed to get filesystem information from server") end + if ( msg.header.error == ndmp.NDMP.ErrorType.NOT_AUTHORIZED_ERROR ) then return fail("Not authorized to get filesystem information from server") end helper:close() local result = tab.new(3) diff --git a/scripts/ndmp-version.nse b/scripts/ndmp-version.nse index 53b177857..3384326b8 100644 --- a/scripts/ndmp-version.nse +++ b/scripts/ndmp-version.nse @@ -50,15 +50,22 @@ action = function(host, port) if ( not(status) ) then return fail("Failed to get server information from server") end helper:close() - local major, minor, build, smajor, sminor = hi.hostinfo.osver:match("Major Version=(%d+) Minor Version=(%d+) Build Number=(%d+) ServicePack Major=(%d+) ServicePack Minor=(%d+)") port.version.name = "ndmp" port.version.product = vendorLookup(si.serverinfo.vendor) - port.version.ostype = hi.hostinfo.ostype - if ( hi.hostinfo.hostname ) then - port.version.extrainfo = ("Name: %s; "):format(hi.hostinfo.hostname) - end - if ( major and minor and build and smajor and sminor ) then - port.version.extrainfo = port.version.extrainfo .. ("OS ver: %d.%d; OS Build: %d; OS Service Pack: %d"):format(major, minor, build, smajor) + + -- hostinfo can be nil if we get an auth error + if ( hi.hostinfo ) then + if ( hi.hostinfo.hostname ) then + port.version.extrainfo = ("Name: %s; "):format(hi.hostinfo.hostname) + end + + local major, minor, build, smajor, sminor = hi.hostinfo.osver:match("Major Version=(%d+) Minor Version=(%d+) Build Number=(%d+) ServicePack Major=(%d+) ServicePack Minor=(%d+)") + if ( major and minor and build and smajor and sminor ) then + port.version.extrainfo = port.version.extrainfo .. ("OS ver: %d.%d; OS Build: %d; OS Service Pack: %d"):format(major, minor, build, smajor) + end + + port.version.ostype = hi.hostinfo.ostype end + nmap.set_port_version(host, port) end