WTMP file

From: BORJA RUIZ CASTRO MORON (padre_at_fedro.ugr.es)
Date: 11/05/03

  • Next message: einstein, dhtm: "Re[2]: ms03-043 questions"
    To: vuln-dev@securityfocus.com
    Date: Wed, 05 Nov 2003 17:58:42 +0100
    
    

    Hi! I´m coding an aplication for remove user entries in WTMP.
    I think the code is OK,but it does not work! :P
    Could somebody take a look please?

    Thanks a lot! :D

     ----------------------------------------------
    #include <stdio.h>
    #include <fcntl.h>
    #include <pwd.h>
    #include <unistd.h>
    #include <utmp.h>
    #include <sys/time.h>

    #define WTMP "/var/log/wtmp"

    int main (int argc, char **argv){

    int fd;

    struct passwd *acceso;
    struct utmp rosita;
    setutent();

    if (argc<2) {
     printf("Usage: %s <user>\n",argv[0]);
     exit(-1);
     }
    if((fd=open(WTMP,O_WRONLY))<0) {
     printf("\nFile not found.\n\n");
     exit(-1);
     }

    if ((acceso=getpwnam(argv[1]))==NULL) {
     printf("\nUnknow user :P\n\n");
     exit(-1);
     }

    // Our info

    rosita.ut_type=DEAD_PROCESS;
    memset(rosita.ut_line,0,UT_LINESIZE);
    memset(rosita.ut_user,0,UT_NAMESIZE);
    memset(rosita.ut_host,0,UT_HOSTSIZE);
    rosita.ut_time=0;

    while((acceso=getpwent())!=NULL) {

    lseek(fd,sizeof(struct utmp)*acceso->pw_uid,SEEK_SET);
    pututline(&rosita);
    }

    endutent();

    close(fd);
    return(0);
    }


  • Next message: einstein, dhtm: "Re[2]: ms03-043 questions"