Skip to content

Commit e3e5c33

Browse files
committed
WIP commit of RDP scanner
1 parent 6793dd2 commit e3e5c33

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Auxiliary
7+
include Msf::Exploit::Remote::Tcp
8+
include Msf::Auxiliary::Scanner
9+
include Msf::Auxiliary::Report
10+
11+
def initialize(info = {})
12+
super(
13+
update_info(
14+
info,
15+
'Name' => 'Identify endpoints speaking the Remote Desktop Protocol (RDP)',
16+
'Description' => %q(
17+
This module attempts to connect to the specified Remote Desktop Protocol port
18+
and determines if it speaks RDP.
19+
),
20+
'Author' => 'Jon Hart <jon_hart[at]rapid7.com>',
21+
'References' =>
22+
[
23+
],
24+
'License' => MSF_LICENSE
25+
)
26+
)
27+
28+
register_options(
29+
[
30+
Opt::RPORT(3389)
31+
# XXX: add options to turn on/off TLS, CredSSP, early user, cookies, etc.
32+
]
33+
)
34+
end
35+
36+
# simple TPKT v3 + x.224 COTP Connect Request + RDP negotiation request with TLS and CredSSP requested
37+
RDP_PROBE = "\x03\x00\x00\x13\x0e\xe0\x00\x00\x00\x00\x00\x01\x00\x08\x00\x03\x00\x00\x00"
38+
# any TPKT v3 + x.2224 COTP Connect Confirm
39+
RDP_RE = /^\x03\x00.{3}\xd0.{7}.*$/
40+
def rdp?
41+
sock.put(RDP_PROBE)
42+
response = sock.get_once(-1)
43+
if response
44+
if RDP_RE.match?(response)
45+
# XXX: it might be helpful to decode the response and show what was selected.
46+
print_good("Identified RDP")
47+
return true
48+
else
49+
vprint_status("No match for '#{Rex::Text.to_hex_ascii(response)}'")
50+
end
51+
else
52+
vprint_status("No response")
53+
end
54+
end
55+
56+
def run_host(_ip)
57+
begin
58+
connect
59+
return unless rdp?
60+
rescue Rex::AddressInUse, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, \
61+
::Errno::ETIMEDOUT, ::Timeout::Error, ::EOFError => e
62+
vprint_error("error while connecting and negotiating RDP: #{e}")
63+
return
64+
ensure
65+
disconnect
66+
end
67+
68+
service = report_service(
69+
host: rhost,
70+
port: rport,
71+
proto: 'tcp',
72+
name: 'RDP'
73+
)
74+
end
75+
end

0 commit comments

Comments
 (0)