Skip to content

Commit 5fcb29c

Browse files
authored
Update kubernetes-enumeration.md
1 parent 003022d commit 5fcb29c

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

src/pentesting-cloud/kubernetes-security/kubernetes-enumeration.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,130 @@ curl --path-as-is -i -s -k -X $'DELETE' \
678678
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/default/pods/$POD_NAME"
679679
```
680680

681+
### Create a Service Account
682+
683+
```bash
684+
CONTROL_PLANE_HOST=""
685+
TOKEN=""
686+
NAMESPACE="default"
687+
688+
689+
curl --path-as-is -i -s -k -X $'POST' \
690+
-H "Host: $CONTROL_PLANE_HOST" \
691+
-H "Authorization: Bearer $TOKEN" \
692+
-H $'Content-Type: application/json' \
693+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
694+
-H $'Accept: application/json' \
695+
-H $'Content-Length: 109' \
696+
-H $'Accept-Encoding: gzip, deflate, br' \
697+
--data-binary $'{\"apiVersion\":\"v1\",\"kind\":\"ServiceAccount\",\"metadata\":{\"name\":\"secrets-manager-sa-2\",\"namespace\":\"default\"}}\x0a' \
698+
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/$NAMESPACE/serviceaccounts?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
699+
```
700+
701+
702+
### Delete a Service Account
703+
704+
```bash
705+
CONTROL_PLANE_HOST=""
706+
TOKEN=""
707+
SA_NAME=""
708+
NAMESPACE="default"
709+
710+
curl --path-as-is -i -s -k -X $'DELETE' \
711+
-H "Host: $CONTROL_PLANE_HOST" \
712+
-H "Authorization: Bearer $TOKEN" \
713+
-H $'Accept: application/json' \
714+
-H $'Content-Type: application/json' \
715+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
716+
-H $'Content-Length: 35' -H $'Accept-Encoding: gzip, deflate, br' \
717+
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
718+
"https://$CONTROL_PLANE_HOST/api/v1/namespaces/$NAMESPACE/serviceaccounts/$SA_NAME"
719+
```
720+
721+
722+
### Create a Role
723+
724+
```bash
725+
CONTROL_PLANE_HOST=""
726+
TOKEN=""
727+
NAMESPACE="default"
728+
729+
730+
curl --path-as-is -i -s -k -X $'POST' \
731+
-H "Host: $CONTROL_PLANE_HOST" \
732+
-H "Authorization: Bearer $TOKEN" \
733+
-H $'Content-Type: application/json' \
734+
-H $'Accept: application/json' \
735+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
736+
-H $'Content-Length: 203' \
737+
-H $'Accept-Encoding: gzip, deflate, br' \
738+
--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' \
739+
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/roles?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
740+
```
741+
742+
743+
### Delete a Role
744+
745+
```bash
746+
CONTROL_PLANE_HOST=""
747+
TOKEN=""
748+
NAMESPACE="default"
749+
ROLE_NAME=""
750+
751+
curl --path-as-is -i -s -k -X $'DELETE' \
752+
-H "Host: $CONTROL_PLANE_HOST" \
753+
-H "Authorization: Bearer $TOKEN" \
754+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
755+
-H $'Accept: application/json' \
756+
-H $'Content-Type: application/json' \
757+
-H $'Content-Length: 35' \
758+
-H $'Accept-Encoding: gzip, deflate, br' \
759+
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
760+
"https://$$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/roles/$ROLE_NAME"
761+
```
762+
763+
764+
### Create a Role Binding
765+
766+
767+
```bash
768+
CONTROL_PLANE_HOST=""
769+
TOKEN=""
770+
NAMESPACE="default"
771+
772+
curl --path-as-is -i -s -k -X $'POST' \
773+
-H "Host: $CONTROL_PLANE_HOST" \
774+
-H "Authorization: Bearer $TOKEN" \
775+
-H $'Accept: application/json' \
776+
-H $'Content-Type: application/json' \
777+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
778+
-H $'Content-Length: 816' \
779+
-H $'Accept-Encoding: gzip, deflate, br' \
780+
--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' \
781+
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/$NAMESPACE/default/rolebindings?fieldManager=kubectl-client-side-apply&fieldValidation=Strict"
782+
```
783+
784+
### Delete a Role Binding
785+
786+
```bash
787+
CONTROL_PLANE_HOST=""
788+
TOKEN=""
789+
NAMESPACE="default"
790+
ROLE_BINDING_NAME=""
791+
792+
curl --path-as-is -i -s -k -X $'DELETE' \
793+
-H "Host: $CONTROL_PLANE_HOST" \
794+
-H "Authorization: Bearer $TOKEN" \
795+
-H $'User-Agent: kubectl/v1.32.0 (linux/amd64) kubernetes/70d3cc9' \
796+
-H $'Accept: application/json' \
797+
-H $'Content-Type: application/json' \
798+
-H $'Content-Length: 35' \
799+
-H $'Accept-Encoding: gzip, deflate, br' \
800+
--data-binary $'{\"propagationPolicy\":\"Background\"}\x0a' \
801+
"https://$CONTROL_PLANE_HOST/apis/rbac.authorization.k8s.io/v1/namespaces/$NAMESPACE/rolebindings/$ROLE_BINDING_NAME"
802+
```
803+
804+
681805
## References
682806

683807
{{#ref}}

0 commit comments

Comments
 (0)