1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

NDMP fixes. Closes #930

This commit is contained in:
dmiller
2017-07-28 16:06:18 +00:00
parent ce86585b16
commit 9358ab0164
4 changed files with 31 additions and 7 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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)

View File

@@ -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