Skip to content

Instantly share code, notes, and snippets.

@aaronjwood
Last active January 8, 2017 21:50
Show Gist options
  • Save aaronjwood/22c17b0bf6f271f38cf0db043d814abd to your computer and use it in GitHub Desktop.
Save aaronjwood/22c17b0bf6f271f38cf0db043d814abd to your computer and use it in GitHub Desktop.
Stack buffer overflow
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char buff[15];
int auth = 0;
printf("\nEnter password: ");
gets(buff);
if (strcmp(buff, "password") != 0) {
printf("\nAccess denied\n");
} else {
auth = 1;
}
// Let's bypass this check!
if (auth) {
printf("\nAccess granted\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment