Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cheat Sheet

Commands

CommandPurpose
py -m venv .venv (Win) / python3 -m venv .venv (Mac/Linux)Create virtual environment
.\.venv\Scripts\activate (Win) / source .venv/bin/activate (Mac/Linux)Activate virtual environment
pip install -r requirements.txtInstall dependencies
python init_db.pyInitialize database
python app.pyRun the web server
Ctrl+CStop the server
deactivateDeactivate virtual environment

Payloads (Only for this local lab)

PayloadUsername FieldPassword FieldResult
Normaladminsupersecret123Success (fixed)
Comment Outadmin' --anythingBypasses (vulnerable only)
Always True' OR '1'='1' --anythingBypases (vulnerable only)

Key Takeaway

# VULNERABLE
query = f"SELECT ... WHERE username = '{username}' ..."
cur.execute(query)

# SECURE
query = "SELECT ... WHERE username = ? AND password = ?"
cur.execute(query, (username, password))

Rule of thumb: If you ever find yourself using f-strings or string concatenation to build SQL with user input, stop and use parameterized queries instead.