Skip to content

Instantly share code, notes, and snippets.

@retpolanne
Created March 24, 2019 00:42
Show Gist options
  • Save retpolanne/994bed511cb7044cdf52294028d82199 to your computer and use it in GitHub Desktop.
Save retpolanne/994bed511cb7044cdf52294028d82199 to your computer and use it in GitHub Desktop.
Example of buffer overflow using strcpy
// to compile: gcc -fno-stack-protector -o boverflow_strcpy boverflow_strcpy.c
// to run (test): ./boverflow_strcpy $(python -c "print 'a'*15")
#include <stdio.h>
#include <strings.h>
void foo(char *bar){
char buffer[16];
strcpy(buffer, bar);
printf("%s", buffer);
}
int main(int argc, char *argv[]) {
foo(argv[1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment