blob: 8edfe3090e6c6230962a78a4ddcafeb82e8639e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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;
}
}
|