As part of my assignment i have to demonstrate stackoverflow in my linux box.
My Box Config: OS: Ubuntu 13.04
GCC version: 4.6.3
I tried to compile the program with the flag -fno-stack-protector, the program complies successfully but Segmentation fault error shows up when i trigger stack overflow. How can i show the actual o/p. Buffer Over Flow Pgm:
int main(int argc, char**argv)
{
int authentication=0;
char cUsername[10], cPassword[10];
strcpy(cUsername, argv[1]);
strcpy(cPassword, argv[2]);
if(strcmp(cUsername, "admin") == 0 && strcmp(cPassword, "adminpass") == 0)
{
authentication = 1;}
if(authentication)
{
printf("Access granted");}
else
{
printf("Wrong username and password");
}return 0;}
If i give an IP like AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA A then it should show Acess granted but right now it shows segmentation fault