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 stack overflow vulnerability.c

Abdul Wahab Junaidb9936675a4aa
diff --git a/C Hacking Tools/stack overflow vulnerability.c b/C Hacking Tools/stack overflow vulnerability.c
new file mode 100644
index 0000000..5948af1
--- /dev/null
+++ b/C Hacking Tools/stack overflow vulnerability.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int bof() {
+ char buffer[8]; /* an 8 byte character buffer */
+
+ /* Copy 20 bytes of 'A' into the buffer, causing buffer overflow */
+ strcpy(buffer, "AAAAAAAAAAAAAAAAAAAA");
+
+ /* This will cause an access violation due to stack corruption, attempting to return will overwrite EIP */
+ return 1;
+}
+
+int main(int argc, char **argv) {
+ bof(); /* Call our function, causing the stack overflow */
+
+ /* Print a message, execution will never reach this point because of the overflow */
+ printf("Not gonna do it!\n");
+
+ /* Leaves the main function */
+ return 1;
+}