Webshell Variants Overview
Three ASP webshell variants were identified, ranging from sophisticated obfuscation to simple command execution:| Variant | Encoding | Lines of Code | Sophistication |
|---|---|---|---|
| m0s.asp | Custom decode function | 43 | High |
| webshell.asp | None | 19 | Low |
| file.asp | None | 18 | Low |
m0s.asp - Primary Webshell with Obfuscation
Full Source Code
Decode Function Analysis
TheDecode() function reverses the encoding applied by the Python C2 scripts:
- Takes encoded string as input
- For each character, finds its position in the substitution alphabet (
de) - Replaces it with the character at the same position in the original alphabet (
en) - Returns decoded plaintext command
- Python C2 encodes
whoami→???(encoded) - ASP webshell receives encoded string in
Accept-Languageheader Decode()reverses substitution →whoami- Command executed via
cmd /c whoami
Command Execution Mechanism
- Creates
WScript.ShellCOM object - Calls
.exec()method with command string - Reads entire stdout output
- Returns output to caller
Request Handling Logic
- Extracts command from
HTTP_ACCEPT_LANGUAGEserver variable - Only executes if header is present and non-empty
- Returns 404 error if no command provided (appears as broken page)
- Immediately ends response on 404 to avoid revealing code
COM Objects Created
WScript.Shell is actively used:
- WSCRIPT.SHELL - Used for command execution
- WSCRIPT.NETWORK - Network operations (unused in this code)
- Scripting.FileSystemObject - File operations (unused in this code)
webshell.asp - Simplified Version
Full Source Code
Key Differences from m0s.asp
Removed features:- No
Decode()function - commands transmitted in plaintext - No encoding/decoding logic
- More compact code (19 lines vs 43 lines)
- Same COM object initialization
- Same
getCommandOutput()function - Same header-based command reception
- Same 404 stealth mechanism
- Backup webshell for when encoding is not needed
- Used by RCE4.py which doesn’t implement encoding
- Simpler deployment with less code to detect
file.asp - Minimal Webshell
Full Source Code
Analysis
Differences from webshell.asp:- Minor formatting differences (whitespace, indentation)
- Functionally identical to webshell.asp
- 18 lines vs 19 lines (negligible difference)
- Possibly a renamed copy for redundancy
- May be deployed to different directories for backup access
- Provides multiple entry points if one webshell is discovered
Security Analysis
Attack Surface
All three webshells enable:- Arbitrary command execution via
cmd /c - Full system access under IIS application pool identity
- Persistent backdoor access
- Potential for lateral movement
- Data exfiltration capabilities
Privilege Context
Commands execute with the privileges of the IIS application pool identity, typically:IIS APPPOOL\DefaultAppPool(limited)NETWORK SERVICE(medium)SYSTEM(if misconfigured - critical)
Evasion Techniques
-
HTTP Header Tunneling
- Commands in
Accept-Languageheader (unusual but valid) - Evades POST/query string inspection
- Commands in
-
404 Error Simulation
- Returns 404 when accessed without command
- Appears as broken/missing page to casual inspection
-
Custom Encoding (m0s.asp only)
- Obfuscates command payloads
- Reduces signature-based detection
-
File Extension Masquerading
.phtoextension (m0s.phto on flydubai.com)- Deployed in image/upload directories
- Blends with legitimate content
Detection and Response
File-based IOCs
YARA Rule Concepts
Behavioral Detection
Process monitoring:Remediation Steps
-
Immediate containment:
- Take affected server offline or isolate network segment
- Terminate IIS application pool
- Block network access to identified webshell URLs
-
Investigation:
- Review IIS logs for Accept-Language header anomalies
- Check file creation timestamps for webshells
- Identify initial access vector (file upload, RCE, etc.)
- Search for additional webshells with similar patterns
-
Eradication:
- Delete all identified webshell files
- Patch vulnerabilities used for initial access
- Review and remove any created user accounts
- Check for persistence mechanisms (scheduled tasks, services)
-
Recovery:
- Restore from clean backup if available
- Rebuild server if compromise is extensive
- Reset all credentials with access to affected systems
- Update WAF/IPS rules to block similar attacks
Related Analysis
- Webshell Framework Overview - Complete framework architecture
- Python Framework Analysis - C2 interface details