1- .PHONY : bootstrap test labs-up labs-down labs-status labs-test labs-fpm-up labs-fpm-down labs-fpm-status labs-fpm-test lint clean
1+ .PHONY : help test lint secrets ci bootstrap inventory validate-profiles validate-fpm \
2+ build-nginx build-php build-all profile-draft calibrate-remote remote matrix \
3+ labs-up labs-down labs-status labs-test \
4+ labs-fpm-up labs-fpm-down labs-fpm-status labs-fpm-smoke labs-fpm-ports labs-fpm-test \
5+ clean
26
3- bootstrap : # # Fetch and pin the upstream exploit
4- python3 tools/bootstrap_upstream.py
7+ help : # # Show this help
8+ @grep -E ' ^[a-zA-Z0-9_.-]+:.*##' $(MAKEFILE_LIST ) | \
9+ awk ' BEGIN {FS = ":.*## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
510
611test : # # Run the unit test suite
7- python3 -m unittest discover -s tests -v
12+ PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -v
13+
14+ lint : # # Run ruff on the Python tools and tests
15+ ruff check tools tests
816
9- lint : # # Run gitleaks to detect leaked secrets
17+ secrets : # # Run gitleaks to detect leaked secrets
1018 gitleaks detect --source . --no-git --redact -v
1119
12- labs-up : # # Start all local laboratories (ports 8100-8106)
20+ ci : lint test validate-profiles validate-fpm # # Run the fast CI checks locally
21+
22+ bootstrap : # # Fetch and pin the upstream exploit
23+ python3 tools/bootstrap_upstream.py
24+
25+ inventory : # # Print the profile and offset inventory
26+ python3 tools/php2shell_inventory.py
27+
28+ validate-profiles : # # Validate every build profile against the generic schema
29+ python3 -c " import json, jsonschema; \
30+ schema = json.load(open(' profiles/schema.json' )); \
31+ from pathlib import Path; \
32+ [jsonschema.validate(json.loads(p.read_text()), schema) or print(f' ok {p.name}' ) \
33+ for p in sorted(Path(' profiles' ).glob(' *.json' )) \
34+ if p.name not in (' schema.json' , ' fpm-schema.json' )]"
35+
36+ validate-fpm : # # Validate the PHP-FPM profiles against the FPM schema
37+ python3 -c " import glob, json, jsonschema; \
38+ s = json.load(open(' profiles/fpm-schema.json' )); \
39+ [jsonschema.validate(json.load(open(p)), s) or print(f' ok {p}' ) \
40+ for p in sorted(glob.glob(' profiles/*-fpm.json' ))]"
41+
42+ # --------------------------------------------------------------------------- #
43+ # PHP-FPM laboratory (nginx + PHP-FPM, user prefix, no Docker)
44+ # --------------------------------------------------------------------------- #
45+
46+ build-nginx : # # Build nginx into lab/fpm/runtime
47+ lab/fpm/build_nginx.sh
48+
49+ build-php : # # Build a PHP version into lab/fpm/runtime (VERSION=8.4.26)
50+ @test -n " $( VERSION) " || \
51+ (echo " usage: make build-php VERSION=8.4.26" ; exit 2)
52+ lab/fpm/build_php.sh " $( VERSION) "
53+
54+ build-all : # # Build several PHP versions (VERSIONS="8.4.25 8.4.26")
55+ @test -n " $( VERSIONS) " || \
56+ (echo " usage: make build-all VERSIONS=\" 8.4.25 8.4.26\" " ; exit 2)
57+ lab/fpm/build_all.sh $(VERSIONS )
58+
59+ profile-draft : # # Generate a draft FPM profile (PHP_FPM=... VERSION=...)
60+ @test -n " $( PHP_FPM) " -a -n " $( VERSION) " || \
61+ (echo " usage: make profile-draft PHP_FPM=/path/to/php-fpm VERSION=8.4.25" ; exit 2)
62+ python3 tools/php2shell_fpm_profile.py --php-fpm " $( PHP_FPM) " --version " $( VERSION) "
63+
64+ calibrate-remote : # # Discover a profile over HTTP only (VERSION=... BASE=... BUILDER=...)
65+ @test -n " $( VERSION) " || \
66+ (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)
67+ python3 tools/php2shell_fpm.py --version " $( VERSION) " \
68+ --base " $( BASE) " --builder " $( BUILDER) " calibrate
69+
70+ remote : # # Run the 100%-remote chain (VERSION=... BASE=... BUILDER=...)
71+ @test -n " $( VERSION) " || \
72+ (echo " usage: make remote VERSION=8.2.34 BASE=http://127.0.0.1:8406 BUILDER=http://127.0.0.1:8407" ; exit 2)
73+ python3 tools/php2shell_fpm.py --version " $( VERSION) " \
74+ --base " $( BASE) " --builder " $( BUILDER) " \
75+ --command " id>out/remote-$( VERSION) " --proof-file " out/remote-$( VERSION) " \
76+ no-oracle
77+
78+ matrix : # # Verify the remote chain on every unpatched build
79+ python3 tools/php2shell_fpm_matrix.py
80+
81+ # --------------------------------------------------------------------------- #
82+ # Laboratories
83+ # --------------------------------------------------------------------------- #
84+
85+ labs-up : # # Start all local Docker laboratories (ports 8100-8106)
1386 python3 tools/php2shell_labs.py up
1487
15- labs-down : # # Stop all local laboratories
88+ labs-down : # # Stop all local Docker laboratories
1689 python3 tools/php2shell_labs.py down
1790
18- labs-status : # # Show laboratory container status
91+ labs-status : # # Show Docker laboratory container status
1992 python3 tools/php2shell_labs.py status
2093
21- labs-test : # # Run the dispatcher against each lab
94+ labs-test : # # Run the dispatcher against each Docker lab
2295 python3 tools/php2shell_labs.py test
2396
2497labs-fpm-up : # # Start the nginx + PHP-FPM laboratories (no Docker)
@@ -30,23 +103,16 @@ labs-fpm-down: ## Stop the nginx + PHP-FPM laboratories
30103labs-fpm-status : # # Show FPM laboratory status
31104 python3 tools/php2shell_fpm_labs.py status
32105
33- labs-fpm-test : # # Run primitive + endgame against the FPM lab
34- python3 tools/php2shell_fpm_labs.py test
106+ labs-fpm-smoke : # # Check the FPM lab endpoints
107+ python3 tools/php2shell_fpm_labs.py smoke
35108
36- inventory : # # Print the profile and offset inventory
37- python3 tools/php2shell_inventory .py
109+ labs-fpm-ports : # # Print the FPM lab port map
110+ python3 tools/php2shell_fpm_labs .py ports
38111
39- validate-profiles : # # Validate profiles (requires jsonschema)
40- python3 -c " import json, jsonschema; \
41- schema = json.load(open(' profiles/schema.json' )); \
42- from pathlib import Path; \
43- [jsonschema.validate(json.loads(p.read_text()), schema) or print(f' ok {p.name}' ) \
44- for p in sorted(Path(' profiles' ).glob(' *.json' )) if p.name ! = ' schema.json' ]"
112+ labs-fpm-test : # # Run primitive + endgame against the FPM lab
113+ python3 tools/php2shell_fpm_labs.py test
45114
46115clean : # # Remove generated files and vendor checkout
47116 rm -rf vendor/php2shell-upstream
48117 rm -rf lab/rce/out/
49-
50- help : # # Show this help
51- @grep -E ' ^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST ) | \
52- awk ' BEGIN {FS = ":.*## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
118+ rm -rf lab/fpm/webroot/out/
0 commit comments