Created
August 21, 2018 11:32
-
-
Save jacob-faber/8d2deebb9f779f28cf32eb2edaf56d66 to your computer and use it in GitHub Desktop.
Setuid example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SUID is ignored for interpreted languages (shell scripts, etc...) | |
tee setuid-example.c <<EOF | |
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char** argv) { | |
printf("%d", geteuid()); | |
return 0; | |
} | |
EOF | |
echo "---------------------------------" | |
gcc -o setuid-example setuid-example.c | |
echo "Setuid with default user: $(./setuid-example)" | |
sudo chown root:root ./setuid-example && sudo chmod u+s ./setuid-example | |
echo "Setuid with root user: $(./setuid-example)" | |
sudo rm ./setuid-example ./setuid-example.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment