Skip to content

Instantly share code, notes, and snippets.

@fgsahoward
Created June 11, 2018 17:24
Show Gist options
  • Select an option

  • Save fgsahoward/17bbe38a0fa03cc2d34de747f0e77603 to your computer and use it in GitHub Desktop.

Select an option

Save fgsahoward/17bbe38a0fa03cc2d34de747f0e77603 to your computer and use it in GitHub Desktop.
/**
* Compile:
* 32-bit:
* gcc -o med32 -m32 -fno-stack-protector med.c
* 64-bit:
* gcc -o med64 -fno-stack-protector med.c
*
* Turn off ASLR:
* sudo systctl -w kernel.randomize_va_space=0
**/
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
void vulnerable() {
char buf[1024];
memset(buf, 0x0, 1024);
write(1, "Enter some text: ", 17);
read(0, buf, 2048);
printf("Your string: %s", buf);
}
int main(int argc, char * argv[], char * envp[]) {
vulnerable();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment