🚀
v13vv/GitBook
🚀
v13vv/GitBook
  • 🌌About this blog
  • The Author
    • v13vv
  • 2025
    • TryHackMe
    • HackTheBox
    • TheCyberMentor
    • PNPT
    • CPTS
    • AZ-500
  • 2024
    • CTFs
      • idekCTF 2024
        • misc/NM~~PZ~~ - easy
      • 🐭Bandit - OverTheWire
        • Bandit 0
        • Bandit 1 ( level 0->1 )
        • Bandit 2 ( level 1->2 )
        • Bandit 3 ( level 2->3 )
        • Bandit 4 ( level 3->4 )
        • Bandit 5 ( level 4->5 )
      • 🐯Natas - OverTheWire
        • Natas 0
        • Natas 1 ( level 0->1 )
        • Natas 2 ( level 1->2 )
        • Natas 3 ( level 2->3 )
    • Security+ Labs
      • ⛑️CompTIA Security+ - 101Labs.net
        • Lab 41 – Getting a reverse shell on a server through a file upload
        • Lab 42 – Manual privilege escalation using python
    • WEB SECURITY
      • 🍊Web Security Academy - PortSwigger
        • Burp Suite Setup on Kali Linux
        • Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
        • Lab: SQL injection vulnerability allowing login bypass
        • Lab: Reflected XSS into HTML context with nothing encoded
    • NETWORKING
      • 🌊Wireshark Labs - Jim Kurose Homepage
        • Getting Started
    • POST-QUANTUM CRYPTOGRAPHY
      • A Study of Algorithms Development for Post-Quantum Cryptography
        • NIST Post-Quantum Cryptography Standardization
          • Call for Proposals in Security Aspect
          • Status Report on the Third Round of the NIST Post-Quantum Cryptography Standardization Process
          • KEM / Digital Signature
            • Kyber
              • What is Kyber ?
                • Module Learning With Errors (M-LWE)
              • Kyber Cryptanalysis
                • Timing Attack
Powered by GitBook
On this page
  1. 2024
  2. WEB SECURITY
  3. Web Security Academy - PortSwigger

Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data

PreviousBurp Suite Setup on Kali LinuxNextLab: SQL injection vulnerability allowing login bypass

Last updated 9 months ago

This lab contains a vulnerability in the product category filter. When the user selects a category, the application carries out a SQL query like the following:

SELECT * FROM products WHERE category = 'Gifts' AND released = 1

To solve the lab, perform a SQL injection attack that causes the application to display one or more unreleased products.

Solving

First thing first, press the 'ACCESS THE LAB' button.

We got a website provided by PortSwigger.

Our task is that, we need to make this page show us its hidden products. and,

SELECT * FROM products WHERE category = 'Gifts' AND released = 1

The SQL Query above is the example condition of the displaying products right now. But the trick is that, if we just think and changed a bit of the query, we can easily break into it, or make it serves us as we want.

i.e. In this case we want the page to show us all of the hidden products from any categories. We could change the above query to:

SELECT * FROM products WHERE category = '' OR '1'='1' --AND released = 1

As you can see above, I removed the 'Gifts' in category, and added the OR '1'='1' -- in between the code before the AND part.

The concept of the code above:

  • We don't consider specific category.

  • OR '1'='1': 1 always equals to 1 means that this is a TRUE statement, and also TRUE OR <anything> equals to TRUE. This trick of query is beneficial to bypassing through most of the things. Edit: In our case: OR 1=1 always evaluates to true, so the WHERE clause is effectively bypassed, returning all rows.

  • --: The '--' works as a comment in sql query. Means that the query after the '--' won't be executed.

Enough of the theory, let's see on the practical attempt.

Okay, now we're going to try to exploit this web page.

1.) Change the proxy server to BURP SUITE. In my case, I'll just change it with my foxyproxy.

2.) In the burp suite, make sure to turn the "Intercept mode" on.

3.) Now let's try clicking one category on the web page. In this case, I'll click on "Accessories". Be ready to take a look at burp suite's event log.

As you can see here, this is the request log from the client to web server. On the first line you will see that it send GET /filter?category=Accessories to the webserver. This is where we'll be playing with.

We'll exploit the SQL injection into the web server as we'll change the request GET into:

GET /filter?category='+OR+1=1--

Now, click forward to see the response from the web server.

But it still unsolved yet. What did I do wrong ? [10 pts.]

.

.

.

Actually, I did solved it already. But I didn't forward all the way through to the end. As I tried clicking the the category again, it pops up that I solved the lab already. That's why I assume it was because of the forward.

Anyway, We solved it :)

🍊
SQL injection
Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data | Web Security AcademyWebSecAcademy
Logo
SOLVED !