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

Handle cases of no tunnels and no auth types for TightVNC

This commit is contained in:
dmiller
2017-03-15 16:19:54 +00:00
parent 772bd8d824
commit 8854d2e33a

View File

@@ -377,32 +377,42 @@ VNC = {
return false, "Failed to get number of tunnels" return false, "Failed to get number of tunnels"
end end
local pos, ntunnels = bin.unpack(">I", buf) local pos, ntunnels = bin.unpack(">I", buf)
local tight = {
tunnels = {},
types = {}
}
if ntunnels > 0 then
status, buf = self.socket:receive_buf(match.numbytes(16 * ntunnels), true) status, buf = self.socket:receive_buf(match.numbytes(16 * ntunnels), true)
if not status then if not status then
return false, "Failed to get list of tunnels" return false, "Failed to get list of tunnels"
end end
local have_none_tunnel = false
pos = 1 pos = 1
local tight = {
tunnels = {},
types = {}
}
for i=1, ntunnels do for i=1, ntunnels do
local tunnel = {} local tunnel = {}
pos, tunnel.code, tunnel.vendor, tunnel.signature = bin.unpack(">IA4A8", buf, pos) pos, tunnel.code, tunnel.vendor, tunnel.signature = bin.unpack(">IA4A8", buf, pos)
if tunnel.code == 0 then
have_none_tunnel = true
end
tight.tunnels[#tight.tunnels+1] = tunnel tight.tunnels[#tight.tunnels+1] = tunnel
end end
if ntunnels > 0 then if have_none_tunnel then
-- Try the "NOTUNNEL" tunnel, for simplicity, if it's available.
self.socket:send(bin.pack(">I", 0))
else
-- for now, just return the first one. TODO: choose a supported tunnel type -- for now, just return the first one. TODO: choose a supported tunnel type
self.socket:send(bin.pack(">I", tight.tunnels[1].code)) self.socket:send(bin.pack(">I", tight.tunnels[1].code))
end end
end
status, buf = self.socket:receive_buf(match.numbytes(4), true) status, buf = self.socket:receive_buf(match.numbytes(4), true)
if not status then if not status then
return false, "Failed to get number of Tight auth types" return false, "Failed to get number of Tight auth types"
end end
local pos, nauth = bin.unpack(">I", buf) local pos, nauth = bin.unpack(">I", buf)
if nauth > 0 then
status, buf = self.socket:receive_buf(match.numbytes(16 * nauth), true) status, buf = self.socket:receive_buf(match.numbytes(16 * nauth), true)
if not status then if not status then
return false, "Failed to get list of Tight auth types" return false, "Failed to get list of Tight auth types"
@@ -414,6 +424,7 @@ VNC = {
pos, auth.code, auth.vendor, auth.signature = bin.unpack(">IA4A8", buf, pos) pos, auth.code, auth.vendor, auth.signature = bin.unpack(">IA4A8", buf, pos)
tight.types[#tight.types+1] = auth tight.types[#tight.types+1] = auth
end end
end
self.tight = tight self.tight = tight