Last active
October 28, 2017 17:46
-
-
Save rweichler/82da580dfe1c23f9ed3b853a3cab74f8 to your computer and use it in GitHub Desktop.
setuid
This file contains hidden or 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
| #!/bin/sh | |
| #set permissions of setuid binary | |
| chown root:wheel /path/to/setuid | |
| chmod 6755 /path/to/setuid |
This file contains hidden or 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
| #include <unistd.h> | |
| int main(int argc, char ** argv) | |
| { | |
| uid_t olduid = getuid(); | |
| gid_t oldgid = getgid(); | |
| setuid(0); | |
| setgid(0); | |
| int result = execv(argv[1], &argv[1]); | |
| setuid(olduid); | |
| setgid(oldgid); | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment