cyber-security-resources/buffer_overflow_example
2018-06-26 22:29:25 -04:00
..
bad_code.c adding buffer overflow example 2018-02-15 18:27:16 -05:00
README.md Update README.md 2018-02-16 00:06:04 -05:00
registers.md Update registers.md 2018-06-26 21:58:59 -04:00
vuln_program Add files via upload 2018-06-26 22:28:57 -04:00
vuln_program.id0 Add files via upload 2018-06-26 22:29:25 -04:00
vuln_program.id1 Add files via upload 2018-06-26 22:29:25 -04:00
vuln_program.id2 Add files via upload 2018-06-26 22:29:25 -04:00
vuln_program.nam Add files via upload 2018-06-26 22:29:25 -04:00

Buffer Overflow Example

This is an example of a very bad coding practices that introduces a buffer overflow. The purpose of this code is to serve as a demonstration and exercise for The Art of Hacking Series and live training

#include <stdio.h>

void secretFunction()
{
    printf("Omar's Crappy Function\n");
    printf("This is a super secret function!\n");
}

void echo()
{
    char buffer[20];

    printf("Please enter your name:\n");
    scanf("%s", buffer);
    printf("You entered: %s\n", buffer);    
}

int main()
{
    echo();

    return 0;
}

The char buffer[20]; is a really bad idea. The rest will be demonstrated in the course.