Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create buffer overflow vulnerability.c

Abdul Wahab Junaid3dfdf19b71b4
diff --git a/C Hacking Tools/buffer overflow vulnerability.c b/C Hacking Tools/buffer overflow vulnerability.c
new file mode 100644
index 0000000..ddbd124
--- /dev/null
+++ b/C Hacking Tools/buffer overflow vulnerability.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int bof() {
+ char buffer[8]; /* an 8 byte character buffer */
+ FILE *badfile;
+
+ /* Open "badfile" for reading */
+ badfile = fopen("badfile", "r");
+
+ /* This is where the overflow happens. Reading 1024 bytes into an 8-byte buffer is a "bad thing" */
+ fread(buffer, sizeof(char), 1024, badfile);
+
+ /* Close the file */
+ fclose(badfile);
+
+ /* Return value */
+ return 1;
+}
+
+int main(int argc, char **argv) {
+ bof(); /* Call our function, causing the buffer overflow */
+
+ /* Print a message, in case of an overflow execution will not reach this point */
+ printf("Not gonna do it!\n");
+
+ /* Leaves the main function */
+ return 1;
+}