Lab 4: Advanced File Upload Techniques

Advanced file upload bypass techniques

Difficulty: High

Lab Overview

This lab demonstrates advanced file upload bypass techniques used to circumvent modern security filters and protections. These techniques include obfuscation, encoding, alternative execution methods, and sophisticated bypass methods.

Objective: Use advanced techniques to bypass sophisticated security filters and upload malicious files.

Advanced Vulnerable Code
// Vulnerable: Advanced filters that can be bypassed
function process_advanced_file_upload($file) {
    $allowed_extensions = ['jpg', 'jpeg', 'png', 'gif', 'txt', 'pdf'];
    $allowed_mime_types = ['image/jpeg', 'image/png', 'image/gif', 'text/plain'];
    $max_file_size = 5 * 1024 * 1024; // 5MB
    $dangerous_patterns = [' $max_file_size) {
        return false;
    }
    
    // Check extension
    $file_extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
    if (!in_array($file_extension, $allowed_extensions)) {
        return false;
    }
    
    // Check MIME type
    if (!in_array($file['type'], $allowed_mime_types)) {
        return false;
    }
    
    // Check file content for dangerous patterns
    $file_content = file_get_contents($file['tmp_name']);
    foreach ($dangerous_patterns as $pattern) {
        if (stripos($file_content, $pattern) !== false) {
            return false;
        }
    }
    
    // Still vulnerable to advanced bypass techniques
    return move_uploaded_file($file['tmp_name'], $file_path);
}
Advanced File Upload
Advanced Filters

The following are filtered:

  • Extensions: jpg, jpeg, png, gif, txt, pdf, doc, docx
  • MIME Types: image/jpeg, image/png, image/gif, text/plain, application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • File Size: Maximum 5MB
  • Content Patterns:
Advanced Bypass Techniques

Try these advanced bypass methods:

  • webshell.php.jpg - Double extension
  • webshell.php%00.jpg - Null byte injection
  • webshell.php;.jpg - Semicolon bypass
  • webshell.PHP.JPG - Case variation
Uploaded Files

No files uploaded yet.

Vulnerability Details
  • Type: Advanced File Upload Techniques
  • Severity: Critical
  • Method: POST
  • Issue: Advanced filters can be bypassed
Advanced Bypass Techniques
  • Obfuscation: Hide malicious code
  • Encoding: Use encoded characters
  • Alternative Execution: Use different execution methods
  • Complex Scenarios: Combine multiple techniques
Advanced File Upload Bypass Payloads

Use these advanced techniques to bypass sophisticated security filters:

1. Obfuscated PHP Web Shells:
# Base64 encoded PHP