-
Notifications
You must be signed in to change notification settings - Fork 3
/
Load.sh
executable file
·56 lines (45 loc) · 1.78 KB
/
Load.sh
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
56
#!/bin/sh
# Set the DEBUGGER variable on the cmdline to use lldb or any debugger
# Make sure it supports the following commands
DEBUGGER="${DEBUGGER:=gdb}"
echo "Using '$DEBUGGER' to inject"
if ! [ -x "$(command -v $DEBUGGER)" ]; then
echo "$DEBUGGER does not exist"
echo "Install it or set the DEBUGGER variable to a replacement"
exit 1
fi
csgo_pid=$(pidof csgo_linux64)
if [ -z "$csgo_pid" ]; then
echo "CS:GO can't be found, is the game running?"
exit 1
fi
lib_name="lib$(cat ProjectName).so"
cp Build/"$lib_name" /usr/lib64/
# The following is copied from Fuzion (https://github.com/LWSS/Fuzion/blob/0a4d775e17aba7a723aadce5b80898705e0bd6ff/load#L25); Thanks LWSS and contributors
# pBypass for crash dumps being sent
# You may also want to consider using -nobreakpad in your launch options.
rm -rf /tmp/dumps # Remove if it exists
mkdir --mode=000 /tmp/dumps # Make it as root with no permissions
# https://www.kernel.org/doc/Documentation/security/Yama.txt
sysctl -w kernel.yama.ptrace_scope=2 # Only allows root to inject code. This is temporary until reboot.
killall -19 steam
killall -19 steamwebhelper
$DEBUGGER -p "$csgo_pid" -n -q -batch \
-ex "call ((void*(*)(char*, int)) dlopen)(\"/usr/lib64/$lib_name\", 1)" \
-ex "call ((char*(*)(void)) dlerror)()" \
-ex "detach" \
-ex "quit" 2>&1 || {
echo "A error has appeared"
echo "$DEBUGGER has failed to dlopen the library"
if [ $DEBUGGER != "gdb" ]; then
echo "- Make sure that $DEBUGGER supports the same usage as GDB"
fi
}
# You have to restart your kernel to reinject btw ^^
sysctl -w kernel.yama.ptrace_scope=3
sleep 1
killall -18 steamwebhelper
killall -18 steam
echo "Process complete"
echo "If you face problems related to the injection process"
echo "you should provide the gdb session and build log to whoever is helping you."