Skip to content

Commit 573ee28

Browse files
committed
Land rapid7#9378, Detect and return on bad VNC negotiations
2 parents f1bb3fe + 51e5fb4 commit 573ee28

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/rex/proto/rfb/client.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,30 @@ def negotiate_vnc_auth(password = nil)
215215

216216
def negotiate_ard_auth(username = nil, password = nil)
217217
generator = @sock.get_once(2)
218+
if not generator or generator.length != 2
219+
@error = "Unable to obtain ARD challenge: invalid generator value"
220+
return false
221+
end
218222
generator = generator.unpack("n").first
223+
219224
key_length = @sock.get_once(2)
225+
if not key_length or key_length.length != 2
226+
@error = "Unable to obtain ARD challenge: invalid key length"
227+
return false
228+
end
220229
key_length = key_length.unpack("n").first
230+
221231
prime_modulus = @sock.get_once(key_length)
232+
if not prime_modulus or prime_modulus.length != key_length
233+
@error = "Unable to obtain ARD challenge: invalid prime modulus"
234+
return false
235+
end
236+
222237
peer_public_key = @sock.get_once(key_length)
238+
if not peer_public_key or peer_public_key.length != key_length
239+
@error = "Unable to obtain ARD challenge: invalid public key"
240+
return false
241+
end
223242

224243
response = Cipher.encrypt_ard(username, password, generator, key_length, prime_modulus, peer_public_key)
225244
@sock.put(response)

modules/auxiliary/scanner/vnc/ard_root_pw.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def run_host(target_host)
8181
log_credential(password)
8282
return
8383
end
84+
else
85+
print_error("VNC handshake failed.")
86+
return
8487
end
8588
disconnect
8689

@@ -92,6 +95,9 @@ def run_host(target_host)
9295
log_credential(password)
9396
return
9497
end
98+
else
99+
print_error("VNC handshake failed.")
100+
return
95101
end
96102
disconnect
97103

@@ -103,6 +109,9 @@ def run_host(target_host)
103109
log_credential('')
104110
return
105111
end
112+
else
113+
print_error("VNC handshake failed.")
114+
return
106115
end
107116

108117
ensure

0 commit comments

Comments
 (0)