SQL Injection (SQLi) - Complete Notes

Table of Contents

  • Tooling & Fuzzing

  • Login Bypass Payloads

  • SQLi Filtering Bypass

  • Discovery Workflow (OffSec Flow)

  • Database Fingerprinting

  • Enumeration — Schemas / Databases

  • Enumeration — Tables

  • Enumeration — Columns

  • Data Extraction / Dumping

  • File Read with LOAD_FILE

  • File Write & RCE via SELECT INTO OUTFILE (MySQL)

  • MSSQL — xp_cmdshell RCE

  • References

Tooling & Fuzzing

wfuzz Login Parameter Fuzzing

Useful Wordlists

More Payloads:

https://github.com/payloadbox/sql-injection-payload-list

https://portswigger.net/web-security/sql-injection/cheat-sheetarrow-up-right

Classic Bypass

Comment Variations

In-line Query Bypass (useful for blind/in-band checks)

SQLi Filtering Bypass

When standard OR is filtered, try the pipe (||) operator:

Retrieve All Data (GET parameter example)

Discovery Workflow (OffSec Flow)

This is the step-by-step approach for manual UNION-based SQLi enumeration.

Step 1 : Find the Number of Columns

Use ORDER BY incrementing until an error occurs, then drop back one:

  • Also works with Union

Step 2 : Identify Which Columns Are Displayed

Replace NULLs with string markers. If you know there are 5 columns:

Or with numeric markers:

Watch the page output : whichever values appear tell you which column positions are reflected.

Step 3 : Enumerate DB Name, User, Version

Step 4 : Enumerate Tables

Step 5 : Dump Target Table

Database Fingerprinting

Use these to identify which database is running when you don't know yet.

Enumeration - Schemas / Databases

Enumeration — Tables

By Database Type

Targeted / Multi-column Examples

Enumeration — Columns

Multi-column Examples

Data Extraction / Dumping

Concatenation (useful when only 1 column reflects)

Specific Target (password for admin)

File Read with LOAD_FILE

File Read with LOAD_FILE

Check Privileges First

Read Files

Hex-Encode Output (bypass filters / display issues)

File Write & RCE via SELECT INTO OUTFILE (MySQL)

Requirements : The file path must be writable by the OS user running the MySQL process (usually mysql or www-data).

Check Write Access

Write a PHP Web Shell

Trigger the Web Shell

Write to Other Locations

Split Write (bypass WAF / length restrictions)

Test Write (verify shell landed)

Execute OS Commands via UDF

MSSQL — xp_cmdshell RCE

Reference: https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MSSQL%20Injection.mdarrow-up-right

💡 Also check HTB Multimaster walkthrough (OSCP+ prep) for full exploitation flow.

Capture NetNTLM Hash via UNC Path (Responder)

Set up Responder on your end:

Enable xp_cmdshell (requires DBA/sysadmin)

Connect with impacket-mssqlclient:

Then enable::

One-Liner Enable + Execute (Inject into SQL parameter)

PowerShell Reverse Shell via xp_cmdshell

Simple PowerShell TCP reverse shell:

  • Base64-encoded payload (avoids quote escaping issues):

💡 Generate your base64 payload with:

  • Set up listener before executing:

References:

Resource
Link

Payload SQLi List

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection

PortSwigger Cheat Sheet

https://portswigger.net/web-security/sql-injection/cheat-sheet

PayloadsAllTheThings MSSQL

https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MSSQL%20Injection.md

SecLists SQLi Wordlists

/usr/share/seclists/Fuzzing/Databases/SQLi/

HTB Multimaster (IppSec/0xdf)

Search ippsec multimaster

HTB Stream IO

https://0xdf.gitlab.io/2022/09/17/htb-streamio.html

OSCP+ Notion Notes

N/A