SQL Injection Demonstration – Summary

Listen to this Post

1️⃣ Set Up DVWA – Deploy the vulnerable web application and log in.
2️⃣ Set Security Level to Low – Adjust security settings to make SQL injection possible.
3️⃣ Perform SQL Injection – Enter a malicious SQL payload in the login field to bypass authentication.
4️⃣ Automate with SQLMap – Use an automated tool to scan for and exploit SQL injection vulnerabilities.
5️⃣ Conclusion – SQL injection occurs due to poor input validation. Prevent it with secure coding practices like parameterized queries.

You Should Know:

1. Setting Up DVWA (Damn Vulnerable Web Application):

  • Download and install DVWA on your local machine or server.
  • Use the following commands to set up DVWA on a Linux system:
    git clone https://github.com/digininja/DVWA.git
    cd DVWA
    sudo apt-get install apache2 mysql-server php libapache2-mod-php php-mysql
    sudo cp config/config.inc.php.dist config/config.inc.php
    sudo service apache2 restart
    sudo service mysql restart
    
  • Access DVWA via your browser: `http://localhost/DVWA`.

2. Setting Security Level to Low:

  • Log in to DVWA with the default credentials (admin/password).
  • Navigate to `DVWA Security` and set the security level to low.

3. Performing SQL Injection:

  • Go to the `SQL Injection` section in DVWA.
  • Enter the following payload in the input field to bypass authentication:
    ' OR '1'='1
    
  • This payload exploits poor input validation to gain unauthorized access.

4. Automating with SQLMap:

  • Use SQLMap to automate the detection and exploitation of SQL injection vulnerabilities.
  • Run the following command to scan for vulnerabilities:
    sqlmap -u "http://localhost/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie="security=low; PHPSESSID=your_session_id"
    
  • SQLMap will identify and exploit the vulnerability, providing detailed results.

5. Preventing SQL Injection: