global security disclosure

logchk.c

logchk.c
Posted Nov 5, 1999
Authored by shadowpenguin

If the access log is wiped by using the log wiper, the logs are not displayed by the last command. However, the general log wipers such as "zap" write the null on the specified entry of logfile, so you can check the log files whether the logs are wiped. This utility shows the all entries, you can analyze the logfile.

systems | unix
MD5 | a85be3f58485ed34d9b3f9c71463f0b8

logchk.c

Change Mirror Download
/*=============================================================================
Log Viewer&Checker Version 1.30
The Shadow Penguin Security (http://shadowpenguin.backsection.net)
Written by UNYUN (shadowpenguin@backsection.net)
=============================================================================
*/
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/file.h>
#include <fcntl.h>
#include <utmp.h>
#include <utmpx.h>
#include <lastlog.h>
#include <pwd.h>

#define UTMP_NAME "/var/adm/utmp"
#define UTMPX_NAME "/var/adm/utmpx"
#define WTMP_NAME "/var/adm/wtmp"
#define WTMPX_NAME "/var/adm/wtmpx"
#define LASTLOG_NAME "/var/adm/lastlog"

void display_utmp(char *fn)
{
int f;
struct utmp utmp_ent;
char buf[10],buf2[32];

if ((f=open(fn,O_RDONLY))>=0){
printf("\n\n[%s]\n",fn);
printf("%-15s %-6s %-15s %-4s %-15s\n","Name","id","Line","Type","Time");
printf("--------------------------------------------------------------------------\n");
while(read (f, &utmp_ent, sizeof (utmp_ent))>0){
strncpy(buf,utmp_ent.ut_id,4);
buf[4]=0;
strncpy(buf2,utmp_ent.ut_user,8);
buf[8]=0;
printf("%-15s %-6s %-15s %4d %s",buf2,buf,utmp_ent.ut_line,utmp_ent.ut_type,asctime(localtime(&utmp_ent.ut_time)));
}
close(f);
}else
printf("Logfile %s can not be opened\n",WTMP_NAME);
}

void display_utmpx(char *fn)
{
int f;
struct utmpx utmpx_ent;
char buf[10];

if ((f=open(fn,O_RDONLY))>=0){
printf("\n\n[%s]\n",fn);
printf("%-15s %-6s %-15s %-4s %-15s\n","Name","id","Line","Type","Host");
printf("--------------------------------------------------------------\n");
while(read (f, &utmpx_ent, sizeof (utmpx_ent))> 0 ) {
strncpy(buf,utmpx_ent.ut_id,4);
buf[4]=0;
printf("%-15s %-6s %-15s %4d %-15s\n",utmpx_ent.ut_user,buf,utmpx_ent.ut_line,utmpx_ent.ut_type,utmpx_ent.ut_host);
}
close(f);
}else
printf("Logfile %s can not be opened\n",WTMP_NAME);
}

void display_wtmp(char *fn)
{
int f;
struct utmp utmp_ent;
char buf[10],buf2[32];

if ((f=open(fn,O_RDONLY))>=0){
printf("\n\n[%s]\n",fn);
printf("%-15s %-6s %-15s %-4s %-15s\n","Name","id","Line","Type","Time");
printf("--------------------------------------------------------------\n");
while(read (f, &utmp_ent, sizeof (utmp_ent))> 0){
strncpy(buf,utmp_ent.ut_id,4);
buf[4]=0;
strncpy(buf2,utmp_ent.ut_user,8);
buf[8]=0;
printf("%-15s %-6s %-15s %4d %s",buf2,buf,utmp_ent.ut_line,utmp_ent.ut_type,asctime(localtime(&utmp_ent.ut_time)));
}
close(f);
}else
printf("Logfile %s can not be opened\n",WTMP_NAME);
}
void display_wtmpx(char *fn)
{
int f;
struct utmpx utmpx_ent;
char buf[10];

if ((f=open(fn,O_RDONLY))>=0){
printf("\n\n[%s]\n",fn);
printf("%-15s %-6s %-15s %-4s %-15s\n","Name","id","Line","Type","Host");
printf("--------------------------------------------------------------\n");
while(read (f, &utmpx_ent, sizeof (utmpx_ent))>0){
strncpy(buf,utmpx_ent.ut_id,4);
buf[4]=0;
printf("%-15s %-6s %-15s %4d %-15s\n",utmpx_ent.ut_user,buf,utmpx_ent.ut_line,utmpx_ent.ut_type,utmpx_ent.ut_host);
}
close(f);
}else
printf("Logfile %s can not be opened\n",WTMPX_NAME);
}

void display_lastlog(char *fn)
{
int f,uid;
struct lastlog newll;
struct passwd *pwd;

if ((f=open(fn, O_RDONLY)) >= 0) {
printf("\n\n[%s]\n",LASTLOG_NAME);
printf("%-10s : %-15s %-15s %s\n","Name","Host","Line","Time");
printf("-----------------------------------------------------------------------\n");
uid=0;
while(read (f, &newll, sizeof (newll))>0){
uid++;
if (newll.ll_time==0) continue;
pwd=getpwuid(uid-1);
printf("%-10s : %-15s %-15s %s",pwd->pw_name,newll.ll_host,newll.ll_line,asctime(localtime(&newll.ll_time)));
}
close(f);
}else
printf("Logfile %s can not be opened\n",LASTLOG_NAME);
}
main()
{
display_wtmp (WTMP_NAME);
display_wtmpx(WTMPX_NAME);
display_utmp (UTMP_NAME);
display_utmpx(UTMPX_NAME);
display_lastlog(LASTLOG_NAME);
}


Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close