-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathload
executable file
·55 lines (45 loc) · 1.22 KB
/
load
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
53
54
55
#!/usr/bin/env bash
function echo_green {
echo -e "\\e[32m$*\\e[0m"
}
function echo_orange {
echo -e "\\e[33m$*\\e[0m"
}
function echo_red {
echo -e "\\e[31m$*\\e[0m"
}
sven_pid=$(pidof svencoop_linux)
if [ -z "$sven_pid" ]; then
echo_red "SvenCoop needs to be open before you can inject, exiting..."
exit 1
fi
filename="libSvenHax.so"
if [ ! -f $filename ]; then
echo_red "Could not find '${filename}'"
exit 1
fi
# Credit: Aixxe @ aixxe.net
if grep -q "$filename" /proc/"$sven_pid"/maps; then
echo_orange "Hack is already injected, aborting..."
exit
fi
echo "Injecting: $filename"
# https://www.kernel.org/doc/Documentation/security/Yama.txt
echo "2" | tee /proc/sys/kernel/yama/ptrace_scope # Only allows root to inject code. This is temporary until reboot.
input="$(
sudo gdb -n -q -batch-silent \
-ex "attach $sven_pid" \
-ex "b SDL_GL_SwapWindow" \
-ex "c" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(pwd)/$filename\", 2)" \
-ex "detach" \
-ex "quit"
)"
last_line="${input##*$'\n'}"
echo $last_line
if [ "$last_line" != "\$1 = (void *) 0x0" ]; then
echo_green "Successfully injected!"
else
echo_red "Injection failed, make sure you have compiled..."
fi