I am learning C and decided to play around with the code. I can figure out the password as it has a bug in my code by writing any character but at 108 character writing the letter K which overwrite tha trigger variable and I can print the message inside. I was wondering is there a way to do the same printing the message inside by changing the return address in my code? If any more details are needed please let me know.
My code:
#include <stdio.h>
 
char getdata() {
  int trigger = 'A';
  char data[100];
  gets(data);
  return (char) trigger;
}
void login() {
  printf("inside!\n");
  exit(0);
}
void main() {
  printf("enter ");
  if (getdata() == 'K') {
    login();
  } else {
    printf("wrong.\n");
    exit(1);
  }
}
I want the output to be:
When user enter some password could be anything it should print inside and that should even work while I have Address Space Layout
Randomisation on.
