Skip to content

Instantly share code, notes, and snippets.

@ryankurte ryankurte/demo2.c
Last active May 1, 2018

What would you like to do?
Buffer overflow example in C
// Demo 1
// clang -fno-stack-protector -fno-sanitize=safe-stack -D_FORTIFY_SOURCE=0 -m32 -Wl,-no_pie -O0 -g demo2.c -o demo2.o
#include <stdio.h>
#include <string.h>
char password[] = "password";
int get_password() {
int auth_ok = 0;
char buff[16];
printf("Enter password: ");
scanf("%s", buff);
if(strncmp(buff, password, sizeof(password)) == 0)
auth_ok = 1;
return auth_ok;
void success() {
int main(int argc, char** argv) {
int res = get_password();
if (res == 0) {
return 0;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.