Find the PHP-to-shell exposure class β an unrestricted file upload that turns into remote code execution β written end to end in ZelC, Rochestonβs cybersecurity-native language. Read-only recon, a benign canary, an immutable verdict anchored to Rosecoin, and the fix in every report.
Read-only recon, a benign canary, risk scoring, evidence, and remediation β the entire php2shell checker, written as one ZelC playbook.
ββββββββββββββββββββββββββββββββββββββββ
Β©οΈ ROCHESTON ZELC: PHP2SHELL_CHECKER.zelc
βοΈ LICENSE: PROPRIETARY / ROCHESTON ECOSYSTEM
π AUTHOR: Haja Mo
π·οΈ VERSION: 1.0 (Sentinel Protocol)
π― PURPOSE: Detect the "PHP-to-shell" exposure class β an unrestricted file
upload that leads to code execution β on a web server you are
AUTHORIZED to test. Detection only. It confirms the weakness with
a BENIGN canary (a marker file that echoes one random token and
holds no shell and no command execution), scores the risk, maps
the control, writes immutable evidence, and hands back the fix.
It never weaponizes anything.
ββββββββββββββββββββββββββββββββββββββββ
package rocheston.webappsec
use net, http, crypto, aina, rosecoin, noodles, rcf
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 1. SCAN POLICY (authorized, detection-only, non-destructive)
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ keep SCAN_POLICY = π¦
AUTHORIZED_ONLY: true
MODE: "detect" -- never weaponize; confirm and report only
CANARY: "benign" -- marker emits one random token, nothing else
TIMEOUT_MS: 8000
VULN_RISK_FLOOR: 70 -- score at or above this reports as VULNERABLE
π
πΉ keep TARGET = "https://app.example.com"
note: Common places an upload handler lives. Reconnaissance is read-only.
πΉ keep UPLOAD_SURFACES = ["/upload", "/upload.php", "/api/upload", "/media/upload", "/includes/upload.php"]
note: What a hardened server should do. This ships inside every report.
πΉ keep REMEDIATION = [
"Store uploads outside the web root; serve them through a handler, never by direct URL.",
"Allow-list real content types by magic bytes β never trust the filename or its extension.",
"Disable script handlers and strip execute permission in the upload directory.",
"Rename every upload to a random token; discard the client-supplied name.",
"Put a WAF rule in front of the endpoint and log every write for evidence."
]
record Verdict
target: Text
status: Text -- VULNERABLE / HARDENED / INCONCLUSIVE
surface: Text
risk: Number
evidence_id: Text
end
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 2. BENIGN DETECTION (read-only recon + a harmless canary)
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ define surface_exists(base, path)
note: A plain read. Does an upload handler even answer here?
πΉ set probe = http get base + path timeout SCAN_POLICY.TIMEOUT_MS
return probe.reachable is true and probe.status < 500
π΄
βοΈ define canary_probe(base, path)
note: Ask the ZelExploits engine, in DETECT mode, to upload a benign
marker β a file that prints one random token and carries no
parameters, no shell, and no command execution β then read it
back. If the token is reflected, the server executed an uploaded
file. This is the safe, standard way to confirm the weakness.
πΉ set token = crypto random string length 16
πΉ set result = zelexploits canary_probe π¦
url: base + path
token: token
mode: "detect"
payload: "benign-marker"
π
return result
π΄
βοΈ define assess(base)
πΉ set finding = Verdict π¦
target: base
status: "HARDENED"
surface: "none"
risk: 0
evidence_id: "none"
π
βοΈ each path in UPLOAD_SURFACES
βοΈ when surface_exists(base, path) is true
πΉ set r = canary_probe(base, path)
βοΈ when r.executed is true
πΉ change finding.status = "VULNERABLE"
πΉ change finding.surface = path
return finding
π΄
βοΈ when r.accepted is true and r.stored_in_webroot is true
πΉ change finding.status = "INCONCLUSIVE"
πΉ change finding.surface = path
π΄
π΄
π΄
return finding
π΄
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 3. THE CHECKER
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ check PhpToShellChecker
note: β οΈ Run only against systems you own or are authorized to test.
βοΈ when SCAN_POLICY.AUTHORIZED_ONLY is true
π¦ trace "Authorized detection run against {TARGET}"
π΄
πΉ set finding = assess(TARGET)
π§ change finding.risk = aina risk score π¦
signal: "unrestricted_upload"
status: finding.status
surface: finding.surface
π
βοΈ when finding.status is "VULNERABLE"
π¨ alert critical message "π΄ PHP-to-shell exposure confirmed on {finding.surface}"
β‘ do
π set pack = evidence record "Upload_Exec_Confirmed" details π¦
target: finding.target
surface: finding.surface
method: "benign canary β token reflected"
risk: finding.risk
π
πΉ change finding.evidence_id = pack.id
π§Ύ rcf map control "OWASP-ASVS-12.2" to finding
π§Ύ rcf map control "CWE-434" to finding
π evidence record "Remediation" details π¦
target: finding.target
steps: REMEDIATION
π
βοΈ rosecoin anchor pack.id
π noodles build report type "vulnerability" data finding
π export report format "pdf" to "reports/php2shell_report.pdf"
π‘ notify slack channel "#appsec" message "π΄ Upload-to-RCE confirmed on {finding.target} β report anchored."
π΄
π΄
βοΈ when finding.status is "HARDENED"
β
alert low message "π’ No upload-to-exec exposure found on {TARGET}"
β‘ do
π audit log "Scan_Clean" details "No executable upload surface on {TARGET}"
π΄
π΄
βοΈ when finding.status is "INCONCLUSIVE"
β οΈ alert medium message "π‘ Upload accepted but execution not confirmed β review {finding.surface}"
β‘ do
π evidence record "Needs_Review" details π¦
target: finding.target
surface: finding.surface
guidance: REMEDIATION
π
π΄
π΄
π΄
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- π OPERATOR MANUAL
-- zelc guard php2shell_checker.zelc -- taint + capability pre-flight
-- zelc run php2shell_checker.zelc -- detect against SCAN_POLICY TARGET
-- Edit TARGET to a host you are AUTHORIZED to test. Detection only β the
-- canary never executes commands, and every report ships with the fix.
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The whole flow stays read-only by default. The only thing that touches the target is a harmless marker β and the moment the weakness is confirmed, ZelC writes the proof and the remediation, not a foothold.
Plain reads locate the upload handler. Nothing is written, nothing is changed, until a check explicitly says so.
Confirmation uses a marker file that echoes one random token β no web shell, no parameters, no command execution. Ever.
A VULNERABLE verdict becomes an immutable evidence pack, hashed and anchored to the Rosecoin ledger for the auditor.
Every report carries the remediation and the mapped control (OWASP ASVS 12.2, CWE-434) β so the finding comes with its cure.
Point it at a target and run. This on-page demo is an illustration of the engineβs output β to scan for real, download the ZelC below and run it against systems you are authorized to test.
Idle. Enter an authorized target and press βRun ZelC checkβ.
β Illustrative output. No request was sent to the target above. Run the downloaded ZelC for a real, authorized scan.
A quick, plain-language read on the weakness the checker hunts for β then the exact hardening for Ubuntu, Apache2, Nginx, PHP, and the PHP CLI, plus the defence-in-depth layers that cage a web shell if one ever lands.
An unrestricted file upload becomes remote code execution the moment two things are true at once: your app accepts a file it shouldnβt, and your web server is willing to run that file as a PHP script. An attacker uploads a .php file, opens its URL, and the server executes it β handing over a web shell and command execution as the www-data user.
This is CWE-434, one of the oldest and most reliable ways to own a Linux web server. It isnβt a bug in one product version β itβs the gap between a careless upload handler and a server configured to run scripts from the wrong directory.
Three classics do most of the damage. Apache with an unanchored handler will happily run shell.php.jpg because .php appears anywhere in the name. Nginx with PHP-FPM and cgi.fix_pathinfo = 1 will execute /uploads/photo.jpg as PHP when asked for /uploads/photo.jpg/x.php β the path-info trick.
And a long tail of extensions beyond .php stays executable even after you block the obvious one. Default file permissions and uploads living inside the web root finish the job.
This is a configuration and application-code class (CWE-434), not a single package bug. Any Apache2, Nginx, or PHP version is exposed if itβs misconfigured β and any version is safe once itβs hardened. So the real patch is the config below, not an apt upgrade. Keep packages current anyway, for everything else.
One concrete, version-pinned exception worth knowing: CVE-2019-11043, a genuine PHP-FPM remote-code-execution bug on Nginx. If you run Nginx + PHP-FPM, make sure PHP is at or above 7.1.33 / 7.2.24 / 7.3.11 β modern PHP 8.x is clear β and apply the Nginx try_files line below.
Treat every one of these as executable and keep them out of upload directories: .php .phar .phtml .pht .php3 .php4 .php5 .php7 .phps .inc
β Paths assume PHP 8.3 on Ubuntu 24.04 (use 8.1 on 22.04). Test every change with apache2ctl configtest or nginx -t before you reload β then re-run the checker to confirm the hole is closed.
Once the checker proves the gap, the same finding drives a ZelBreach adversary-emulation drill: how far the weakness would carry an attacker, how much your blue team catches, and the evidence to prove it β all under one intent and one blast radius.
ββββββββββββββββββββββββββββββββββββββββ
Β©οΈ ROCHESTON ZELBREACH: PHP2SHELL_PENTEST.π―.zelc
βοΈ LICENSE: PROPRIETARY / AUTHORIZED COMPLIANCE TESTING
π AUTHOR: Haja Mo
π·οΈ VERSION: 1.0 (Tiger Protocol)
π― PURPOSE: A ZelBreach adversary-emulation playbook that measures how far an
unrestricted-upload weakness WOULD carry an attacker β for
authorized compliance pen-testing inside your own organization.
SIMULATION ONLY. The ZelBreach engine replays each technique in a
sandbox; nothing here touches production, and no live exploit,
payload, or web shell is carried in this file. It emulates the
chain, scores blue-team detection, and proves the gap to auditors.
(ZFS class .π― = adversary simulation β runs with no OS write access.)
ββββββββββββββββββββββββββββββββββββββββ
package adversary.simulation
use zelbreach, aina, rosecoin, noodles, rcf, rcce
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 1. INTENT (the compiler validates every step against this)
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ intent UploadToShellDrill π¦
category: "exploitation"
objective: "Prove unrestricted-upload-to-RCE exposure for compliance"
environment: "authorized-lab"
simulation_only: true
require_authorization: true
prohibited_actions: ["live_exploit", "data_exfiltration", "persistence", "production_write"]
π
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 2. BLAST RADIUS (the governor β physics enforced at compile time)
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ keep BLAST_LIMITS = π¦
MAX_TARGETS: 1
SCOPE: "in-scope-assets-only"
NO_LIVE_EXPLOIT: true -- technique runs in the sandbox, never on prod
TIME_WINDOW: "approved-maintenance"
π
note: The emulated kill chain, named at the MITRE ATTACK level only. Each
entry is a phase the engine REPLAYS in a sandbox. No operational
detail, payload, or bypass recipe lives in this playbook.
πΉ keep KILL_CHAIN = [
π¦ id: "T1595" phase: "recon" label: "Enumerate upload surfaces" π,
π¦ id: "T1190" phase: "access" label: "Flag public-facing upload weakness" π,
π¦ id: "T1505.003" phase: "foothold" label: "Emulate web-shell foothold" π,
π¦ id: "T1083" phase: "discover" label: "Emulate discovery under containment" π,
π¦ id: "TA0010" phase: "evidence" label: "Capture proof and score detection" π
]
πΉ keep TARGET = "lab-app-01.internal"
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 3. THE DRILL
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ check UploadToShellSimulation
note: β οΈ Authorization gate β refuse to run outside simulation.
βοΈ when UploadToShellDrill.simulation_only is false
π¨ alert critical message "Refusing to run β this drill is simulation-only."
stop
π΄
πΉ set coverage = []
πΉ set halted_at = "none"
π‘ notify slack channel "#purple-team" message "π― ZelBreach drill armed (sandbox) against {TARGET}"
βοΈ each phase in KILL_CHAIN
note: The engine replays the technique in its sandbox and reports
whether the blue-team stack would have SEEN and STOPPED it.
π§ set step = zelbreach simulate π¦
target: TARGET
technique: phase.id
phase: phase.phase
mode: "sandbox"
blast: BLAST_LIMITS
π
β‘ do
π evidence record "Emulated_Step" details π¦
technique: phase.id
label: phase.label
detected: step.detected
blocked: step.blocked
π
πΉ change coverage = coverage + [step.detected]
π΄
note: Physics guard β if an emulated step would ever leave scope,
the drill halts before the next phase even begins.
βοΈ when step.in_scope is false
π¨ alert critical message "Blast-radius stop at {phase.id}"
πΉ change halted_at = phase.id
break
π΄
βοΈ when step.blocked is true
π‘ notify slack channel "#purple-team" message "π‘οΈ Blue team stopped {phase.id} ({phase.label})"
πΉ change halted_at = phase.id
break
π΄
π΄
note: ββ Score the exercise and prove it ββ
π§ set score = aina risk score π¦
signal: "upload_to_rce_drill"
coverage: coverage
halted_at: halted_at
π
β‘ do
π§Ύ rcf map control "OWASP-ASVS-12.2" to "UploadToShellDrill"
π§Ύ rcf gap report output "reports/upload_rce_gap.html"
π rcce generate scorecard details π¦
drill: "UploadToShellDrill"
target: TARGET
detection_coverage: coverage
risk: score
π
π noodles generate evidence_pack
βοΈ rosecoin anchor evidence_pack "upload-rce-drill"
π audit log "Drill_Complete" details "Simulation finished β halted at {halted_at}, risk {score}"
π΄
π΄
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- π OPERATOR MANUAL
-- Load inside ZelBreach -> set Simulation Only -> Run.
-- zelc guard php2shell_pentest.zelc -- intent + blast-radius pre-flight
-- The .π― Tiger class runs in ZelBreach's sandbox with no OS write access.
-- Authorized compliance testing on in-scope assets ONLY. No live exploit,
-- payload, or web shell is contained in this playbook.
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The compiler validates every emulated step against a declared intent. Prohibited actions never compile.
One target, in-scope only, no live exploit. The physics engine halts the drill before it ever leaves bounds.
Each phase is named at the ATT&CK technique level and scored for blue-team detection and blocking.
Produces an RCCE scorecard and an RCF gap report β drop it straight into Level 3 lab exercises.
Six ZelBreach playbooks across the attack surface β ransomware, cloud identity, phishing, lateral movement, supply chain, API abuse. Same ZelC spine every time: intent-gated, blast-radius-capped, evidence-anchored, simulation-only. Pick one to read it.
Start with the checker and the drill below β and every playbook in the arsenal above downloads from its own panel. Pre-flight with zelc guard, then zelc run. Edit the target to a host you own or are authorized to test.
The detection-only checker. Finds the exposure, scores it, anchors the evidence, ships the fix.
The ZelBreach drill. Simulation-only adversary emulation and detection scoring for compliance pen-testing.