mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-28 13:43:24 -08:00
Update kubernetes-enumeration.md
This commit is contained in:
@@ -678,6 +678,130 @@ curl --path-as-is -i -s -k -X $'DELETE' \
|
||||
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/default/pods/$POD_NAME"
|
||||
```
|
||||
|
||||
### Create a Service Account
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
NAMESPACE="default"
|
||||
|
||||
|
||||
curl --path-as-is -i -s -k -X $'POST' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'Content-Length: 109' \
|
||||
-H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"apiVersion\":\"v1\",\"kind\":\"ServiceAccount\",\"metadata\":{\"name\":\"secrets-manager-sa-2\",\"namespace\":\"default\"}}\x0a' \
|
||||
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/$NAMESPACE/serviceaccounts?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
|
||||
```
|
||||
|
||||
|
||||
### Delete a Service Account
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
SA_NAME=""
|
||||
NAMESPACE="default"
|
||||
|
||||
curl --path-as-is -i -s -k -X $'DELETE' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Content-Length: 35' -H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
|
||||
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/$NAMESPACE/serviceaccounts/$SA_NAME"
|
||||
```
|
||||
|
||||
|
||||
### Create a Role
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
NAMESPACE="default"
|
||||
|
||||
|
||||
curl --path-as-is -i -s -k -X $'POST' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Content-Length: 203' \
|
||||
-H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"apiVersion\":\"rbac.authorization.k8s.io/v1\",\"kind\":\"Role\",\"metadata\":{\"name\":\"secrets-manager-role\",\"namespace\":\"default\"},\"rules\":[{\"apiGroups\":[\"\"],\"resources\":[\"secrets\"],\"verbs\":[\"get\",\"create\"]}]}\x0a' \
|
||||
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/roles?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
|
||||
```
|
||||
|
||||
|
||||
### Delete a Role
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
NAMESPACE="default"
|
||||
ROLE_NAME=""
|
||||
|
||||
curl --path-as-is -i -s -k -X $'DELETE' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'Content-Length: 35' \
|
||||
-H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
|
||||
"https://$$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/roles/$ROLE_NAME"
|
||||
```
|
||||
|
||||
|
||||
### Create a Role Binding
|
||||
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
NAMESPACE="default"
|
||||
|
||||
curl --path-as-is -i -s -k -X $'POST' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Content-Length: 816' \
|
||||
-H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"apiVersion\":\"rbac.authorization.k8s.io/v1\",\"kind\":\"RoleBinding\",\"metadata\":{\"name\":\"secrets-manager-role-binding\",\"namespace\":\"default\"},\"roleRef\":{\"apiGroup\":\"rbac.authorization.k8s.io\",\"kind\":\"Role\",\"name\":\"secrets-manager-role\"},\"subjects\":[{\"apiGroup\":\"\",\"kind\":\"ServiceAccount\",\"name\":\"secrets-manager-sa\",\"namespace\":\"default\"}]}\x0a' \
|
||||
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/$NAMESPACE/default/rolebindings?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
|
||||
```
|
||||
|
||||
### Delete a Role Binding
|
||||
|
||||
```bash
|
||||
CONTROL_PLANE_HOST=""
|
||||
TOKEN=""
|
||||
NAMESPACE="default"
|
||||
ROLE_BINDING_NAME=""
|
||||
|
||||
curl --path-as-is -i -s -k -X $'DELETE' \
|
||||
-H "Host: $CONTROL_PLANE_HOST" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
|
||||
-H $'Accept: application/json' \
|
||||
-H $'Content-Type: application/json' \
|
||||
-H $'Content-Length: 35' \
|
||||
-H $'Accept-Encoding: gzip, deflate, br' \
|
||||
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
|
||||
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/rolebindings/$ROLE_BINDING_NAME"
|
||||
```
|
||||
|
||||
|
||||
## References
|
||||
|
||||
{{#ref}}
|
||||
|
||||
Reference in New Issue
Block a user