Sfortunatamente, non mi sembra di capire un concetto minore nel libro "Art of Exploitation", riguardante l'overflow dell'heap: una nuova shell di root viene aggiunta al file passwd. Da pagina 168 :
However, the nature of this particular heap overflow exploit won’t allow that exact line to be written to
/etc/passwd, because the string must end with/etc/passwd. However, if that filename is merely appended to the end of the entry, the passwd file entry would be incorrect. This can be compensated for with the clever use of a symbolic file link, so the entry can both end with/etc/passwdand still be a valid line in the password file. Here’s how it works:reader@hacking:~/booksrc $ mkdir /tmp/etc reader@hacking:~/booksrc $ ln -s /bin/bash /tmp/etc/passwd reader@hacking:~/booksrc $ ls -l /tmp/etc/passwd lrwxrwxrwx 19 2007-09-09 16:25 /tmp/etc/passwd -> /bin/bashNow
/tmp/etc/passwdpoints to the login shell /bin/bash. This means that a valid login shell for the password file is also/tmp/etc/passwd, making the following a valid password file line:myroot:XXq2wKiyI43A2:0:0:me:/root:/tmp/etc/passwdThe values of this line just need to be slightly modified so that the portion before
/etc/passwdis exactly 104 bytes long:
-
Comprendo la parte quando l'autore afferma che
/tmp/etc/passwdpuò essere usato per creare un link a/bin/bash, ma non capisco come funzioni realmente (non c'è spiegazione dimkdir,ln -secc. -
Inoltre, questo è probabilmente molto semplice, ma perché l'autore afferma che: "i valori di questa linea devono essere leggermente modificati in modo che la parte prima che
/etc/passwdsia esattamente lungo 104 byte "? Perche '/tmpè stato omesso nella riga precedente (es. perché non è specificato:" la parte prima di/tmp/etc/passwdè esattamente 104 byte lungo "? Nella pagina successiva, il nuovo account root è scritto in/etc/passwd, ma perché no in/tmp/etc/passwd? Ho controllato, e ci sono 2 diverse cartelleetcsul sistema, perché è così?