what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

chklastlog.c

chklastlog.c
Posted Jul 4, 2000

chklastlog.c v1.3 checks lastlog and wtmp for signs of tampering. It will detect most log wiping programs, such as z2 and zap.

Changes: Linux/FreeBSD port, new Red Hat compatibility.
systems | unix
SHA-256 | 5c70a4d3d2f9a170c0fb3ab5fec5a3ac1e7f46bf1c40d812bf7e23dea65d5910

chklastlog.c

Change Mirror Download
/*
Copyright (c) DFN-CERT, Univ. of Hamburg 1994

Univ. Hamburg, Dept. of Computer Science
DFN-CERT
Vogt-Koelln-Strasse 30
22527 Hamburg
Germany

02/20/97 - Minimal changes for Linux/FreeBSD port.
02/25/97 - Another little bit change
12/26/98 - New Red Hat compatibility
Nelson Murilo, nelson@pangeia.com.br
*/


#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <utmp.h>
#if (HAVE_LASTLOG_H)
#include <lastlog.h>
#endif
#include <sys/file.h>

#ifdef __FreeBSD__
#define WTMP_FILENAME "/var/log/wtmp"
#else
#ifndef WTMP_FILENAME
#define WTMP_FILENAME "/var/adm/wtmp"
#endif
#endif

#ifdef __FreeBSD__
#define LASTLOG_FILENAME "/var/log/lastlog"
#else
#ifndef LASTLOG_FILENAME
#define LASTLOG_FILENAME "/var/adm/lastlog"
#endif
#endif

#define TRUE 1
#define FALSE 0


int main() {
int fh_wtmp;
int fh_lastlog;
struct lastlog lastlog_ent;
struct utmp utmp_ent;
struct passwd *pw_ent;
int userid[65535];
int i;
int status = 0;

for (i=0; i<65535; i++)
userid[i]=FALSE;

if ((fh_lastlog=open(LASTLOG_FILENAME,O_RDONLY)) < 0) {
fprintf(stderr, "unable to open lastlog-file %s\n", LASTLOG_FILENAME);
return(1);
}

if ((fh_wtmp=open(WTMP_FILENAME,O_RDONLY)) < 0) {
fprintf(stderr, "unable to open wtmp-file %s\n", WTMP_FILENAME);
close(fh_lastlog);
return(2);
}

while (read (fh_wtmp, &utmp_ent, sizeof (struct utmp)) > 0)
if ( !nonuser(utmp_ent) && strncmp(utmp_ent.ut_line, "ftp", 3) &&
(pw_ent=getpwnam(utmp_ent.ut_name)) != NULL )
if ( userid[pw_ent->pw_uid] == FALSE ) {
lseek(fh_lastlog, (long)pw_ent->pw_uid * sizeof (struct lastlog), 0);
if (read(fh_lastlog, &lastlog_ent, sizeof (struct lastlog)) > 0)
if (lastlog_ent.ll_time == 0)
{
printf("user %s deleted or never loged from lastlog!\n", pw_ent->pw_name);
++status;
}
userid[pw_ent->pw_uid]=TRUE;
}
close(fh_wtmp);
close(fh_lastlog);
return(status);
}

/* minimal funcionality of nonuser() */
nonuser(struct utmp utmp_ent)
{
return (!memcmp(utmp_ent.ut_name, "shutdown", sizeof ("shutdown")));
}
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close