v12 = __readfsqword(0x28u); v3 = time(0LL); srand(v3); setbuf(stdout, 0LL); setbuf(stdin, 0LL); rgid = getegid(); setresgid(rgid, rgid, rgid); puts("I dare you to leek my secret."); for ( i = 0; i < N; ++i ) { heap_addr = (char *)malloc(0x10uLL); heap_random = malloc(0x20uLL); memset(heap_random, 0, 0x20uLL); getrandom(); for ( j = 0; j <= 31; ++j ) { if ( !*((_BYTE *)heap_random + j) || *((_BYTE *)heap_random + j) == 10 ) *((_BYTE *)heap_random + j) = 1; } printf("Your input (NO STACK BUFFER OVERFLOWS!!): "); input(heap_addr); // heap overflow printf(":skull::skull::skull: bro really said: "); puts(heap_addr); // print printf("So? What's my secret? "); fgets(s2, 33, stdin); if ( strncmp((constchar *)heap_random, s2, 0x20uLL) ) { puts("Wrong!"); exit(-1); } puts("Okay, I'll give you a reward for guessing it."); printf("Say what you want: "); gets(heap_addr); // bof puts("Hmm... I changed my mind."); free(heap_random); free(heap_addr); puts("Next round!"); } puts("Looks like you made it through."); win(); return v12 - __readfsqword(0x28u); }
I can find heap overflow in memcpy of input(). And then, There are second bof in heap from gets(). At that time, I should have understanding the structure of heap. If the structure of heap is destroyed, I’ll be meet Double free vulnerability. (This will be caused by recognizing the heap as one.)