THM Industrial Intrusion CTF - Task 28 [PWN] - Start
whAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAt? Just spam a lot of AAAAAAAAAAAAAAAAAAAAAs like so. Done. No seriously, lets go over what this program actually does, and why this even works. I load up the provided binary in Ghidra and take a look at the decompiled code, more specifically at the main function. bool main(void) { bool bVar1; char local_38 [44]; int local_c; setvbuf(stdout,(char *)0x0,2,0); setvbuf(stdin,(char *)0x0,2,0); local_c = 0; printf("Enter your username: "); gets(local_38); bVar1 = local_c != 0; if (bVar1) { puts("Welcome, admin!"); print_flag(); } else { puts("Access denied."); } return !bVar1; } What happens here? The program, will read input into local_38 which can be [44] bytes long. It’s buffer is 44 bytes. For this, it uses gets(), which is not only outdated but also dangerous, because it does not limit the input length. ...