Created
February 6, 2018 02:04
-
-
Save craig-m/714a465d7e7e4ae739ff1311850a9228 to your computer and use it in GitHub Desktop.
a setuid c wrapper for /sbin/reboot
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
Setuid reboot wrapper script | |
The reboot_setuid.c file (11 lines): | |
``` | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main() | |
{ | |
setuid( 0 ); | |
system ("/sbin/reboot now"); | |
return 0; | |
} | |
``` | |
Compile + install: | |
gcc -static -fpic -fpie reboot_setuid.c -o reboot_setuid | |
sudo chown root:root reboot_setuid | |
sudo chmod 0755 reboot_setuid | |
sudo chmod +s reboot_setuid | |
sudo mv -v reboot_setuid /usr/local/bin/reboot_setuid | |
sudo chattr +i /usr/local/bin/reboot_setuid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment