FTP Web Shell Upload
When FTP write access lands in a directory also served by a web server, uploading a web shell and requesting it over HTTP gives remote code execution. This requires two confirmed conditions: write access to the FTP path, and that path being reachable over HTTP. Both are confirmed in FTP Writable Directory Check.
Identify the Web Root Path
The FTP root may be the web root, a subdirectory of it, or unrelated. Determine the relationship before uploading.
Check whether a test file uploaded to FTP is accessible over HTTP:
If the response contains pathtest, the FTP root maps directly to the web root. Test subdirectories:
Clean up the test file after confirming:
PHP Web Shell
For Linux targets running Apache or Nginx with PHP:
Confirm execution:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
ASPX Web Shell
For Windows targets running IIS:
Upload to a Subdirectory
If the writable path is a subdirectory such as uploads:
Get a Reverse Shell
Start your listener:
Trigger a reverse shell through the web shell. URL-encode the payload:
mkfifo method if the bash redirect is filtered:
After catching the shell, stabilise it before proceeding. See Shell Stabilization and TTY Upgrade.
Extension Filtering Bypass
Some web servers only execute PHP files with specific extensions. If shell.php is not executed, try alternate extensions:
shell.php5
shell.php7
shell.phtml
shell.phar
Upload each and request it over HTTP. If the server executes .phtml or .php5 files, the bypass works.
Handling FTP over Interactive Session
If curl fails due to server quirks, use an interactive ftp session:
binary put /tmp/shell.php shell.php
The binary command ensures the file is not corrupted by line ending conversion during transfer.
References
-
RFC 959 - File Transfer Protocolwww.rfc-editor.org/rfc/rfc959 (opens in new tab)
FTP STOR command specification covering file upload behaviour
Was this helpful?
Your feedback helps improve this page.