summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..8edfe30
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "fs.h"
+#include "inject.h"
+#include "proc.h"
+
+int main(int argc, char** argv)
+{
+ if (argc < 3)
+ {
+ printf("inject_so [pid] [so files ...]\n");
+ return -1;
+ }
+
+ pid_t pid;
+ char** so_files = argv+2;
+
+ sscanf(argv[1], "%li", &pid);
+
+ if (!process_exists(pid))
+ {
+ printf("%li is not a running process\n", pid);
+ return -1;
+ }
+
+ char so_path[PATH_MAX];
+ char** so_file = so_files;
+ while (*so_file)
+ {
+ if (!isFile(*so_file))
+ {
+ printf("[!] %s is not a file\n", *so_file);
+ //++so_file;
+ //continue;
+ }
+
+ realpath(*so_file, so_path);
+ printf("[*] Injecting %s\n", so_path);
+
+ int ret = load_library(pid, so_path);
+ if (!ret)
+ printf("[*] Success\n");
+ else if (ret == 1)
+ printf("[!] library already loaded\n");
+ else
+ printf("[!] could not load libary\n");
+
+ ++so_file;
+ }
+} \ No newline at end of file