Re: setuid (stupid question)
From: Wojtek Walczak (gminick@hacker.pl)
Date: 03/22/03
- Next message: Kasper Dupont: "Re: setuid (stupid question)"
- Previous message: Kasper Dupont: "Re: setuid (stupid question)"
- In reply to: Julien Le Goff: "setuid (stupid question)"
- Next in thread: Kasper Dupont: "Re: setuid (stupid question)"
- Reply: Kasper Dupont: "Re: setuid (stupid question)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Wojtek Walczak <gminick@hacker.pl> Date: Sat, 22 Mar 2003 19:36:51 +0000 (UTC)
Dnia Sat, 22 Mar 2003 19:00:54 +0100, Julien Le Goff napisał(a):
> I'm trying to understand how suid works, but I have some problems. Here is
> what I understood: when a program is setuid, a user can execute it as if
> he were the user who owns it.
[...]
> If I execute the script as if I were root, then I should be able to see
> inside /root/, shouldn't I?
SUID bit won't work with shell scripts, but you can always write it in C:
% cat c.c
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
int main(void)
{
DIR * dir;
struct dirent *dirent;
if((dir = opendir("/root"))==NULL) {
fprintf(stderr, "opendir() error: %s\n", strerror(errno));
exit(errno);
}
while((dirent=readdir(dir))) {
printf("%s\n", dirent->d_name);
}
if(closedir(dir) == -1) {
fprintf(stderr, "closedir() error: %s\n", strerror(errno));
exit(errno);
}
return 0;
}
% gcc c.c -oeles
% ./eles
opendir() error: Permission denied
% su
Password:
# chown root ./eles
# chmod +s ./eles
# exit
% ./eles|wc -l
35
%
...as you can see - now it works.
-- [ Wojtek Walczak - gminick (at) underground.org.pl ] [ <http://gminick.linuxsecurity.pl/> ] [ "...rozmaite zwroty, matowe od patyny dawnosci." ]
- Next message: Kasper Dupont: "Re: setuid (stupid question)"
- Previous message: Kasper Dupont: "Re: setuid (stupid question)"
- In reply to: Julien Le Goff: "setuid (stupid question)"
- Next in thread: Kasper Dupont: "Re: setuid (stupid question)"
- Reply: Kasper Dupont: "Re: setuid (stupid question)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|