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.

Shell Encryption

GCC/cpp or linux version of Ansi C assembler. The Encryption is week XOR based. it's just the 1st example I can think of from memory.
Command Line Example:
Command 1: sudo gcc -o encrypt encrypt.c
Command 2: ./encrypt
Note: ...you can copy encrypt to /bin ....



C++ Include Files:





#include

#include



#define KEY_LENGTH 66 * 6



unsigned char Random_Byte(void)

{

double result;



result = (double) rand() / (double) RAND_MAX;

result = result * 255.0;

return (unsigned char) result;

}







void Crypt(FILE *input, FILE *output)

{

unsigned char key[KEY_LENGTH];

int key_index, in_value;

unsigned char out_value, random_value;

int done;



/* create random key */

for (key_index = 0; key_index < done =" 0;" in_value =" fgetc(input);">= 0)

{

out_value = (unsigned char) in_value;

random_value = Random_Byte();



for (key_index = 0; key_index < out_value =" out_value" out_value =" out_value" done =" 1;" done =" 0;" in_value =" fgetc(input);">= 0)

{

random_value = (unsigned char) in_value;

in_value = fgetc(input);

if (in_value >= 0)

{

out_value = (unsigned char) in_value;

out_value = out_value ^ random_value;

for (key_index = (KEY_LENGTH - 1); key_index >= 0; key_index--)

out_value = out_value ^ key[key_index];



fputc(out_value, output);

}

else

done = 1;

}

else

done = 1;



} /* end of while */

printf("Decrypting file..");

} /* end of Decrypt() */







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

{

FILE *input, *output;



if (argc <> \n");

printf("Use the `e' option to encrypt in_file, producing out_file.\n");

printf("Use the `d' option to decrypt out_file giving in_file.\n");

printf("Example: Encrypt c plain.txt coded.txt\n");

printf(" Encrypt d coded.txt newplain.txt\n");

printf("\n Encryption By Johnny Buckallew Stroud\n");

return 0;

}



if ( (argv[1][0] != 'e') && (argv[1][0] != 'd') )

{

printf("First agument must be `e' or `d'.\n");

return 1;

}



input = fopen(argv[2], "r");

if (!input)

{

printf("Cannot open %s for reading.\n", argv[2]);

printf("Command Example: sudo encrypt e %s outfile.doc \n", argv[2]);

return 1;

}



output = fopen(argv[3], "w");

if (!output)

{

printf("Cannot open %s for writting.\n", argv[3]);

printf("sudo encrypt e input.doc %s", argv[3]);

fclose(input);

return 1;

}



printf("Working......");

srand( time(NULL) );

if (argv[1][0] == 'e')

Crypt(input, output);

else

Decrypt(input, output);



printf("....Done.\n");

fclose(input);

fclose(output);

return 0;



} /* end of main() */