Skip to content

What is a web shell? A defender's primer

What web shells are, why attackers rely on them, how they are classified, and where they sit in the attack lifecycle — explained for defenders, without payloads.

Published on 7 min read

A web shell is a piece of code that an attacker places on a web-accessible server so that ordinary HTTP(S) requests can be turned into actions on that server: running operating-system commands, reading and writing files, querying databases, or relaying traffic deeper into the network. It is written in whatever language the server already executes — PHP, ASP.NET (ASPX/ASHX), classic ASP, JSP, Python, Node.js — so it needs no extra runtime and blends in with the application around it.

For defenders, the important point is not how to write one, but what it changes on a system and what traces it leaves. This primer builds the mental model the rest of this site relies on.

Why attackers like web shells

Web shells persist because they solve several attacker problems at once:

Attacker goalHow a web shell helpsWhat it means for defenders
PersistenceSurvives reboots and credential resets; lives as a file or modulePassword resets alone do not evict the intruder
StealthTraffic looks like normal HTTPS to a public web serverNetwork perimeter controls rarely block it
Low footprintCan be a few hundred bytes of textEasy to miss in a large webroot
PrivilegeRuns as the web server or application-pool identityOften SYSTEM, NETWORK SERVICE or a service account with broad rights
PivotingMany variants proxy or tunnel trafficThe server becomes a beachhead into internal networks

MITRE ATT&CK tracks this as T1505.003 — Server Software Component: Web Shell. Government advisories — notably the joint NSA and Australian Signals Directorate guidance Detect and Prevent Web Shell Malware (2020) — have repeatedly flagged web shells as one of the most common persistence mechanisms on internet-facing servers.

Where web shells live in the attack lifecycle

A web shell is almost never the first thing an attacker does. It is the thing they do immediately after gaining the ability to write a file or execute code on a server:

  1. Initial access — exploitation of a vulnerable application or appliance, abuse of an upload feature, stolen admin credentials for a CMS, or a compromised third-party component.
  2. Web shell deployment — a file is written into a directory the web server will execute, or a module is registered with the server.
  3. Hands-on activity — reconnaissance (whoami, ipconfig, net group), credential theft, staging tools, data access.
  4. Expansion — lateral movement, additional web shells as backups, sometimes ransomware or data theft.

Because step 2 is the pivot between "a bug exists" and "an intruder is operating", web shells are among the highest-value artifacts an incident responder can find. The shell's creation time anchors the timeline; its access logs reveal the attacker's IPs and cadence; its process children reveal what they did.

A defender's classification

Rather than cataloguing families, it helps to classify web shells by the properties that change how you detect them.

By form factor

Form factorDescriptionPrimary detection surface
Standalone scriptA new file such as .php, .aspx, .jsp in the webrootFile integrity monitoring, file creation events
Injected codeMalicious lines appended to a legitimate page or include fileContent diffing against a known-good baseline
Configuration abuseHandlers or directives changed so a harmless-looking extension executesConfig monitoring (web.config, .htaccess, server conf)
Server moduleNative IIS module, Apache/nginx module, or Java filter/servletLoaded-module inventory, memory analysis
Memory-residentCode injected into the running application (e.g. Java or .NET in-memory implants) with no file on diskProcess telemetry, memory forensics, anomalous request handling

By capability

  • Command runners execute OS commands and return output.
  • File managers browse, upload, download and timestomp files.
  • Database clients connect to back-end databases using credentials found in config files.
  • Proxies and tunnels relay TCP traffic through HTTP to reach internal hosts.
  • Loaders and stagers are tiny "one-liners" that evaluate code sent in each request. They carry no visible functionality at rest, which makes them hard to spot by reading the file — the logic arrives with the traffic.

The last category is why reading the source is not enough. A two-line file that evaluates request data can be as dangerous as a full-featured panel.

By interaction style

  • Interactive panels render an HTML interface; requests often use GET for the panel and POST for actions.
  • Client-driven shells expect a dedicated client that sends encoded or encrypted payloads, typically via POST bodies, cookies or custom headers. Publicly reported families like China Chopper popularised this model.
  • Password- or key-gated shells ignore requests that lack a secret parameter and return a normal-looking page or a 404 otherwise, frustrating simple scanners.

What a web shell changes on a system

Every web shell, regardless of family, leaves evidence in some combination of the following places. The detection guides on this site are organised around them.

Evidence layerTypical traceGuide
File systemNew or modified executable file in a web-served path; odd timestampsFile integrity detection
Web server logsRequests to a rarely-used URL, often POST, from few source IPsLog analysis
Process telemetryw3wp.exe, httpd, php-fpm or java spawning shells and recon toolsProcess-tree detection
NetworkOutbound connections from the web server; internal scanningFirewall and NDR logs
MemoryInjected assemblies, filters or modules without a backing fileMemory forensics

Common misconceptions

"We'd notice a new file." In a webroot with thousands of files, a new error_log.php or aspnet_client/*.aspx does not stand out without automation. Attackers deliberately pick names that look like part of the product.

"Our WAF blocks web shells." A WAF can block some exploitation and some known shell traffic patterns, but encrypted or custom-encoded shell traffic over TLS to an already-planted file will often pass. WAFs are a layer, not a guarantee — see eradication and hardening.

"We patched, so we're safe." Patching closes the door the attacker used; it does nothing to a web shell already planted. The large-scale Exchange compromises of 2021 showed thousands of servers that were patched after shells had been dropped and remained backdoored. See notable incidents.

"Deleting the file ends the incident." The shell is a symptom. Attackers who used it may have harvested credentials, created accounts, planted additional shells, or moved laterally. Eradication must be scoped by investigation — see the forensic investigation guide.

Legitimate look-alikes

Defenders must also recognise tools that behave like web shells but are authorised: hosting control panels, database admin interfaces, remote-management agents with web consoles, and diagnostic pages left by developers. These are both a false-positive source and a real risk — an unauthenticated admin tool left in production is functionally an open web shell. Inventory them, restrict them to management networks, and require strong authentication.

Key takeaways

  • A web shell turns HTTP requests into server-side actions and is ATT&CK technique T1505.003.
  • It is a post-exploitation artifact: find it and you have found proof of compromise and a timeline anchor.
  • Classify by form factor and interaction style to choose the right detection surface.
  • No single control is enough; combine file, log, process and memory visibility.

Continue with how web shells get planted to understand the vulnerability classes that lead to deployment.

Related guides