Created
December 21, 2020 13:54
-
-
Save Sasszem/41bf6f3b10d55cd3a874eff78635c229 to your computer and use it in GitHub Desktop.
Some weird dynamic memory stuff, but looks like secure...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() { | |
int* state = (int*) calloc(sizeof(int),1024); | |
int* admin_flag = &state[1023]; | |
*admin_flag = 0; | |
free(state); | |
char* str = malloc(4096); | |
char* line = malloc(128); | |
scanf("%127s", line); | |
snprintf(str, 4096, line); | |
if (*admin_flag==12852) { | |
printf("You won!\n"); | |
} | |
free(str); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment