Skip to content

About

Isolated Docker adversary-emulation lab: PHP2Shell (CVE-2026-109618/619, CVE-2026-115560) exploit chains, 11-scenario patch & WAF audit, Sliver C2, Cloudflare Quick Tunnel + Tor egress, guided mitigation validation.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PHP2Shell Unchained
Isolated adversary-emulation lab for PHP Session Upload Progress (PHP2Shell) chains, mitigations, and blue-team validation

CI Docker Compose PHP matrix SAPI Sliver C2 Quick Tunnel Tor egress License MIT

CVE-2026-109618 CVE-2026-109619 CVE-2026-115560 Calif research


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.


Who this is for

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

Architecture (logical)

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
Loading

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.

Operator console

The lab is driven from one ASCII menu. Security admins start at [8]. Emulation tracks are [1]–[7] and stay inside the compose network.

Main operator menu

CLI help, workarounds first

Menu 8, patch and WAF audit

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.


Vulnerability context (reference)

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


Exploit chains in this lab

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.


Quick start

1. Clone and install CLI (any directory after install)

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            # preflight

2. Minimal FPM path (one terminal)

vtbw-php2shell-lab up
vtbw-php2shell-lab test          # UAF reachability
vtbw-php2shell-lab rce           # Chain A (lab LFI)
vtbw-php2shell-lab down

Target URL (default): http://127.0.0.1:19281/

3. Mitigation validation (recommended for sec teams)

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 evaluation

Logs: out/workarounds/<UTC>/ (session.log, steps.jsonl, step-NN-*.log, auswertung.md).

Step-by-step (DE): docs/WORKAROUNDS-SCHRITT-FUER-SCHRITT.md.

4. External-attacker perspective

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-top10

5. Authorized assessment (your own real hosts)

Sysadmins 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 report

Design boundary (deliberate): assess = probes + evidence only. The full chain against authorized production hosts is a separate, additionally gated mode:

5b. Remote engagement (full chain, authorized hosts — no Docker target)

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

6. Multi-terminal convenience

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 | shell

7. Cursor / MCP

Configure the MCP server in docs/CURSOR-INTEGRATION.md. Tools: lab_help, lab_status, lab_run, lab_read_doc, lab_exploit_map.


Patch & WAF audit scenarios

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 all

Reference: docs/PATCH-BYPASS-AUDIT.md.


Documentation map

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

Repository layout

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)

Requirements

  • Docker Engine with Compose v2
  • bash, curl, python3 on the host
  • ~/.local/bin on PATH after install-commands.sh

Disclaimer

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.

About

Isolated Docker adversary-emulation lab: PHP2Shell (CVE-2026-109618/619, CVE-2026-115560) exploit chains, 11-scenario patch & WAF audit, Sliver C2, Cloudflare Quick Tunnel + Tor egress, guided mitigation validation.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages