Skip to content

Instantly share code, notes, and snippets.

@Sasszem
Created December 21, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sasszem/41bf6f3b10d55cd3a874eff78635c229 to your computer and use it in GitHub Desktop.
Save Sasszem/41bf6f3b10d55cd3a874eff78635c229 to your computer and use it in GitHub Desktop.
Some weird dynamic memory stuff, but looks like secure...
#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