SQL Injection is a critical web security vulnerability that allows attackers to interfere with the queries that an application makes to its database. It can allow attackers to view data that they are not normally able to retrieve, and sometimes it can be used to gain unauthorized access to the underlying system. This project will teach you how to identify and exploit SQL Injection vulnerabilities using Burp Suite and DVWA (Damn Vulnerable Web Application).
- Basic understanding of web application concepts and the HTTP protocol.
- Familiarity with SQL queries and databases.
- A working installation of DVWA and Burp Suite Community Edition.
-
Install XAMPP:
- Download XAMPP from Apache Friends and install it.
- Start the Apache and MySQL services from the XAMPP control panel.
-
Install DVWA:
- Download DVWA from GitHub.
- Extract the DVWA files into the
htdocs
directory of your XAMPP installation (e.g.,C:\xampp\htdocs\DVWA
).
-
Configure DVWA:
- Open
config
directory inside DVWA (C:\xampp\htdocs\DVWA\config
) and renameconfig.inc.php.dist
toconfig.inc.php
. - Edit
config.inc.php
and set the following database configurations:$_DVWA['db_user'] = 'root'; $_DVWA['db_password'] = ''; $_DVWA['db_database'] = 'dvwa';
- Open
-
Set up the DVWA Database:
- Open a web browser and navigate to
http://localhost/DVWA/setup.php
. - Click on the "Create / Reset Database" button to set up the database.
- Log in to DVWA with the default credentials:
Username: admin Password: password
- Open a web browser and navigate to
-
Download and Install Burp Suite:
- Download Burp Suite Community Edition from PortSwigger and install it.
-
Configure Burp Suite with your Browser:
- Open Burp Suite and go to the "Proxy" tab.
- Click on "Intercept is on" button to toggle interception off.
- Go to "Options" sub-tab and ensure the proxy listener is running on 127.0.0.1:8080.
- Configure your web browser to use Burp Suite as a proxy (set the proxy server to 127.0.0.1 and port 8080).
-
Set DVWA Security Level to Low:
- Log in to DVWA and go to the "DVWA Security" section.
- Set the security level to "Low" and click "Submit".
-
Navigate to SQL Injection Section:
- Go to the "SQL Injection" section in DVWA.
-
Intercept the Request with Burp Suite:
- In your browser, enter a user ID (e.g.,
1
) and click "Submit". - Burp Suite will intercept the request. Forward the request to see the result.
- In your browser, enter a user ID (e.g.,
-
Modify the Request to Exploit SQL Injection:
- Intercept the request again and modify the
id
parameter to an SQL Injection payload (e.g.,1' OR '1'='1
). - Forward the modified request and observe the response.
- Intercept the request again and modify the
-
Initial Request Interception:
- Request intercepted by Burp Suite:
GET /vulnerabilities/sqli/?id=1&Submit=Submit HTTP/1.1 Host: localhost
- Request intercepted by Burp Suite:
-
Modified Request with SQL Injection:
- Modify the intercepted request:
GET /vulnerabilities/sqli/?id=1' OR '1'='1&Submit=Submit HTTP/1.1 Host: localhost
- Expected output: The response should return all users in the database instead of just the one with ID
1
.
- Modify the intercepted request:
-
Crafting SQL Injection Payloads:
- Use payloads to extract database information. For example, to list database tables:
GET /vulnerabilities/sqli/?id=1' UNION SELECT table_name, null FROM information_schema.tables WHERE table_schema=database()-- -&Submit=Submit HTTP/1.1
- Use payloads to extract database information. For example, to list database tables:
-
Expected Output:
- The response should list the table names in the current database.
-
Implementing Input Validation and Parameterized Queries:
- Modify the application code (if you have access) to use prepared statements and input validation.
-
Testing the Mitigation:
- After applying the mitigation, repeat the SQL Injection attempts and ensure they are no longer successful.
By completing these exercises, you will gain hands-on experience in identifying and exploiting SQL Injection vulnerabilities using Burp Suite and DVWA. Additionally, you will understand the importance of proper input validation and parameterized queries in preventing SQL Injection attacks.