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 attack using nonfunction pointers.c

Abdul Wahab Junaid4ef8b92d5c89
diff --git a/C Hacking Tools/attack using nonfunction pointers.c b/C Hacking Tools/attack using nonfunction pointers.c
new file mode 100644
index 0000000..c9cd90e
--- /dev/null
+++ b/C Hacking Tools/attack using nonfunction pointers.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+ char *args, *s1 = "/bin/ls", *s2 = "/bin/ps";
+ char buffer[128];
+ int i;
+
+ if (argc > 1) {
+ args = argv[1]; // Get the command-line argument
+
+ // Copy the argument into the buffer, ensuring no buffer overflow
+ for (i = 0; i < 128 && args[i] != '\0'; i++) {
+ buffer[i] = args[i];
+ }
+ buffer[i] = '\0'; // Null-terminate the buffer
+ }
+
+ // Execute the system command based on the argument
+ if (strcmp(buffer, "ls") == 0) {
+ system(s1);
+ } else if (strcmp(buffer, "ps") == 0) {
+ system(s2);
+ } else {
+ printf("Invalid command!\n");
+ }
+
+ return 0;
+}