msgbartop
I will happily conduct a FREE basic web security scan for any genuine organization interested in my services to point out whether or not I can find vulnerabilities in your application. Just contact me.
Need a PHP Programmer, PHP staff or project manager? Contact me now.
msgbarbottom

03 Oct 09 Linux C setuid setgid tutorial

Here’s a very brief example of how to use setuid() and setgid() functions in your C program.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(void)
{

int current_uid = getuid();
printf(“My UID is: %d. My GID is: %d\n”, current_uid, getgid());
system(“/usr/bin/id”);

if (setuid(0))
{

perror(“setuid”);
return 1;

}

//I am now root!
printf(“My UID is: %d. My GID is: %d\n”, getuid(), getgid());
system(“/usr/bin/id”);

//Time to drop back to regular user priviledges
setuid(current_uid);
printf(“My UID is: %d. My GID is: %d\n”, getuid(), getgid());
system(“/usr/bin/id”);

return 0;

}

The program above should be pretty self explainatory, now:

adam@staging:~$ gcc -O2 -ggdb -o setuid setuid.c
adam@staging:~$ ls -al setuid
-rwxr-xr-x 1 adam adam 9792 2009-10-03 18:09 setuid
adam@staging:~$

(more…)

Tags: , , , , ,

03 Apr 09 shPanel – the Linux System and Hosting Control Panel

shPanel is now in production. You should see http://www.adamsinfo.com/shpanel-linux-system-hosting-control-panel/ to preorder! I welcome any ideas/comments

Tags: , , , ,