๐Ÿ’พ SQL Injection Simulator

Learn SQL Injection Safely

โš ๏ธ FOR EDUCATIONAL PURPOSES ONLY - DO NOT USE ON REAL SYSTEMS

๐Ÿ“š What is SQL Injection?

SQL Injection (SQLi) is a code injection technique where an attacker inserts malicious SQL code into application queries. This can allow attackers to:

Note: This is a pure frontend simulator. No real database is involved. The simulator shows what would happen if these queries were executed.

๐Ÿงช Mock Login Form

Query Analysis:

๐Ÿ’ก Try These SQL Injection Payloads

Enter these in the username or password field:

Authentication Bypass:
' OR '1'='1
Comment-based Bypass:
admin'--
OR with Comments:
' OR 1=1--
UNION Attack:
' UNION SELECT username, password FROM users--
Dangerous Query:
'; DROP TABLE users--

๐Ÿ” Understanding the Vulnerability

Vulnerable Code (Backend):

// โŒ VULNERABLE: String concatenation in SQL query
const query = "SELECT * FROM users WHERE username='" + username + "' AND password='" + password + "'";
db.execute(query);

The problem: User input is directly concatenated into the SQL query without sanitization, allowing attackers to modify the query logic.

Secure Code (Parameterized Query):

// โœ… SECURE: Using parameterized queries/prepared statements
const query = "SELECT * FROM users WHERE username=? AND password=?";
db.execute(query, [username, password]);

// โœ… SECURE: Using ORM (e.g., in Node.js with Sequelize)
User.findOne({ where: { username: username, password: password } });

๐ŸŽฏ How SQL Injection Works

When you enter: ' OR '1'='1 as username

The query becomes:

SELECT * FROM users WHERE username='' OR '1'='1' AND password='anything'

Since '1'='1' is always TRUE, the OR condition makes the entire WHERE clause TRUE, bypassing authentication and returning all users!

โš ๏ธ Real-World Impact

๐Ÿ”’ Prevention Techniques

๐Ÿ” Detection Tips