用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Wyl-cmd/kxns-cli --skill js-secrets-extraction命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Hermes Agent features guide — cron, delegation, memory, automation, YOLO mode, dual-agent hunting, and slash commands for the agentiko Telegram setup
Worker container environment — tools, paths, and usage patterns for the remote SSH terminal
Exploit no-auth APIs for data theft and CRUD via probes.
基于 SOC 职业分类
正在显示 SKILL.md
| name | js-secrets-extraction |
| description | Analyze JS bundles and source maps for hardcoded secrets, API keys, JWTs, and internal endpoints |
| sources | field_ops, real_targets |
| report_count | 30+ |
Modern JavaScript bundles (Webpack, Vite, esbuild) often contain:
curl -s "https://target.com" > index.html
grep -oP 'src="[^"]*\.js"' index.html | cut -d'"' -f2 | while read js; do
curl -s "https://target.com$js" > "$(basename $js)"
done
# Search for secrets in bundles
grep -rPn "(apiKey|api_key|API_KEY|token|secret|password|clientId|client_id|auth0|firebase|supabase)[\"'\"]?\\s*[:=]\\s*[\"'\'][^\"'\']{8,}" *.js
curl -sI "https://target.com/assets/index-abc123.js.map"
curl -sI "https://target.com/static/js/main.12345.js.map"
# If HTTP 200, use for reconstruction:
# https://unminify.com
# https://source-map-visualization.netlify.app
Real-world case: Enterprise Angular SPA admin, 2 JS bundles (250KB each) exposed:
Modern deployments often serve the main SPA on port 443 and admin/API on separate ports (8080, 8081, 8084). Always check JS bundles on ALL discovered ports:
# Check source maps on every open port
for port in 443 8080 8081 8084; do
curl -sI "https://target.com:$port/static/js/main.*.js.map" 2>/dev/null
curl -sI "https://target.com:$port/assets/index-*.js.map" 2>/dev/null
done
Real-world case (target-health-saas.com, June 2026):
/static/js/main.a5a4e0fb.js.map (HTTP 200)https://target-health-saas.com:8081, auth services, dashboard APIs, pharmacy/drug/hospital componentsWhen you find an admin portal on a separate port, the JS bundle often contains different secrets than the main site:
base = "https://target.com:8080" # Admin portal
js = requests.get(f"{base}/static/js/main.*.js").text
# 1. Extract ALL API URLs
api_urls = re.findall(r'https?://[^\"\'\\s\\n,)>\\]]+', js)
# 2. Find base API URL (the backend this admin talks to)
# 3. Look for hardcoded credentials, API keys, auth patterns
# 4. Extract route paths for the admin app
routes = re.findall(r'[\"\'](/[a-zA-Z0-9_/.-]*(?:admin|chat|bot|message|user|auth|login|token|config|setting|dashboard|hospital|pharmacy|drug|payment)[a-zA-Z0-9_/.-]*)[\"\']', js, re.IGNORECASE)
When source maps are available, analyze the sourcesContent array for hardcoded secrets:
import json, re
data = json.loads(open("bundle.js.map").read())
all_source = " ".join(data.get("sourcesContent", []))
# Search for credentials in the original source
patterns = {
"password": r'[\"\']([^\"\']*(?:password|passwd|pwd)[^\"\']*)[\"\']\s*[:=]\s*[\"\']([^\"\']+)[\"\']',
"token": r'[\"\']([^\"\']*(?:token|jwt|api_key|apikey|secret)[^\"\']*)[\"\']\s*[:=]\s*[\"\']([^\"\']+)[\"\']',
}
for name, pat in patterns.items():
matches = re.findall(pat, all_source, re.IGNORECASE)
if matches:
print(f"[{name}] {matches[:5]}")
import re
patterns = {
"Firebase API Key": r'apiKey:\s*[\"\']([^\"\']{30,})',
"AWS Key": r'(?:AKIA|ASIA)[A-Z0-9]{16}',
"Google API Key": r'AIza[0-9A-Za-z\\-_]{35}',
"JWT": r'eyJ[A-Za-z0-9_\\-]{20,}\.[A-Za-z0-9_\\-]{20,}\.[A-Za-z0-9_\\-]{10,}',
"Mercado Pago": r'APP_USR-[a-f0-9]{8,}',
"Stripe": r'(?:sk_live|pk_live)_[A-Za-z0-9]{24,}',
"Auth0 Domain": r'(?:domain|auth0_domain):\s*[\"\']([^\"\']+\.auth0\.com)',
"Auth0 Client ID": r'(?:client_id|clientId|AUTH0_CLIENT_ID):\s*[\"\']([^\"\']{20,})',
"Supabase URL": r'(?:supabaseUrl|SUPABASE_URL):\s*[\"\'](https://[^\"\']+\.supabase\.co)',
"Supabase Key": r'(?:supabaseKey|anonKey|SUPABASE_ANON_KEY):\s*[\"\'](eyJ[A-Za-z0-9_\\-]+\.[A-Za-z0-9_\\-]+\.[A-Za-z0-9_\\-]+)',
"Heroku": r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}',
"Generic Secret": r'(?:secret|password|token|key):\s*[\"\']([^\"\']{8,})',
}
import requests, re, json
base = "https://target.com"
html = requests.get(base).text
# Extract all JS URLs
js_urls = re.findall(r'src="([^"]*\.js)"', html)
for js_url in js_urls:
if js_url.startswith("/"):
js_url = base + js_url
content = requests.get(js_url).text
for name, pattern in patterns.items():
matches = re.findall(pattern, content)
for m in matches:
if isinstance(m, tuple):
m = m[0]
if len(m) > 6:
print(f"[{name}] {m[:80]}")
| Issue | Solution |
|---|---|
| Bundles too large | Use grep -oP with specific patterns |
| Minified code (1 char names) | Use source maps for reconstruction |
| False positive matches | Validate keys by testing API endpoint |
| Rate limiting | Add delays between bundle downloads |
JS bundles frequently leak production backend URLs, enabling direct API attacks bypassing CDN/WAF:
# Platform-specific backend URL patterns
grep -oP 'https?://[a-zA-Z0-9.\-]+\.(fly\.dev|azurewebsites\.net|onrender\.com|vercel\.app|netlify\.app)[^"'\'' ]{0,40}' /tmp/*.js
grep -oP 'https?://[a-zA-Z0-9.\-]+\.(supabase\.co|r2\.dev|blob\.vercel-storage\.com)[^"'\'' ]{0,40}' /tmp/*.js
# Edge function URLs
grep -oP 'functions/v1/[a-zA-Z0-9_\-]+' /tmp/*.js
# Internal API paths
grep -oP '["\x60]/api/v1/[a-zA-Z0-9_\-/]+["\x60]' /tmp/*.js
| Pattern | Platform | Example | Secret? |
|---|---|---|---|
*.fly.dev | Fly.io | ht-prod-backend.fly.dev | ✅ Backend URL |
*.azurewebsites.net | Azure | consigpro-api-prod-... | ✅ Backend URL |
*.onrender.com | Render | clickcity-api.onrender.com | ✅ Backend URL |
*.supabase.co | Supabase | jxhvjufqtabpeieyhkgk.supabase.co | ✅ Anon key is public; backend URL is intel |
*.r2.dev | Cloudflare R2 | pub-xxx.r2.dev | ✅ Storage URL |
functions/v1/* | Supabase Edge | provision-openrouter-key | ✅ Endpoint name |
dpl_* | Vercel DPL | dpl_BCoyPsxxYLZ... | ❌ NOT a secret — public deploy ID |
# Test Firebase API key
curl -s "https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIza..."
# Test Supabase anon key
curl -s "https://PROJECT.supabase.co/rest/v1/users?limit=1" -H "apikey: ANON_KEY" -H "Authorization: Bearer ANON_KEY"
Recover full pre-compiled source code when .js.map files are left in production:
# Find .map files via Wayback Machine
curl -s "https://web.archive.org/cdx/search/cdx?url=*.target.com/*&collapse=urlkey&output=text&fl=original&filter=original:.*\.js\.map$" \
| sort -u > map_urls.txt
# Download and extract source
wget https://target.com/static/app.js.map
node -e "
const map = require('./app.js.map');
map.sources.forEach((src, i) => {
const fs = require('fs');
fs.writeFileSync(src.split('/').pop(), map.sourcesContent[i]);
});
print('Extracted ' + map.sources.length + ' source files');
"
# Quick check: does a JS file have an available map?
curl -skI "https://target.com/static/app.js.map" | grep "200\|Content-Type"
Crawl JS files recursively for embedded URLs, APIs, and IPs:
# lazyegg — crawls JS files for links, APIs, IPs
python3 lazyegg.py https://target.com
python3 lazyegg.py https://target.com/js/auth.js
# Combine with waybackurls for deep coverage
waybackurls target.com \
| grep '\.js$' \
| awk -F '?' '{print $1}' \
| sort -u \
| xargs -I{} bash -c 'python3 lazyegg.py "{}" --js_urls --domains --ips' \
> lazyegg_output.txt
# subjs — extract JS URLs from any URL list
cat all_urls.txt | subjs | tee js_files_full.txt
JS bundles are source code — even minified. A disciplined per-file (per-chunk) review finds what autonomous agents miss:
# 1. Download all JS chunks
curl -sk "https://target.com" | grep -oP 'src="[^"]+\.js[^"]*"' | \
cut -d'"' -f2 | while read js; do
curl -sk "$js" -o "chunks/$(basename $js)"
done
# 2. Per-chunk pattern review for dangerous sinks
for chunk in chunks/*.js; do
echo "=== $chunk ==="
# eval / new Function (arbitrary code execution)
grep -oPn 'eval\s*\(|new\s+Function\s*\(' "$chunk"
# Hardcoded API keys/secrets
grep -oPn '(?:api[_-]?key|secret|token|password|bearer)\s*[:=]\s*["\x27][^"\x27]{8,}' "$chunk"
# postMessage without origin check
grep -oPn 'postMessage\s*\(' "$chunk"
# Prototype pollution patterns
grep -oPn '__proto__|constructor\.prototype' "$chunk"
# Debug/test code in production
grep -oPin 'debug|test|staging|localhost' "$chunk"
# Client-trusted flags
grep -oPn '(?:isAdmin|isVip|isPremium|isModerator|role)\s*[=:]\s*true' "$chunk"
done > ai_review_findings.txt
# 3. Review findings — each is a CANDIDATE, not confirmed
grep -c ai_review_findings.txt
grep -c ai_review_findings.txt
Key insight: autonomous agents told "find bugs" in a whole codebase burn budget and miss things. A guaranteed per-file pass with fixed output structure produces repeatable hits. Each finding still needs manual PoC verification.