Skip to content

Commit 0f3a114

Browse files
committed
Initial public research release
0 parents  commit 0f3a114

84 files changed

Lines changed: 7912 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.11", "3.12"]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Unit tests
23+
run: PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests -v
24+
25+
secrets:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
- uses: gitleaks/gitleaks-action@v2
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__/
2+
*.py[cod]
3+
.DS_Store
4+
vendor/
5+
lab/wordpress/wp/
6+
lab/rce/out/

‎ACCEPTABLE_USE.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Acceptable use
2+
3+
PHP2Shell is a research toolkit for **authorized** security testing. This page
4+
is part of the project's terms of use, together with [LICENSE](LICENSE) and
5+
[SECURITY.md](SECURITY.md).
6+
7+
## You may use it only when
8+
9+
- you own the target system, or
10+
- you have explicit, written permission from the owner to test it, and
11+
- your testing complies with the law and with the rules of any program you
12+
participate in.
13+
14+
A public website, an IP address you found online, or a domain that "looks like a
15+
lab" is **not** authorization.
16+
17+
## You must not
18+
19+
- test third-party or public infrastructure;
20+
- build or distribute target lists, scanners or mass-exploitation tooling;
21+
- use the remote worker-saturation mode against systems you do not own: it opens
22+
many connections and is disruptive;
23+
- cause denial of service, data loss or persistence on systems without written
24+
authorization;
25+
- publish data obtained from systems you do not own (hostnames, cookies,
26+
credentials, file contents).
27+
28+
## Disruptive behavior
29+
30+
The chain sends large request bodies, triggers out-of-memory conditions and
31+
kills Apache children. Run it against disposable laboratories. The reference
32+
labs bind to `127.0.0.1` and mount an `/out` directory; keep it that way.
33+
34+
## Disclosure
35+
36+
If you find a new affected build or a new PHP issue, prefer coordinated
37+
disclosure with the PHP security team and the distribution vendor. Do not
38+
publish an unpatched exploit or third-party data.
39+
40+
## No warranty
41+
42+
The software is provided "as is", without warranty of any kind. The authors
43+
accept no liability for misuse or damage. The license grants copyright
44+
permissions only; it does not grant authorization to test any system.

‎CONTRIBUTING.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Contributing
2+
3+
Thanks for helping make PHP2Shell reproducible. Contributions are reviewed for
4+
correctness, safety and evidence.
5+
6+
## Scope
7+
8+
Welcome:
9+
10+
- new build profiles with a real command proof and the exact image/tag;
11+
- offset extraction for new distributions and architectures;
12+
- laboratory fixes and calibration improvements;
13+
- tests, documentation, detection guidance and defensive tooling;
14+
- fixes for the open configurations (`display_errors=Off`, `expose_php=Off`,
15+
FPM).
16+
17+
Not welcome:
18+
19+
- target lists, mass-exploitation tooling or automation against third parties;
20+
- data from systems you do not own (hostnames, IPs, cookies, credentials);
21+
- changes that make remote saturation pinning a default;
22+
- unverified "RCE" claims.
23+
24+
## Adding a profile
25+
26+
1. Use an exact image tag and the matching architecture.
27+
2. Run `tools/php2shell_calibrate.py` against a local lab.
28+
3. Confirm a real proof (`uid=...`), not just a successful response.
29+
4. Add `profiles/<build>.json` with the offsets, heap parameters and
30+
`rce: true` only when the proof is reproducible.
31+
5. If stage 3 is probabilistic, say so in the profile and in the README table.
32+
6. Update `docs/profile-inventory.md` and the README status table together.
33+
34+
Profiles must not contain target data. `rce: false` is a valid and useful
35+
result: negative data prevents false positives.
36+
37+
## Code style
38+
39+
- Python 3.11+ with the standard library; avoid new runtime dependencies.
40+
- Keep the dispatcher's safe defaults: loopback automatic, remote opt-in.
41+
- Error messages must not print secrets or raw target data.
42+
- Run the tests before opening a pull request:
43+
44+
```sh
45+
python3 -m unittest discover -s tests -v
46+
gitleaks detect --source . --no-git --redact -v
47+
```
48+
49+
## Pull request checklist
50+
51+
- [ ] Tests pass and new logic has a test.
52+
- [ ] Profile changes include the exact image/tag and a proof.
53+
- [ ] README/inventory tables are updated and accurate.
54+
- [ ] No secrets, personal paths or third-party target data.
55+
- [ ] Credits are preserved (9bie, Karasawa2025, WoYinDao, PHP team).
56+
- [ ] The change does not weaken the authorization gates.
57+
58+
## Disclosure
59+
60+
This repository is not a vendor channel. If you find a new affected build or a
61+
new PHP issue, report it to the PHP security team and the distribution vendor
62+
through their coordinated disclosure process. Do not open a public issue with
63+
an unpatched exploit.

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 devploit
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎Makefile‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.PHONY: bootstrap test labs-up labs-down labs-status labs-test lint clean
2+
3+
bootstrap: ## Fetch and pin the upstream exploit
4+
python3 tools/bootstrap_upstream.py
5+
6+
test: ## Run the unit test suite
7+
python3 -m unittest discover -s tests -v
8+
9+
lint: ## Run gitleaks to detect leaked secrets
10+
gitleaks detect --source . --no-git --redact -v
11+
12+
labs-up: ## Start all local laboratories (ports 8100-8106)
13+
python3 tools/php2shell_labs.py up
14+
15+
labs-down: ## Stop all local laboratories
16+
python3 tools/php2shell_labs.py down
17+
18+
labs-status: ## Show laboratory container status
19+
python3 tools/php2shell_labs.py status
20+
21+
labs-test: ## Run the dispatcher against each lab
22+
python3 tools/php2shell_labs.py test
23+
24+
inventory: ## Print the profile and offset inventory
25+
python3 tools/php2shell_inventory.py
26+
27+
validate-profiles: ## Validate profiles (requires jsonschema)
28+
python3 -c "import json, jsonschema; \
29+
schema = json.load(open('profiles/schema.json')); \
30+
from pathlib import Path; \
31+
[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']"
33+
34+
clean: ## Remove generated files and vendor checkout
35+
rm -rf vendor/php2shell-upstream
36+
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}'

0 commit comments

Comments
 (0)