Hi folks,
i want to practice a little C programming and want to write a key logger programm which transparently greps characters from stdin pass them to telnet /ssh and check the input strings for a given list of forbidden input...
Here is a littel starter
main()
{
int i;
while (1){
i = getc(stdin);
putc(i,stdout);
};
}
My problem is that stdin per default is buffered and it waits till it receives <enter> from the user.
I used
freopen
setvbuf
do close stdin and reopen it as a new stream which is unbuffered but with no success
-> stdin still waits until it receives enter from the user....
So i did a little research and found that behaviour and settings of stdin is system dependent and i need to change it on linux using ioctl
I tried:
main()
{
int n;
struct termios oldT, newT;
char c;
ioctl(0,TCGETS,&oldT); //get current mode
newT=oldT;
newT.c_lflag &= ~ECHO; // echo off
newT.c_lflag &= ~ICANON; //one char @ a time
ioctl(0,TCSETS,&newT); // set new terminal mode
while(1){
read(0,&c,1); //read 1 char @ a time from stdin
putc(c,stdout);
};
}
but with no success...
...the option ICANON according to a google usenet entrie should do the job but didn't
I am running a debian system with kernel 2.4.21 and openwall patch
Any Suggestions?
regards,
weeny