$npx -y skills add meltedinhex/analyst-ai-pack --skill analyzing-webshellsAnalyzes suspected webshells (PHP, ASPX/ASP, JSP) by detecting dynamic-execution
| 1 | # Analyzing Webshells |
| 2 | |
| 3 | ## When to Use |
| 4 | |
| 5 | - You found a suspicious server-side script (`.php`, `.aspx`, `.jsp`, `.asp`) and need to confirm |
| 6 | it is a webshell and understand its command interface. |
| 7 | - You are triaging a web-server compromise and want to classify dropped scripts. |
| 8 | |
| 9 | **Do not use** a live web server to execute the script to "test" it — that runs attacker code. |
| 10 | Analyze the source statically. |
| 11 | |
| 12 | ## Prerequisites |
| 13 | |
| 14 | - The suspect script file(s), read inertly. |
| 15 | |
| 16 | ## Safety & Handling |
| 17 | |
| 18 | - Read the file statically; never deploy or request it on a live server. Defang any URLs. |
| 19 | |
| 20 | ## Workflow |
| 21 | |
| 22 | ### Step 1: Detect execution sinks and input flow |
| 23 | |
| 24 | ```bash |
| 25 | python scripts/analyst.py scan shell.php |
| 26 | ``` |
| 27 | |
| 28 | Flags dynamic-execution sinks (`eval`, `assert`, `system`, `exec`, `passthru`, `Runtime.exec`, |
| 29 | ASPX `eval()`/`Process.Start`) and whether request input (`$_GET`/`$_POST`/`Request`) reaches them. |
| 30 | |
| 31 | ### Step 2: Identify obfuscation/encoder chains |
| 32 | |
| 33 | Detects `base64_decode`, `gzinflate`, `str_rot13`, `eval(chr(...))`, hex `\x` strings, and |
| 34 | `FromBase64String` chains commonly wrapping the payload. |
| 35 | |
| 36 | ### Step 3: Decode obvious layers |
| 37 | |
| 38 | Apply base64/rot13/gzinflate where present to reveal the inner command interface (best-effort, |
| 39 | non-executing). |
| 40 | |
| 41 | ### Step 4: Classify and report |
| 42 | |
| 43 | Note the language, the password/parameter gate (if any), and capabilities (file manager, command |
| 44 | exec, SQL, upload); defang IOCs. |
| 45 | |
| 46 | ## Validation |
| 47 | |
| 48 | - A flagged file pairs an execution sink with attacker-controlled input. |
| 49 | - Encoder chains are identified and, where safe, decoded statically. |
| 50 | - Capability classification is backed by concrete code evidence. |
| 51 | |
| 52 | ## Pitfalls |
| 53 | |
| 54 | - Legitimate admin tools that also use `eval`/`system` — corroborate with input flow. |
| 55 | - Multi-stage shells that fetch the real logic remotely. |
| 56 | - Deeply nested or runtime-built obfuscation that static decode only partly unwinds. |
| 57 | |
| 58 | ## References |
| 59 | |
| 60 | - See [`references/api-reference.md`](references/api-reference.md) for the scanner. |
| 61 | - ATT&CK T1505.003 (linked in frontmatter). |