home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3243
< prev
next >
Wrap
Internet Message Format
|
1991-04-26
|
2KB
From: muts@fysak.fys.ruu.nl (Peter Mutsaers)
Newsgroups: alt.sources
Subject: another 'su encancer'
Message-ID: <muts.672650807@fysaj>
Date: 26 Apr 91 07:26:47 GMT
Now that we are discussing a su encancer etc., here is a 'root' program that
I've been using the last 1.5 year.
The syntax is 'root command [args]' and runs one command with su privilege.
It is quite safe, and checks if the uid is right. (only works for one user).
Without args it executes a shell with su privilege.
Of course this program must also be owned by root and be setuid.
Change the number on the first line of main() to your own uid.
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Peter Mutsaers <muts@fysaq> on Fri Apr 26 09:30:05 1991
#
# This archive contains:
# root.c
#
LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH
echo x - root.c
cat >root.c <<'@EOF'
#include <stdio.h>
#include <string.h>
int main(argc, argv)
int argc;
char *argv[];
{
if (1030 != getuid()) {
fprintf(stderr,"sorry...");
sleep(2);
fprintf(stderr,"\n");
exit(1);
}
setuid(geteuid());
setgid(getegid());
switch (argc) {
case 1:
execl("/bin/csh", "csh", (char *) 0);
perror("csh");
exit(1);
default:
execvp(argv[1], &argv[1]);
perror(argv[1]);
exit(1);
}
}
@EOF
chmod 644 root.c
exit 0
--
Peter Mutsaers email: muts@fysap.fys.ruu.nl
Rijksuniversiteit Utrecht muts@fys.ruu.nl
Princetonplein 5 tel: (+31)-(0)30-533880
3584 CG Utrecht, Netherlands