This article is a practical walkthrough of SQL injection exploitation using DVWA at multiple security levels, progressing from manual union-based injection to filter bypass techniques to automated SQLmap. It demonstrates the complete methodology for extracting database credentials through a seven-step injection workflow, then shows how different security implementations attempt to block the attack and how to circumvent them. The material matters because SQL injection remains prevalent in real applications, and understanding manual exploitation before using automation tools builds the foundational skills necessary to adapt when standard techniques fail.
- Union-based injection seven-step workflowThe article details a methodical progression: (1) confirm injection with a single quote to trigger SQL error, (2) use ORDER BY to determine column count, (3) test UNION SELECT with matching columns to identify displayable fields, (4) query database metadata (database name and version), (5) enumerate table names via information_schema.tables, (6) enumerate column names via information_schema.columns, and (7) dump target credentials. This identical methodology applies across different database engines and real-world applications once adapted for their specific structure.
- Information_schema enables database reconnaissanceThe article explains that information_schema is a metadata database present in all MySQL installations that contains the structural information of every other database. By querying information_schema.tables and information_schema.columns, an attacker can enumerate the complete database structure before targeting specific data—a critical advantage because you must know the exact table and column names to construct a valid injection payload.
- Numeric injection bypasses quote-escaping filtersAt DVWA Medium security, mysql_real_escape_string() escapes single quotes, blocking quote-based injection. However, since the user_id parameter is numeric, the underlying query uses numeric comparison without quotes: WHERE user_id = $id. An attacker bypasses quote-escaping entirely by injecting directly into the numeric field (id=1 UNION SELECT user,password FROM users--+) because no quotes are involved in the query structure at all.
- Comment syntax variations defeat comment filtersHigh security blocks the -- comment sequence but does not block the # character, which also comments remaining query text in MySQL. The article demonstrates that 1' UNION SELECT user,password FROM users# successfully closes the injected SELECT while bypassing the -- filter. More broadly, filters blocking specific comment styles fail because multiple valid comment syntaxes exist across SQL dialects.
- Manual injection confirms vulnerability typeThe article emphasizes that manual injection testing before running SQLmap reveals the specific injection class (union-based, boolean-blind, time-based) and establishes whether query results are reflected in page output. The author notes that automated tools can miss certain vulnerability types—providing an example of a junior tester whose SQLmap missed a time-based blind injection that manual testing found in minutes, illustrating why understanding the injection mechanism prevents false negatives.
- Prepared statements make injection structurally impossibleDVWA's Impossible level uses PDO with parameterised queries where PDO::PARAM_INT binding forces the database driver to cast input to an integer before query construction. Any SQL syntax in the input is treated as a literal integer value (evaluating to 0 or 1), returning no results. This is fundamentally different from blacklist filtering because it separates query structure from user data at the driver level, making SQL injection impossible rather than attempting to detect and block it.
- Blind injection extraction works via boolean or timingWhen query results are not reflected in page output, boolean-based blind injection tests whether conditions are true or false by observing page response differences, extracting data one bit at a time. Time-based blind injection uses SLEEP() commands that only execute on true conditions, causing measurable response delays that indicate a true condition. The article provides example payloads: 1' AND SUBSTRING(database(),1,1)='d'--+ for boolean extraction and 1' AND IF(SUBSTRING(database(),1,1)='d',SLEEP(5),0)--+ for time-based extraction.
- SQLmap workflow with Burp request filesThe article demonstrates capturing a complete HTTP request in Burp Suite and saving it as a file, then using sqlmap -r dvwa_sqli.txt to preserve cookies and headers. The workflow progresses from --dbs to enumerate databases, then -D dvwa --tables to list tables, then -D dvwa -T users --dump to extract credentials. SQLmap automatically cracks common hash formats like MD5 using built-in wordlists, producing identical results to manual injection but in seconds.
Bottom line: Learning manual SQL injection through the seven-step union methodology before using automated tools builds genuine understanding of how the vulnerability works and why filters fail—this foundation enables you to adapt when standard techniques are blocked and to recognize injection types that automation tools might miss. The article demonstrates that SQL injection is fundamentally about understanding query structure and metadata availability, not memorizing tool commands.
🎯 What You’ll Master in Lab 7
⏱️ 60 min read · 3 hands-on exercises
📊 What is your SQL injection experience level?
📋 What You’ll Master — DVWA SQL Injection Lab Complete Walkthrough
- Lab Setup — DVWA SQL Injection Module at All Security Levels
- DVWA SQL Injection Low — Error Detection to Full Database Dump
- Union Based SQL Injection — Extracting Tables, Columns and Credentials
- Medium and High Security — Filter Bypass Techniques
- SQLmap DVWA Automation — Verify Manual Findings With One Command
- How Parameterised Queries Fix SQL Injection — The Impossible Level Explained
SQL injection has been in the OWASP Top 10 for over a decade and remains one of the most prevalent vulnerabilities in real web applications. If you completed DVWA Lab 3 on command injection, you already understand the core principle of injection attacks — user input being interpreted as executable code rather than data. SQL injection applies this same principle to database queries. The full DVWA lab series covers each OWASP Top 10 category with hands-on exploitation and remediation analysis.
Lab Setup — DVWA SQL Injection Module at All Security Levels
DVWA SQL Injection Low — Error Detection to Full Database Dump
The DVWA SQL injection module presents a single input field: “User ID”. The application queries the database for a user with the matching ID and returns their first and last name. The underlying query looks like: SELECT first_name, last_name FROM users WHERE user_id = '$id'. The single quotes around $id — with no sanitisation — make this directly injectable.
⏱️ Time: 25 minutes · DVWA running, security level: Low
📸 Screenshot the final credential dump output showing usernames and hashes and share in #dvwa-labs on Discord. Tag #sqli2026
Union Based SQL Injection — Extracting Tables, Columns and Credentials
The union-based technique works because the original query returns exactly two columns (first_name and last_name) and both are displayed in the page response. Your UNION SELECT must match this exact column count, and the data types must be compatible. The key insight is that information_schema — a metadata database present in all MySQL installations — contains the structure of every other database, allowing you to enumerate tables and columns before targeting specific data.
Medium and High Security — Filter Bypass Techniques
⏱️ Time: 20 minutes · DVWA Medium then High security level
📸 Screenshot the Medium security bypass showing credential dump via numeric injection and share in #dvwa-labs on Discord.
SQLmap DVWA Automation — Verify Manual Findings With One Command
⏱️ Time: 15 minutes · DVWA Low security, Burp Suite running
📸 Screenshot the SQLmap –dump output showing cracked passwords and share in #dvwa-labs on Discord. Tag #sqlmap2026
Blind SQL Injection — When No Output Is Returned
DVWA’s SQL injection module is an in-band scenario — you can see query results directly on the page. Most real-world SQL injection is blind. The application is vulnerable, but it returns no query output in the response. You detect and exploit it through indirect signals: boolean differences in page content, or measurable time delays in server responses.
Boolean-based blind injection: You inject a condition that is either true or false and observe whether the page response changes. If 1' AND 1=1--+ returns the normal page and 1' AND 1=2--+ returns a different response (empty, error, or different content), the application is boolean-blind injectable. You extract data one bit at a time — asking questions like “is the first character of the database name greater than ‘M’?” — and the response tells you yes or no.
Time-based blind injection: When page content does not change between true and false conditions, you use time delays. Inject a condition that causes SLEEP(5) only when true. If the response takes 5 extra seconds, the condition was true. This is slower but works in all scenarios where boolean differences are invisible — including applications that always return the same page regardless of query result.
/dvwa/vulnerabilities/sqli_blind/ that is specifically designed to practice these techniques. After completing this lab, the blind module is the natural next step — same vulnerability class, but now without the luxury of seeing query results directly on the page.How Parameterised Queries Fix SQL Injection — The Impossible Level Explained
The Impossible security level in DVWA uses PDO with prepared statements. The query becomes: $data = $db->prepare('SELECT first_name, last_name FROM users WHERE user_id = (:id) LIMIT 1;'); followed by $data->bindParam(':id', $id, PDO::PARAM_INT);. The PDO::PARAM_INT binding means the database driver casts the input to an integer before it ever reaches the query. Any attempt to inject SQL syntax results in the entire input being treated as a literal integer — which evaluates to 0 or 1 and returns no matching user.
This is the fundamental distinction between blacklist filtering (which can always be bypassed) and parameterised queries (which cannot). Parameterised queries do not try to detect malicious input — they make SQL injection structurally impossible by separating the query structure from user-supplied data at the database driver level. Every developer working with SQL should understand this distinction — and now you do too.
🧠 QUICK CHECK — DVWA SQL Injection Lab
1' ORDER BY 3--+ and receive a MySQL error, but 1' ORDER BY 2--+ returns normal results. What has this determined?
📋 Commands Used Today — DVWA SQL Injection Reference Card
🏆 Mark Lab 7 as Complete
You have manually extracted a complete database from a vulnerable web application — the same technique used in some of the largest data breaches in history. Understanding it completely is essential for both offensive testing and defensive development.
❓ Frequently Asked Questions
What is the difference between error-based and union-based SQL injection?
Why do DVWA passwords appear as MD5 hashes?
When should I use SQLmap instead of manual injection?
What does the DVWA Impossible security level use to prevent SQL injection?
What comes after the SQL Injection lab in the DVWA series?
Can I practice SQL injection without DVWA?
Lab 6: DVWA File Upload Lab 2026
Lab 8: DVWA XSS Reflected Lab 2026
📚 Further Reading
- DVWA Command Injection Lab 2026 — Lab 3 covers OS command injection at all security levels — the injection technique that goes beyond databases to execute OS commands on the server.
- SQL Injection Complete Guide — The full SQL injection category covering error-based, boolean-blind, time-based, and out-of-band injection techniques beyond what DVWA covers.
- DVWA Lab Series Hub — The complete DVWA lab index with all 30 labs in sequence, covering every OWASP Top 10 category with step-by-step walkthroughs.
- PortSwigger SQL Injection Labs — The most comprehensive free SQL injection training available — 18 labs covering every injection type from basic retrieval to blind time-based attacks.
- OWASP SQL Injection Reference — The authoritative OWASP SQL injection documentation covering injection types, prevention techniques, and real-world case studies from major breaches.

