Created
October 16, 2012 14:29
-
-
Save jblyberg/3899599 to your computer and use it in GitHub Desktop.
A very small C wrapper for running shell scripts suid. Pretty dangerous, but handy.
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
#include <unistd.h> | |
#include <errno.h> | |
main( int argc, char ** argv, char ** envp ) | |
{ | |
if( setgid(getegid()) ) perror( "setgid" ); | |
if( setuid(geteuid()) ) perror( "setuid" ); | |
envp = 0; /* blocks IFS attack on non-bash shells */ | |
system( "/path/to/bash/script", argv, envp ); | |
perror( argv[0] ); | |
return errno; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I implemented a utility to make creating executable binaries with suid flag set a bit easier: https://github.com/thiagorb/suid-wrapper
With this utility you can create new binaries without having to write or modify source code, and you also don't need to compile (and therefore no compiler needed).