PHP2Shell Unchained
Isolated adversary-emulation lab for PHP Session Upload Progress (PHP2Shell) chains, mitigations, and blue-team validation
Maintainer: Leviticus-Triage
PHP2Shell Unchained is a self-contained Docker lab for security engineering teams, platform operators, and application developers who need to reproduce, exercise, and measure PHP2Shell-related attack paths and vendor or emergency mitigations—without touching production systems.
The lab bundles multiple public research chains (FPM + LFI, mod_php heap, Jackalsyn framework slot), optional Sliver post-exploitation emulation, Cloudflare Quick Tunnel inbound perspective, optional Tor egress for outbound obfuscation, an 11-scenario patch / WAF audit engine, and a guided workarounds runner with session logs and Markdown evaluation output.
Scope: Authorized testing only—your lab hosts, your CI images, or explicitly permitted targets. See SECURITY.md.
| Role | What you get |
|---|---|
| System / platform admins | Repeatable Docker stacks, workarounds run to validate ini/FPM/WAF changes, doctor health checks, version matrix against fixed PHP releases |
| Application developers | Understand Chain A (session file + LFI), upload-progress configuration, and why ini_set() timing matters for CVE-2026-115560 |
| Security / red & blue teams | Exploit-path comparison, WAF Top-10 bypass probes, external-attacker mode (tunnel ± Tor), Singularity LKM detection exercises, JSONL audit trails |
flowchart TB
subgraph sgHost ["Operator host"]
CLI["lab CLI and menu"]
MCP["IDE MCP bridge"]
end
subgraph sgDocker ["Compose lab network"]
TGT["nginx plus PHP-FPM"]
APA["Apache mod_php"]
ATK["attacker and patch audit"]
end
subgraph sgSide ["Optional sidecars"]
CF["Quick Tunnel"]
TOR["Tor egress"]
end
CLI --> TGT
MCP --> CLI
ATK --> TGT
ATK --> APA
CF --> TGT
ATK -.-> TOR
Networks: lab_isolated carries target and attacker traffic with no direct internet. lab_egress is the only path for controlled outbound fetches. Details: docs/DOCUMENTATION.md.
The lab is driven from one ASCII menu. Security admins start at [8]. Emulation tracks are [1]–[7] and stay inside the compose network.
| Key | Audience | What it is |
|---|---|---|
| [8] | Admins, blue team | Guided workaround session, 11 patch and WAF checks, markdown report under out/workarounds/ |
| [h] | Everyone | Same text as vtbw-php2shell-lab help |
| [1] | Lab operators | Bring the FPM target up, doctor, then reachability checks |
| [d] | Lab operators | ps, logs, down, portable export |
Full command reference stays in docs/DOCUMENTATION.md. A short admin path is docs/HOW-TO.md.
| ID | CVSS (NVD) | Mechanism (summary) | Fixed PHP (vendor) |
|---|---|---|---|
| CVE-2026-109618 | 9.2 | OOM / longjmp leaves uninitialized request state → memory corruption → RCE |
8.2.35, 8.3.36, 8.4.27, 8.5.12 |
| CVE-2026-109619 | 9.2 | Stale global state after fatal error on upload-progress path → UAF → RCE | same |
| CVE-2026-115560 | advisory | serialize_handler switch + upload progress enabled |
next bugfix train; interim: session.upload_progress.enabled=0 |
Further reading: Calif Research — PHP2Shell · CERT-EU SA 2026-018 · PHP.net 2026 archive · Google Cloud response blog
| Chain | Origin | Stack | Lab entrypoint | Outcome in lab |
|---|---|---|---|---|
| Reachability / UAF signal | 0x4148 PoC | PHP-FPM | test, doctor |
Armed / bytes_processed — not full heap RCE |
| Chain A (session + LFI) | ikow PoC | PHP-FPM | rce, shell |
uid=www-data via intentional LFI |
| Zer061 heap | Zer061 | Apache prefork + mod_php | apache-up, zer061 |
3-stage HTTP heap RCE |
| Jackalsyn framework | Jackalsyn / php-up-2026 bundle |
build-dependent | fetch-jackalsyn, jackalsyn lab |
Slot in third_party/ (manual bundle) |
| Post-exploit | BishopFox Sliver | C2 profile | menu [6] | mTLS / HTTPS listeners, implant staging |
| LKM detection | Singularity (research LKM) | host / priv container | menu [7] | build + singularity detect |
Full comparison: docs/EXPLOIT-CHAIN-COMPARISON.md.
git clone https://github.com/Leviticus-Triage/php2shell-unchained.git
cd php2shell-unchained
./scripts/install-commands.sh # symlinks → ~/.local/bin (and /usr/local/bin if writable)vtbw-php2shell-lab help
php2shell-unchained # interactive menu
vtbw-php2shell-doctor # preflightvtbw-php2shell-lab up
vtbw-php2shell-lab test # UAF reachability
vtbw-php2shell-lab rce # Chain A (lab LFI)
vtbw-php2shell-lab downTarget URL (default): http://127.0.0.1:19281/
vtbw-php2shell-lab workarounds run # guided: change config → ENTER → audit → auswertung.md
vtbw-php2shell-lab workarounds auto # baseline measurement only
vtbw-php2shell-lab workarounds last # open last evaluationLogs: out/workarounds/<UTC>/ (session.log, steps.jsonl, step-NN-*.log, auswertung.md).
Step-by-step (DE): docs/WORKAROUNDS-SCHRITT-FUER-SCHRITT.md.
vtbw-php2shell-lab external up --tor # Quick Tunnel + Tor egress for cloudflared / audit proxy
vtbw-php2shell-lab tunnel url
vtbw-php2shell-lab external patch-audit waf-bypass-top10Sysadmins and red teamers can validate real PHP deployments they are authorized to test — the same 11 patch/WAF probes, scope-gated:
# 1. Declare authorization (gitignored, machine-checked gate)
echo 'staging-php.internal.example # RoE SEC-1234, 2026-10-27' >> scope-authorized.txt
# 2. Target + run
export PATCH_AUDIT_URL='https://staging-php.internal.example/index.php'
vtbw-php2shell-lab assess run all
vtbw-php2shell-lab assess reportDesign boundary (deliberate): assess = probes + evidence only. The full chain against authorized production hosts is a separate, additionally gated mode:
For red teamers and sysadmins who need the complete path — exploitation, chaining, post-exploitation — against their own real systems:
echo 'staging-php.internal.example # RoE SEC-1234' >> scope-authorized.txt
CONFIRM_ROE=I-AM-AUTHORIZED ENGAGE_LHOST=10.20.30.40 \
vtbw-php2shell-lab engage run 'https://staging-php.internal.example/index.php'| Property | Behaviour |
|---|---|
| Phases | 00 scope+kits → 10 recon → 20 fingerprint → 30 exploit → 40 foothold → 50 post-ex → 60 report |
| Incremental | Each phase idempotent; engage resume <sid> continues |
| Chained | Later phases hydrate earlier results (banner → exploit choice, listener → post-ex) |
| Multi-terminal | Listeners / C2 consoles spawn automatically (tmux panes, gnome-terminal tabs, or nohup) |
| Tor | ENGAGE_TOR=on — Host tor.service SOCKS5 :9050 (no Docker sidecar required) |
| RAAS | lukechilds reverse-shell.sh — Default on (ENGAGE_RS=off to skip) |
| C2 | ENGAGE_C2=sliver (default) — compose or host auto |
| Tunnel | ENGAGE_TUNNEL=on — listener + optional Sliver HTTPS tunnel |
| External | ENGAGE_EXTERNAL=auto on lab IPs — full external up stack |
| Jackalsyn | selftest in phase 30; --lab with ENGAGE_FCGI_HOST + ENGAGE_DTOR |
| Singularity | lab (default) · load/full = container-build/LKM mit CONFIRM_SINGULARITY_ENGAGE=VM-REBOOT-OK |
| mod_php | ENGAGE_MODPHP=auto: Fingerprint zer061-heap + exploit.py (+ optional Lab-Apache :19288) |
| Gate | scope-authorized.txt plus CONFIRM_ROE=I-AM-AUTHORIZED |
Docs: remote/README.md · profile template: remote/engagement.yaml.example
For the isolated lab workflow, tmux panes spawn automatically:
vtbw-php2shell-lab session lab # 4 panes: stack up | logs | audit list | doctor
vtbw-php2shell-lab session audit # 3 panes: guided workarounds | logs | shellConfigure the MCP server in docs/CURSOR-INTEGRATION.md. Tools: lab_help, lab_status, lab_run, lab_read_doc, lab_exploit_map.
| ID | Typical control under test |
|---|---|
vendor-patch |
PHP version ≥ vendor fix |
upload-progress-off |
session.upload_progress.enabled=Off |
ini-set-late |
Runtime ini_set too late |
memory-limit-workaround |
Elevated memory_limit (618 exposure note) |
cve-115560-config |
serialize handler switch |
waf-php2shell-signature |
WAF body signature |
waf-bypass-top10 |
Ten evasion mutations |
edge-multipart-block |
CDN multipart block |
chain-a-lfi |
LFI closure |
zer061-heap |
mod_php heap path |
singularity-detect |
post-exploit LKM IOC checklist |
vtbw-php2shell-lab patch-audit list
vtbw-php2shell-lab patch-audit run allReference: docs/PATCH-BYPASS-AUDIT.md.
| Document | Language | Content |
|---|---|---|
| docs/HOW-TO.md | EN | First hour: install, doctor, workarounds, stop |
| docs/AUTHORIZED-ASSESSMENT.md | EN | Scope-gated validation of your own real hosts |
| docs/DOCUMENTATION.md | DE | Complete technical manual (commands, compose, env, logs) |
| docs/HOWTO-DE.md | DE | Phased workflow 1–10 |
| docs/WORKFLOW-KOMPLETT.md | DE | Full workflow: setup → exploit → post-exploit → audit |
| docs/WORKAROUNDS-SCHRITT-FUER-SCHRITT.md | DE | Guided mitigation walkthrough |
| docs/EXPLOIT-CHAIN-COMPARISON.md | DE | Chain vs. chain matrix |
| docs/SINGULARITY-LAB.md | DE | LKM lab modes |
| docs/CURSOR-INTEGRATION.md | DE | Skill, rule, MCP |
| SECURITY.md | EN | Authorized use & reporting |
| CONTRIBUTING.md | EN | Contributions |
bin/ Global CLI wrappers (resolve lab root from any cwd)
scripts/ Dispatcher, tunnel, tor, workarounds, fetch-* helpers
attacker/ Attacker image + patch_audit.py
target/ nginx + PHP-FPM target image
docker-compose.yml
mcp/ FastMCP server for IDE integration
docs/
third_party/ Not in git — populated via fetch-* (zer061, jackalsyn, sliver, …)
out/ Runtime artifacts (audits, tunnels, workarounds sessions)
- Docker Engine with Compose v2
bash,curl,python3on the host~/.local/binonPATHafterinstall-commands.sh
This repository provides intentionally vulnerable configurations and proof-of-concept tooling for defensive validation in isolated environments. Operators are responsible for compliance with applicable law and organizational policy. No warranty is expressed or implied. See SECURITY.md.


