githubEdit

SQL Injection & XSS Playground

This is my playground for SQL injection and XSS

Classic SQL Injection

SQL injection overview

What is it?

SQL injection is where an attacker is able to manipulate database queries made by an application.

A simple example

  • A vulnerable web application has the endpoint /search?product={productName}

  • When a request is made, the application uses SQL to search for the product SELECT * FROM products WHERE name=$productName

  • If an attacker inserts a payload into {productName} such as anything' UNION SELECT password FROM users WHERE username = 'admin that modifies the query, sensitive data could be leaked.

  • The vulnerable application sends this query to the database and the database returns the admin's password.

It's important to note that a payload or attack may change depending on the application, the query, and the database. SQL injection can often lead to:

  • Sensitive data exposure

  • Data manipulation

  • Remote code execution

  • Denial of service

Other learning resources:

Writeups:

Have a good writeup & want to share it here? Drop me a message on LinkedIn.

Checklist

Exploitation

SQL Injection & XSS Playground

Classic SQL Injection

Union Select Data Extraction

Authentication Bypass

Second Order Injection

Dropping a Backdoor

Conditional Select

Bypassing Whitespace Filtering

Time Based SQL Injection

Sleep Invokation

XSS

Strtoupper Bypass

Say we have the following PHP code that takes name as a user supplied parameter:

Line 3 is vulnerable to XSS, and we can break out of the input with a single quote ':

For example, if we set the name parameter to the value of a', we get:

Note that the a got converted to a capital A and this is due to the strtoupper function being called on our input. What this means is that any ascii letters in our JavaScript payload will get converted to uppercase and become invalid and will not execute (i.ealert() != ALERT()).

To bypass this constraint, we can encode our payload using JsFuck, which eliminates all the letters from the payload and leaves us with this:

References

Last updated