summaryrefslogtreecommitdiff
path: root/other/utmpcloak
diff options
context:
space:
mode:
authorSkyperTHC2026-03-03 06:28:55 +0000
committerSkyperTHC2026-03-03 06:28:55 +0000
commit5d3573ef7a109ee70416fe94db098fe6a769a798 (patch)
treedc2d5b294c9db8ab2db7433511f94e1c4bb8b698 /other/utmpcloak
parentc6c59dc73cc4586357f93ab38ecf459e98675cc5 (diff)
packetstorm sync
Diffstat (limited to 'other/utmpcloak')
-rw-r--r--other/utmpcloak/utcl.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/other/utmpcloak/utcl.c b/other/utmpcloak/utcl.c
new file mode 100644
index 0000000..c2be232
--- /dev/null
+++ b/other/utmpcloak/utcl.c
@@ -0,0 +1,80 @@
1/* HiHo,
2 this utility changes the host of a given username (all his logins affected)
3 usage is utcl <user> <host> where host is the desired host (only 20 chars)
4
5 this piec of software is mostly ripped from ute.c which i found on my hdd
6 and dont know where it came from.. many thanks to the author of this one..
7 thanks goes also out to xdr who gave me the idea of writing this (he wrote
8 such thingie, but then lost it @#$! ;)
9
10 have fun...
11 -hendy (flames to hendy@winterland.net)
12
13 greetings: (oh, this is lame, i know) to #!teso, #hax, #hack
14
15 // hope it's not too lame
16
17 */
18
19#include <stdlib.h>
20#include <sys/types.h>
21#include <string.h>
22#include <stdio.h>
23#include <unistd.h>
24#include <sys/file.h>
25#include <fcntl.h>
26#include <utmp.h>
27#include <pwd.h>
28#include <lastlog.h>
29// #define UTMP_FILE "/var/run/utmp" /* should have been defined in utmp.h */
30#define MAX_ENT 100
31
32int
33main (int argc, char **argv)
34{
35 int item;
36 struct utmp Entry[MAX_ENT + 1];
37 off_t position[MAX_ENT + 1];
38 FILE *fptr;
39
40 if (argc < 3)
41 {
42 printf ("usage: %s <user> <host>\n", argv[0]);
43 exit (1);
44 }
45
46 if ((fptr = fopen (UTMP_FILE, "r+")) != NULL)
47 {
48 int last, num, i = 1; /* get all utmp entries. */
49 while (fread (&Entry[i], sizeof (Entry[i]), 1, fptr) > 0)
50 {
51 if (strcmp (Entry[i].ut_line, "") != 0) /* skip empty entries */
52 {
53 position[i] = ftell (fptr) - (long) (sizeof (Entry[i]));
54 i++;
55 }
56 }
57 last = i - 1; /* keep a tab on how many entries there are. */
58 position[i] = ftell (fptr); /* keep track of EOF */
59
60 for (item = 1; item <= last; item++)
61 {
62
63 if (!(strcmp (Entry[item].ut_name, argv[1])))
64 {
65 strcpy (Entry[item].ut_host, argv[2]); /* insert new host */
66 fseek (fptr, position[item], SEEK_SET); /* seek position in utmp */
67 fwrite (&Entry[item], sizeof (Entry[num]), 1, fptr); /* write to file */
68
69 }
70 }
71
72
73 fclose (fptr);
74 }
75 else
76 {
77 printf ("\nERROR: cannot open file %s \n", UTMP_FILE);
78 }
79 return (0);
80}