diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2018-06-16 22:50:18 +0200 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2018-06-16 22:50:18 +0200 |
commit | b0cf064f819357feedc77d6d5eb0de49e122554a (patch) | |
tree | 2ba0defb81576326dbc25736174100bfd43f677c /examples-secure/buffer-overflow/buffer-overflow.c | |
parent | 7d93b9b60f0923b0f895d63b2d456b279a6ab774 (diff) |
Added command injection example and secured examples
Diffstat (limited to 'examples-secure/buffer-overflow/buffer-overflow.c')
-rw-r--r-- | examples-secure/buffer-overflow/buffer-overflow.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples-secure/buffer-overflow/buffer-overflow.c b/examples-secure/buffer-overflow/buffer-overflow.c new file mode 100644 index 0000000..261a58e --- /dev/null +++ b/examples-secure/buffer-overflow/buffer-overflow.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <string.h> + +int main(void) +{ + char buf[16]; + int ok = 0; + + printf("Type admin password: "); + fgets(buf, sizeof buf, stdin); + buf[strlen(buf)-1] = '\0'; + + if (strcmp(buf, "pass123")) printf("\nWrong password!\n"); + else ok = 1; + + if (ok) printf("\nLogged in as admin.\n"); + + return 0; +} |