Lion Cipher Lab

Your first SQL queries: understand databases before you meet SQL injection

Why it matters

Almost every applied-security path eventually points you at a SQL-injection exercise, and almost none of them stop to make sure you can read a SQL query first. That is backwards. SQL injection is, at its core, a query that got built wrong — so the vulnerability is genuinely incomprehensible until you have written a few queries yourself and seen how they are put together. Databases also sit under nearly everything you will defend: web apps, logs, user accounts, asset inventories. Spend half an hour making a small table and asking it questions, and two things happen at once — the database stops…

What you'll learn

Steps in this lab

  1. What a database is, and why this comes before SQL injection
  2. Get a database engine with zero setup — it's already in Python
  3. Create a database file and a table (CREATE TABLE)
  4. Put a few rows in (INSERT INTO)
  5. Ask the table questions (SELECT, then filter with WHERE)
  6. The bridge: why building queries is step one to understanding SQL injection
  7. What you just built, and where it points

Open the full interactive lab →