By causing buffer overflow we can overwrite the memory where flag value 0 is saved, so an even incorrect password will crack the code..
How will this happen internally? Could someone please explain in detail..how will this happen in memory practically?
#include<stdio.h>
int main(int argc, char *argv[])
{
int flag = 0;
char passwd[10];
memset(passwd,0,sizeof(passwd));
strcpy(passwd, argv[1]);
if(0 == strcmp("LinuxGeek", passwd))
{
flag = 1;
}
if(flag)
{
printf("\n Password cracked \n");
}
else
{
printf("\n Incorrect passwd \n");
}
return 0;
}