I am making a Cydia app that has permission to install files. I need to be able to gain root access to /Applications for this. I have looked here, but it was a little unclear. Could anybody explain it a little better?
Thanks!
I am making a Cydia app that has permission to install files. I need to be able to gain root access to /Applications for this. I have looked here, but it was a little unclear. Could anybody explain it a little better?
Thanks!
Never use system with setuid! If, for example, a malicious individual were to change the PATH
to be /tmp:$PATH
, and this person added their own program to /tmp and named it "ls", then even running this simple code would give them root access to your device:
setuid(0); system("ls");
Instead, you should use the exec family of functions, but not execvp/execlp.
you can use this
setuid( 0 );
system( "/path/to/script.sh" );
where path to script is a script in your app that would install files
or
setuid( 0 );
system( "cmd" );
where cmd is a command such as
setuid( 0 ); system( "echo Hello World" );
You can also log this way to the /tmp
directory or any other place.
setuid( 0 ); system( "echo Hello World >> /tmp/install.log" );
setuid (0);
gives it root access and system (cmd);
is the actual command
Be careful on how you use this as root has access to everywhere.