How to remove utmp/wtmp entries?

How to remove utmp/wtmp entries?

Post by Peter Beckm » Thu, 01 Aug 1996 04:00:00



I want to know if there is some code out there that allows you to parse
through the wtmp entries (and utmp if it's the same format) and delete or
add entries at will.  If so, please mail it to me (and post it, as others
may be interested) with comments if possible.  

Thanks!

Peter
--
Peter Beckman                     Independent Consultant

 
 
 

How to remove utmp/wtmp entries?

Post by Andru Luvi » Thu, 01 Aug 1996 04:00:00


: I want to know if there is some code out there that allows you to parse
: through the wtmp entries (and utmp if it's the same format) and delete or
: add entries at will.  If so, please mail it to me (and post it, as others
: may be interested) with comments if possible.  

if you have write access to utmp, it's not difficult... it's a sequential
file of fixed length records of type struct utmp... man utmp to see
it's makeup...

andru

 
 
 

How to remove utmp/wtmp entries?

Post by Scott G. Ha » Fri, 02 Aug 1996 04:00:00


[I trimmed the newsgroup list quite a bit, but it is still long..]



>: I want to know if there is some code out there that allows you to parse
>: through the wtmp entries (and utmp if it's the same format) and delete or
>: add entries at will.  If so, please mail it to me (and post it, as others
>: may be interested) with comments if possible.  

>if you have write access to utmp, it's not difficult... it's a sequential
>file of fixed length records of type struct utmp... man utmp to see
>it's makeup...

I think you would rather want to use one of the system calls defined for this:

        getutent(), getutid(),  getutline(),  pututline(),  setutent(),
        endutent(), utmpname() - access utmp file entry

        #include <utmp.h>

Check the man page under: getut

--
"It was our last, best hope for peace -- it failed.       | Scott G. Hall
Now it's our last best hope." (Babylon-5 opener)          | Lucent Technologies
----------------------------------------------------------| Bell Labs - BCS

 
 
 

How to remove utmp/wtmp entries?

Post by Birger Bli » Tue, 06 Aug 1996 04:00:00



>I want to know if there is some code out there that allows you to parse
>through the wtmp entries (and utmp if it's the same format) and delete or
>add entries at will.  If so, please mail it to me (and post it, as others
>may be interested) with comments if possible.  

>Thanks!

>Peter
>--
>Peter Beckman                     Independent Consultant


Use /usr/lib/acct/fwtmp to convert utmp,wtmp to ascii.
You can edit the text and convert to data , using fwtmp -ic , but you may lose
new records.
euas78c17% /usr/lib/acct/fwtmp < /var/adm/wtmp | grep ftp
euabbt   ftp? ftp4404           4404  7 0000 0000 835705497 Tue Jun 25 14:24:57 1996
         ftp? ftp4404           4404  8 0000 0000 835705531 Tue Jun 25 14:25:31 1996
euabbt   ftp? ftp14505         14505  7 0000 0000 838641036 Mon Jul 29 13:50:36 1996
         ftp? ftp14505         14505  8 0000 0000 838641064 Mon Jul 29 13:51:04 1996

To clean all old entrys from wtmp , copy utmp to wtmp.  

--
--

UAB/Z/IP, Unix Systems Mgmt       Phone: +46 8 7274183
Ericsson AXE Research and Development, Armborstv 14,  S-125 25 Alvsjo, Sweden
--

 
 
 

How to remove utmp/wtmp entries?

Post by J.J.Farre » Wed, 07 Aug 1996 04:00:00





>: I want to know if there is some code out there that allows you to parse
>: through the wtmp entries (and utmp if it's the same format) and delete or
>: add entries at will.  If so, please mail it to me (and post it, as others
>: may be interested) with comments if possible.  

>if you have write access to utmp, it's not difficult... it's a sequential
>file of fixed length records of type struct utmp... man utmp to see
>it's makeup...

Modifying utmp directly can lead to substantial problems, since "utmp"
consists of two files which must be kept in step. There are library
routines provided to modify utmp - man getut - and I strongly recommend
that you use them. The versions in early releases of SVR4 were rather
buggy and inefficient, though still safer than modifying utmp by hand.
The ones in later versions (from SVR4.2MP, I think) are almost error-free
and efficient.

            My opinions; I do not speak for my employer.

 
 
 

How to remove utmp/wtmp entries?

Post by Ajay Kumar Gumma » Thu, 08 Aug 1996 04:00:00


I have written programs in C, that remove the desired entries from the utmp and wtmp files.  If you want a copy of the same, email me.

bye
. . . . .

Ajay

 
 
 

How to remove utmp/wtmp entries?

Post by Marcus J. Ran » Fri, 09 Aug 1996 04:00:00


        Do an alta vista search for "cloak.c" which has code
for clearing utmp and wtmp entries.

mjr.
--
Chief Scientist, V-ONE Corporation  --  "Security for a connected world"
work            http://www.v-one.com
personal        http://www.clark.net/pub/mjr/mjr-top.html

 
 
 

How to remove utmp/wtmp entries?

Post by Richard C. Gaine I » Fri, 09 Aug 1996 04:00:00



Quote:>    Do an alta vista search for "cloak.c" which has code
>for clearing utmp and wtmp entries.
>mjr.
>--
>Chief Scientist, V-ONE Corporation  --  "Security for a connected world"
>work            http://www.v-one.com
>personal        http://www.clark.net/pub/mjr/mjr-top.html

The following is for Solaris2.  It takes a username as an argument and
removes all entries from [uw]tmp [uw]tmpx and lastlog.  

rick

#include <stdio.h>
#include <fcntl.h>
#include <utmpx.h>
#include <utmp.h>
#include <lastlog.h>
#include <pwd.h>

void kill_tmp(char *, char *);
void kill_tmpx(char *, char *);
void kill_lastlog(char *, char *);

int f;
char buf[40];

main(int argc, char **argv)
{

        if (argc!=2)
        {
                puts("Error!");
                exit(1);
        }

        kill_tmp(UTMP_FILE,*(argv +1));
        kill_tmp(WTMP_FILE,*(argv +1));
        kill_tmpx(UTMPX_FILE,*(argv +1));
        kill_tmpx(WTMPX_FILE,*(argv +1));
        kill_lastlog("/var/adm/lastlog",*(argv +1));

Quote:}

void kill_tmp(char *name, char *who)
{
        struct utmp utmp_ent;

        if ((f=open(name,O_RDWR))>=0)
        {
                while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
                        if (!strncmp(utmp_ent.ut_name,who,strlen(who)))
                        {
                                bzero((char *)&utmp_ent,sizeof( utmp_ent ));
                                lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
                                write (f, &utmp_ent, sizeof (utmp_ent));
                        }
                close(f);
        }
        else
        {
                sprintf(buf,"write %s",name);
                perror(buf);
        }

Quote:}

void kill_tmpx(char *name, char *who)
{
        struct utmpx utmp_ent;

        if ((f=open(name,O_RDWR))>=0)
        {      
                while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
                        if (!strncmp(utmp_ent.ut_user,who,strlen(who)))
                        {
                                bzero((char *)&utmp_ent,sizeof( utmp_ent ));
                                lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
                                write (f, &utmp_ent, sizeof (utmp_ent));
                        }
                close(f);
        }
        else
        {
                sprintf(buf,"write %s",name);
                perror(buf);
        }

Quote:}

void kill_lastlog(char *name, char *who)
{
        struct passwd *pwd;
        struct lastlog newll;

        if ((pwd=getpwnam(who))==NULL)
        {
                printf("Can't get user info for %s in /etc/passwd\n",who);
                printf("lastlog not changed.\n");
                return;
        }
        if ((f=open(name, O_RDWR)) >= 0)
        {
                lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
                bzero((char *)&newll,sizeof( newll ));
                write(f, (char *)&newll, sizeof( newll ));
                close(f);
        }
        else
        {
                sprintf(buf,"write %s",name);
                perror(buf);
        }

Quote:}

 
 
 

How to remove utmp/wtmp entries?

Post by Wes Fel » Mon, 12 Aug 1996 04:00:00


Quote:

> The following is for Solaris2.  It takes a username as an argument and
> removes all entries from [uw]tmp [uw]tmpx and lastlog.  

> rick

Neither "cloak.c" nor rick's code worked for my SunOS 4.1.3 UNIX, but a
program called Zap.c did.  It worked entirely too well, removing all signs
that I had ever been on the system.  After entering "Zap UserName", the
program took all records in utmp, wtmp, and lastlog so it looked like
UserName had "Never Logged In".

-Wes

 
 
 

How to remove utmp/wtmp entries?

Post by Thomas H. Ptac » Tue, 13 Aug 1996 04:00:00



Quote:>that I had ever been on the system.  After entering "Zap UserName", the
>program took all records in utmp, wtmp, and lastlog so it looked like
>UserName had "Never Logged In".

Thus proving a point that's been understood amongst Unix professionals for
quite some time: the standard Unix accounting mechanisms provide
absolutely no real accountability.

There's no magic in any of this. This information is stored in regular
files. The world doesn't end if you write to one of them.

--
-----------------------------------------------------------------------------
Thomas Ptacek at The rdist Organization,
Chicagoland's only kung-fu guerilla terrorist computer security organization.

"If you're so special, why aren't you dead?"

 
 
 

How to remove utmp/wtmp entries?

Post by Wes Felt » Tue, 13 Aug 1996 04:00:00


Here is the site for the Zap.c program I mentioned that removes logged
entries from utmp, wtmp, and lastlog.  It is very easy to modify to just
remove all logged entries from any one of the three logs.

-Wes

 
 
 

How to remove utmp/wtmp entries?

Post by Andreas Gra » Tue, 13 Aug 1996 04:00:00




> >I want to know if there is some code out there that allows you to parse
> >through the wtmp entries (and utmp if it's the same format) and delete or
> >add entries at will.  If so, please mail it to me (and post it, as others
> >may be interested) with comments if possible.

> >Thanks!

> >Peter
> >--
> >Peter Beckman                     Independent Consultant

> Use /usr/lib/acct/fwtmp to convert utmp,wtmp to ascii.
> You can edit the text and convert to data , using fwtmp -ic , but you may lose

Or you check the security faq - there you'll find a neat little
c program to do the job you want.

--

2 rules to success in life:  1. Don't tell people everything you know.

 
 
 

How to remove utmp/wtmp entries?

Post by thoug » Wed, 14 Aug 1996 04:00:00



>Neither "cloak.c" nor rick's code worked for my SunOS 4.1.3 UNIX, but a
>program called Zap.c did.  It worked entirely too well, removing all signs
>that I had ever been on the system.  After entering "Zap UserName", the
>program took all records in utmp, wtmp, and lastlog so it looked like
>UserName had "Never Logged In".

>-Wes

        Marry is the best I have seen.  And that includes the one I
        wrote for Linux....

        ftp://ftp.infonexus.com/pub/SourceAndShell/LogCleaners/UtmpAndWtmp/ma...

--

`da guild

 
 
 

How to remove utmp/wtmp entries?

Post by Gary Howlan » Wed, 14 Aug 1996 04:00:00



> > The following is for Solaris2.  It takes a username as an argument and
> > removes all entries from [uw]tmp [uw]tmpx and lastlog.

> > rick

> Neither "cloak.c" nor rick's code worked for my SunOS 4.1.3 UNIX, but a
> program called Zap.c did.  It worked entirely too well, removing all signs
> that I had ever been on the system.  After entering "Zap UserName", the
> program took all records in utmp, wtmp, and lastlog so it looked like
> UserName had "Never Logged In".

Here's one in Perl, which should be easier to modify for other OSs than
a C implementation.  Haven't bothered making it use ARGV yet, but if you
can't do that yourself then you don't deserve to use the program :-)

#!/usr/local/bin/perl -w

# open(FH, '+< /var/log/wtmp');
open(FH, '+< /var/run/utmp');

my $entry = '';
while (read(FH, $entry, 36))
{
        my ($line, $name, $host, $time);
        ($line, $name, $host, $time) = unpack("a8 a8 a16 L", $entry);

        $_ = $name;
        if (m/gary/)
        {
                seek(FH, -36, 1);
                print FH "\0"x36;
                seek(FH,0,1);
        }

Quote:}

Gary
--

Key fingerprint =  0C FB 60 61 4D 3B 24 7D  1C 89 1D BE 1F EE 09 06
^S
^A^Aoft FAT filesytem is extremely robust, ^Mrarely suffering from^T^T
 
 
 

How to remove utmp/wtmp entries?

Post by Gregory Row » Wed, 14 Aug 1996 04:00:00




> >that I had ever been on the system.  After entering "Zap UserName", the
> >program took all records in utmp, wtmp, and lastlog so it looked like
> >UserName had "Never Logged In".
> Thus proving a point that's been understood amongst Unix professionals for
> quite some time: the standard Unix accounting mechanisms provide
> absolutely no real accountability.
> There's no magic in any of this. This information is stored in regular
> files. The world doesn't end if you write to one of them.

I have to laugh because none of these programs will work under HP-UX.  sunos
allowed anybody to write to utmp and wtmp, which proves your point that it
provides no real accountability.  Under HP-UX, any program that needs to
modify wtmp or utmp is either run by root or SUID root, making it more secure
and making accounting actually meaningful.

GREG