Skip to content

Commit 8680aa8

Browse files
committed
Landing rapid7#1857 - MS12-020 off-by-one fix
2 parents bfcd860 + d028f52 commit 8680aa8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

modules/auxiliary/scanner/rdp/ms12_020_check.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def check_rdp
5353
res = sock.get_once(-1, 5)
5454

5555
# return true if this matches our vulnerable response
56-
( res and res == "\x03\x00\x00\x0b\x06\xd0\x00\x00\x12\x34\x00" )
56+
( res and res.match("\x03\x00\x00\x0b\x06\xd0\x00\x00\x12\x34\x00") )
5757
end
5858

5959
def report_goods
@@ -121,16 +121,9 @@ def user_request
121121
"\x28" # PER encoded PDU contents
122122
end
123123

124-
def channel_request_one
124+
def channel_request
125125
"\x03\x00\x00\x0c" +
126-
"\x02\xf0\x80\x38" +
127-
"\x00\x01\x03\xeb"
128-
end
129-
130-
def channel_request_two
131-
"\x03\x00\x00\x0c" +
132-
"\x02\xf0\x80\x38" +
133-
"\x00\x02\x03\xeb"
126+
"\x02\xf0\x80\x38"
134127
end
135128

136129
def peer
@@ -143,6 +136,7 @@ def run_host(ip)
143136

144137
# check if rdp is open
145138
if not check_rdp
139+
vprint_status "#{peer} Could not connect to RDP."
146140
disconnect
147141
return
148142
end
@@ -153,18 +147,23 @@ def run_host(ip)
153147
# send userRequest
154148
sock.put(user_request)
155149
res = sock.get_once(-1, 5)
150+
user1 = res[9,2].unpack("n").first
151+
chan1 = user1 + 1001
156152

157153
# send 2nd userRequest
158154
sock.put(user_request)
159155
res = sock.get_once(-1, 5)
160156

157+
user2 = res[9,2].unpack("n").first
158+
chan2 = user2 + 1001
159+
161160
# send channel request one
162-
sock.put(channel_request_one)
161+
sock.put(channel_request << [user1, chan2].pack("nn"))
163162
res = sock.get_once(-1, 5)
164163

165-
if res and res[8,2] == "\x3e\x00"
164+
if res and res[7,2] == "\x3e\x00"
166165
# send ChannelRequestTwo - prevent BSoD
167-
sock.put(channel_request_two)
166+
sock.put(channel_request << [user2, chan2].pack("nn"))
168167

169168
print_good("#{peer} Vulnerable to MS12-020")
170169
report_goods

0 commit comments

Comments
 (0)