Web Shell Management and Upgrade
A web shell gives code execution but is fragile — it lives in one file, produces no interactive shell, and disappears if the application restarts or the file is detected. The first priority after landing a web shell is confirming the execution context, then upgrading to a stable reverse shell before doing anything else. Enumeration through a web shell parameter is slow and error-prone compared to a proper interactive session.
Confirm Execution Context
Establish what user, privileges, and environment you have before attempting anything else:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Linux target 5.15.0-91-generic x86_64 GNU/Linux
root:x:0:0:root:/root:/bin/bash www-data:x:33:33:www-data:/var/www:/bin/sh
Upgrade to Reverse Shell
Set up the listener first, then trigger the reverse shell through the web shell. Use URL encoding to handle special characters in the payload:
If bash is not available or the redirect operator is filtered, use mkfifo:
Python fallback when nc and bash redirects are both unavailable:
Stabilise the Shell
Raw nc shells have no tab completion, no arrow keys, and Ctrl+C kills the connection. Stabilise immediately after connecting:
Then background the shell with Ctrl+Z and configure the local terminal:
Plant a Secondary Web Shell
Before moving on, plant a secondary shell in a less obvious location as a fallback. Name it something that blends with legitimate files:
-rw-r--r-- 1 www-data www-data 32 Mar 28 12:00 /var/www/html/assets/img/thumb.php
Locate Other Web Application Files
Find the full web root structure and other web applications on the same server:
References
-
PayloadsAllTheThings — Reverse Shell Cheatsheetgithub.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md (opens in new tab)
Reverse shell payloads for bash, python, nc, perl, and other languages
Was this helpful?
Your feedback helps improve this page.