Skip to content

Instantly share code, notes, and snippets.

@craig-m
Created February 6, 2018 02:04
Show Gist options
  • Save craig-m/714a465d7e7e4ae739ff1311850a9228 to your computer and use it in GitHub Desktop.
Save craig-m/714a465d7e7e4ae739ff1311850a9228 to your computer and use it in GitHub Desktop.
a setuid c wrapper for /sbin/reboot
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