File upload without proper validation
This lab demonstrates a basic file upload vulnerability where users can upload files without proper validation. The application accepts any file type and stores it directly on the server without checking file content or extensions.
Objective: Upload malicious files to achieve server compromise or data exfiltration.
// Vulnerable: Basic file upload without validation
function process_file_upload($file) {
if (empty($file['name'])) {
return false;
}
// Vulnerable: Direct file upload without validation
$upload_dir = 'uploads/';
if (!file_exists($upload_dir)) {
mkdir($upload_dir, 0755, true);
}
$file_path = $upload_dir . basename($file['name']);
if (move_uploaded_file($file['tmp_name'], $file_path)) {
return $file_path;
}
return false;
}
This lab demonstrates file upload vulnerabilities. You can upload:
Try uploading these files:
webshell.php - PHP web shellmalicious.js - JavaScript filebackdoor.exe - Executable fileconfig.txt - Configuration fileNo files uploaded yet.
webshell.php - PHP web shellmalicious.js - JavaScript filebackdoor.exe - Executable fileconfig.txt - Configuration fileUse these files to test file upload vulnerabilities:
PHP Version: 8.1.33
Server: LiteSpeed/6.3.4 Enterprise
OS: Linux v999.srv-console.green 5.14.0-570.55.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 21 05:27:51 EDT 2025 x86_64
Current Directory: /home/kzlabsst/practice.kzlabs.store/fileupload
Disk Space: 232291524608 bytes free
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND kzlabsst 2697789 0.0 0.0 150872 40768 ? S 08:16 0:00 lsphp kzlabsst 2768138 0.0 0.0 159400 32860 ? Ss 08:21 0:00 lsphp:absst/practice.kzlabs.store/fileupload/1.php kzlabsst 2768176 0.0 0.0 7236 3072 ? R 08:21 0:00 ps aux
{result.stdout}")
if result.stderr:
print(f"Error: {result.stderr}")
except Exception as e:
print(f"Error: {e}")
print("""
""")$output"; } print < HTML
#{output}"
end
puts <
HTML"
eval "$cmd" 2>&1
echo ""
fi
cat << 'EOF'
EOF