Wednesday, February 6, 2008

Hidden linux/dos bug.

This is A C example of the type dos command. you can compile this C source code and copy it using the linux command CP to the directory /bin. the linux copy command is “sudo cp mtype /bin” and your good to go.

File Name: mtype




#include stdio.h
#include stdlib.h



int main(int argc, char *argv[])

{

FILE *fp;

char ch;



if((fp = fopen(argv[ 1 ],"r"))==NULL) {

printf("Error: %s Cannot open file.\n",argv[1]);

exit(1);

}



while((ch = fgetc( fp )) != EOF) {

printf("%c", ch);

}

fclose(fp);



return 0;

}



I can remember back in the days of ms-dos that if you used the type command on a executable file it scrambled the text of the dos prompt. if you compile this C script and copy it to the directory called “/bin” you can use it as a command. use the command to dump some executable file and the bug really fucks up the shell font of Linux.

No comments: