Skip to content

Web Shell

Risk Level

A web shell is a malicious script uploaded to a web server that provides the attacker with remote command execution via a web browser. Web shells are lightweight, stealthy, and extremely persistent — they blend into server directories as normal-looking files (e.g., image.php, wp-update.php, config.asp).

MilestoneYearDetails
Early PHP shells2000sc99, r57 in hacking forums
c99 shell2000sFeature-rich PHP shell
r57 shell2000sCompetitor to c99
China Chopper2000s+22-byte ASP/ASPX/PHP; APT staple
WSO Shell2000s+Feature-rich; criminal use
ProxyLogon shells2021Exchange zero-day; mass deployment
1. UPLOAD
└─ File upload vuln, RCE, RFI/LFI, compromised creds
2. DISGUISE
└─ Named: image.php, wp-update.php, config.asp, license.txt
3. COMMAND EXECUTION
└─ Attacker accesses shell URL → OS commands via browser
4. FILE MANAGEMENT
└─ Upload, download, edit, delete, permission changes
5. LATERAL MOVEMENT
└─ Pivot to internal network, SMB, RDP, SSH
6. PERSISTENCE
└─ Survives patching (original vuln fixed, shell remains)
ShellLanguageSizeNotable
c99PHP~20KBFeature-rich; early 2000s
r57PHP~25KBCompetitor to c99
China ChopperASP/PHP/JSP22 bytesAPT; used by Chinese groups
WSOPHP~50KBFeature-rich; criminals
b374kPHP~30KBModern, feature-rich
ProxyLogon shellsASPXVarious2021 Exchange; HAFNIUM
IndicatorDetection
File AnomaliesUnexpected .php/.asp/.jsp in static dirs
File IntegrityFIM alerts on new/modified files
Web LogsPOST to unusual files; high entropy params
Process Treew3wp.execmd.exe / powershell.exe
NetworkOutbound from web server to unusual IPs
YARA RulesWeb shell signatures (PHP, ASP, JSP)
  • Validate uploads — Type, size, storage outside web root
  • Disable script execution in upload dirs (php_flag engine off)
  • WAF — Block known shells, suspicious patterns
  • File Integrity Monitoring — FIM on web directories
  • Least Privilege — Web server as unprivileged user
  • Disable unused extensions — .asp, .php, .jsp if not needed
  • Log monitoring — POST to static files, unusual UAs
ASP: <%eval request("cmd")%>
PHP: <?eval($_POST[cmd]);?>
JSP: <%Runtime.getRuntime().exec(request.getParameter("cmd"));%>
  • 22 bytes — Smallest functional web shell
  • Usage — Chinese APT groups (APT10, APT41, etc.)
  • Detection — Extremely difficult; minimal footprint
  • File upload validation — MIME, extension, content scan
  • Store uploads outside web root — No script execution
  • WAF rules — Known shells, eval, exec, system, passthru
  • FIM — Tripwire, AIDE, OSSEC, Wazuh on web dirs
  • Least privilege — Web server user, no shell access
  • Regular auditsfind /var/www -type f -name "*.php" -newer /tmp/marker
TechniqueIDDescription
Web ShellT1505.003Web server backdoor
Server Software ComponentT1505Persistence via components
Command and Scripting InterpreterT1059Command execution