|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T u
Length: 1721 (0x6b9) Types: TextFile Names: »user.chk.c«
└─⟦4f9d7c866⟧ Bits:30007245 EUUGD6: Sikkerheds distributionen └─⟦3da311d67⟧ »./cops/1.04/cops_104.tar.Z« └─⟦6a2577110⟧ └─⟦4f9d7c866⟧ Bits:30007245 EUUGD6: Sikkerheds distributionen └─⟦6a2577110⟧ »./cops/1.04/cops_104.tar« └─⟦this⟧ »cops_104/src/user.chk.c«
#include <stdio.h> #include <pwd.h> #include <sys/types.h> #include <sys/stat.h> /* Any file writable by all will be flagged */ #define DMODE 002 #define MODE1 004 #define MODE2 040 /* #define DMODE2 020 */ /* potentially dangerous files */ char *ftable[] = { "rhosts", "profile", "login", "logout", "cshrc", "bashrc", "kshrc", "tcshrc", "netrc", "forward", "dbxinit", "distfile", "exrc", "emacsrc" }; char *ft; char *ftr, *malloc(); char generic_file[100]; main(argc,argv) int argc; char **argv; { register int fmode; register int index; struct passwd *pp; static struct stat statb; if (argc != 1) { printf("Usage: %s\n",argv[0]); exit(1); } ft = malloc(100); ftr = malloc(100); while ((pp = getpwent()) != (struct passwd *)0) { if (stat(pp->pw_dir,&statb) < 0) { continue; } index = 0; /* * Use the home-dir, and add on each potential security threat * file to the path one at a time. Then check each file to see * if it breaks with the modes established up above * */ for (ft = ftable[index]; index < 14; ft = ftable[++index]) { if (strlen(pp->pw_dir) != 1) sprintf(generic_file, "%s/.%s", pp->pw_dir,ft); else sprintf(generic_file, "%s.%s", pp->pw_dir,ft); if (stat(generic_file,&statb) < 0) continue; if (statb.st_mode & DMODE) printf("Warning! User %s:\t%s is mode \t0%3.3o!\n", pp->pw_name,generic_file,statb.st_mode&~S_IFMT); /* check for mode on .netrc files; should be non-readable */ if (!strcmp("netrc", ftable[index])) if (statb.st_mode & MODE1 || statb.st_mode & MODE2) printf("Warning! User %s:\t%s is readable; mode \t0%3.3o!\n", pp->pw_name,generic_file,statb.st_mode&~S_IFMT); } } exit(0); }