Login
Order Now
Support
C Programming Homework Help on Buffer Overflow

C Programming Homework Help on Buffer Overflow

  • 30th Jun, 2022
  • 15:11 PM
#include
#include
void last()
{
    printf("\nRoot access");
}
void important(const char* input)
{
    char buf[10];
    strcpy(buf, input);
}

int main()
{
    printf("Address of last = %p\n", last);
    char systemPassword[8]="12345";
    char userPassword[8];
    int access=0;
    int count=0;
    while(count<4)
    {
        if(count==3)
        {
            printf("\nSystem Locked");
            break;
        }
        if(count>0)
        {
            printf("\nYou have %d attemp left",3-count);
        }
        printf("\nEnter Password : ");
        scanf("%s",userPassword);

        if(strcmp(systemPassword,userPassword)==0)
        {
            access++;
        }
        else
        {
            printf("\nWrong Credentials");
        }
        if(access)
        {
            char *dob;
            printf("\nEnter Date of birth for verification : ");
            scanf("%s",dob);
            important(dob);
            
            
        }
        count++;

    }
    return 0;
}

Share this post

assignment helpassignment helperassignment expertsassignment writing services