exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

stasis.c

stasis.c
Posted Jan 28, 2000
Authored by Mixter | Site mixter.void.ru

Stasis is a tool to fool atime/mtime timestamp checking. It records the timestamp of files, then periodically finds atime/mtime changes and restores the old timestamps, as if the files were never accessed / changed.

SHA-256 | eb63609efc1350e5ecc18faffda1b59339dc10d5a460127fa971feb32673d225

stasis.c

Change Mirror Download
/*
stasis.c - timestamp suspension tool - 01/00 by Mixter

this ia a simple file monitoring tool that records the timestamp of
files, then periodically finds atime/mtime changes and restores the
old timestamps, as if the files were never accessed / changed.
this shows that timestamp monitoring is not very foolproof, and can
be used to fool some lame admins and script kiddies' atime/mtime scan
based protection scripts for eggdrop tcl and other programs easily.

compile with -DBSD if your system doesn't have working utime()...

#include <std_disclaimer.h>
#include <lame_advertisement.h>
http://mixter.void.ru / http://mixtersecurity.tripod.com

*/

#define MINUTES_DELAY 3 /* delay between file scans */
#define LOGFILE "/var/tmp/.s3kr1t" /* optional to define */

#define DELAY MINUTES_DELAY * 60

#include <stdio.h>
#include <unistd.h>
#include <utime.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>

#ifndef BSD /* OS specific utime functions */
#include <stdlib.h>
#define UTIME_ENT struct utimbuf
#define UTIME_ATIME actime
#define UTIME_MTIME modtime
#define UTIME_F utime
#else
#include <malloc.h>
#include <sys/time.h>
#define UTIME_ENT struct timeval
#define UTIME_ATIME tv_sec
#define UTIME_MTIME tv_usec
#define UTIME_F utimes
#endif

#ifdef LOGFILE
void
log (char *a, char *b)
{
FILE *ph1le = fopen (LOGFILE, "a");
fprintf (ph1le, "%s %s\n", a, b);
fclose (ph1le);
}
#endif

struct fhash /* filename / time association struct */
{
char filename[255];
UTIME_ENT timebuf;
struct fhash *next;
}
*fstart, *fcurr;

int
main (int argc, char **argv)
{
FILE *list;
char buffer[512];
struct stat statbuf;
int counter = 0;

fstart = malloc (sizeof (struct fhash));
fstart->next = NULL;
fcurr = fstart;

if (argc != 2)
{
doh:
fprintf (stderr, "Usage: %s <file list>\n", argv[0]);
fprintf (stderr, "Make a file list by typing something like: find / -type -f > list.txt\n");
exit (0);
}

if ((list = fopen (argv[1], "r")) == NULL)
goto doh;

/* read filename timestamps */
while (fgets (buffer, 255, list) != NULL)
{
buffer[strlen(buffer)-1] = '\0'; /* pesky \n's */
if (lstat (buffer, &statbuf) != 0)
{
#ifdef LOGFILE
log ("ignoring non existant file: ", buffer);
#endif
continue;
}
strncpy (fcurr->filename, buffer, 254);
fcurr->timebuf.UTIME_ATIME = statbuf.st_atime;
fcurr->timebuf.UTIME_MTIME = statbuf.st_mtime;
fcurr->next = malloc (sizeof (struct fhash));
fcurr = fcurr->next;
counter++;
}

free (fcurr->next);
fcurr->next = NULL;

printf ("Going into background, monitoring %d files\n", counter);

if (fork())
exit(0);

/* comparison routine */
while (1)
{
sleep (DELAY);
for (fcurr = fstart; fcurr->next != NULL; fcurr = fcurr->next)
{
if (lstat (fcurr->filename, &statbuf) != 0)
{
#ifdef LOGFILE
log ("file has been deleted: ", fcurr->filename);
#endif
continue;
}
if (fcurr->timebuf.UTIME_ATIME != statbuf.st_atime)
{
#ifdef LOGFILE
log ("atime change reverted: ", fcurr->filename);
#endif
UTIME_F (fcurr->filename, &fcurr->timebuf);
}
if (fcurr->timebuf.UTIME_MTIME != statbuf.st_mtime)
{
#ifdef LOGFILE
log ("mtime change reverted: ", fcurr->filename);
#endif
UTIME_F (fcurr->filename, &fcurr->timebuf);
}
}
}

return 0;
}
Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    0 Files
  • 13
    Aug 13th
    0 Files
  • 14
    Aug 14th
    0 Files
  • 15
    Aug 15th
    0 Files
  • 16
    Aug 16th
    0 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    0 Files
  • 20
    Aug 20th
    0 Files
  • 21
    Aug 21st
    0 Files
  • 22
    Aug 22nd
    0 Files
  • 23
    Aug 23rd
    0 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 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