Skip to content

Commit daa8503

Browse files
authored
Merge pull request #1350 from HackTricks-wiki/update_HTB_Zero___htaccess_ErrorDocument_LFI___credential_20250827_152245
HTB Zero .htaccess ErrorDocument LFI → credential reuse → ro...
2 parents 5b4eb85 + 08b6739 commit daa8503

2 files changed

Lines changed: 44 additions & 12 deletions

File tree

  • src
    • linux-hardening/privilege-escalation
    • network-services-pentesting/pentesting-web

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,15 @@ escaping-from-limited-bash.md
16301630
cisco-vmanage.md
16311631
{{#endref}}
16321632
1633+
## Android rooting frameworks: manager-channel abuse
1634+
1635+
Android rooting frameworks commonly hook a syscall to expose privileged kernel functionality to a userspace manager. Weak manager authentication (e.g., signature checks based on FD-order or poor password schemes) can enable a local app to impersonate the manager and escalate to root on already-rooted devices. Learn more and exploitation details here:
1636+
1637+
1638+
{{#ref}}
1639+
android-rooting-frameworks-manager-auth-bypass-syscall-hook.md
1640+
{{#endref}}
1641+
16331642
## Kernel Security Protections
16341643
16351644
- [https://github.com/a13xp0p0v/kconfig-hardened-check](https://github.com/a13xp0p0v/kconfig-hardened-check)
@@ -1675,13 +1684,4 @@ cisco-vmanage.md
16751684
- [https://www.linode.com/docs/guides/what-is-systemd/](https://www.linode.com/docs/guides/what-is-systemd/)
16761685
16771686
1678-
## Android rooting frameworks: manager-channel abuse
1679-
1680-
Android rooting frameworks commonly hook a syscall to expose privileged kernel functionality to a userspace manager. Weak manager authentication (e.g., signature checks based on FD-order or poor password schemes) can enable a local app to impersonate the manager and escalate to root on already-rooted devices. Learn more and exploitation details here:
1681-
1682-
1683-
{{#ref}}
1684-
android-rooting-frameworks-manager-auth-bypass-syscall-hook.md
1685-
{{#endref}}
1686-
16871687
{{#include ../../banners/hacktricks-training.md}}

src/network-services-pentesting/pentesting-web/apache.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,38 @@ uid=1(daemon) gid=1(daemon) groups=1(daemon)
2727
Linux
2828
```
2929

30+
## LFI via .htaccess ErrorDocument file provider (ap_expr)
31+
32+
If you can control a directory’s .htaccess and AllowOverride includes FileInfo for that path, you can turn 404 responses into arbitrary local file reads using the ap_expr file() function inside ErrorDocument.
33+
34+
- Requirements:
35+
- Apache 2.4 with expression parser (ap_expr) enabled (default in 2.4).
36+
- The vhost/dir must allow .htaccess to set ErrorDocument (AllowOverride FileInfo).
37+
- The Apache worker user must have read permissions on the target file.
38+
39+
.htaccess payload:
40+
41+
```apache
42+
# Optional marker header just to identify your tenant/request path
43+
Header always set X-Debug-Tenant "demo"
44+
# On any 404 under this directory, return the contents of an absolute filesystem path
45+
ErrorDocument 404 %{file:/etc/passwd}
46+
```
47+
48+
Trigger by requesting any non-existing path below that directory, for example when abusing userdir-style hosting:
49+
50+
```bash
51+
curl -s http://target/~user/does-not-exist | sed -n '1,20p'
52+
```
53+
54+
Notes and tips:
55+
- Only absolute paths work. The content is returned as the response body for the 404 handler.
56+
- Effective read permissions are those of the Apache user (typically www-data/apache). You won’t read /root/* or /etc/shadow in default setups.
57+
- Even if .htaccess is root-owned, if the parent directory is tenant-owned and permits rename, you may be able to rename the original .htaccess and upload your own replacement via SFTP/FTP:
58+
- rename .htaccess .htaccess.bk
59+
- put your malicious .htaccess
60+
- Use this to read application source under DocumentRoot or vhost config paths to harvest secrets (DB creds, API keys, etc.).
61+
3062
## Confusion Attack <a href="#a-whole-new-attack-confusion-attack" id="a-whole-new-attack-confusion-attack"></a>
3163

3264
These types of attacks has been introduced and documented [**by Orange in this blog post**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1) and the following is a summary. The "confusion" attack basically abuses how the tens of modules that work together creating a Apache don't work perfectly synchronised and making some of them modify some unexpected data can cause a vulnerability in a later module.
@@ -274,8 +306,8 @@ Check [**Docker PHP LFI Summary**](https://www.leavesongs.com/PENETRATION/docker
274306
## References
275307

276308
- [https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1)
309+
- [Apache 2.4 Custom Error Responses (ErrorDocument)](https://httpd.apache.org/docs/2.4/custom-error.html)
310+
- [Apache 2.4 Expressions and functions (file:)](https://httpd.apache.org/docs/2.4/expr.html)
311+
- [HTB Zero write-up: .htaccess ErrorDocument LFI and cron pgrep abuse](https://0xdf.gitlab.io/2025/08/12/htb-zero.html)
277312

278313
{{#include ../../banners/hacktricks-training.md}}
279-
280-
281-

0 commit comments

Comments
 (0)