From 80242d0a3f7acf76c1adadf50229eee4e2096e02 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Fri, 21 Jul 2023 06:29:41 +0200 Subject: [PATCH] Add unload to injector script Usage: ./inject unload --- inject.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/inject.sh b/inject.sh index 14f3efc..931c3c6 100755 --- a/inject.sh +++ b/inject.sh @@ -6,6 +6,24 @@ libpath=$(realpath "libhlcheat.so") # Used to echo the command. For debugging. #set -x +if [ "$1" == "unload" ]; then + sudo gdb -n -q -batch \ + -ex "attach $pid" \ + -ex "set \$dlopen = (void* (*)(char*, int))dlopen" \ + -ex "set \$dlclose = (int (*)(void*))dlclose" \ + -ex "set \$dlerror = (char* (*)(void))dlerror" \ + \ + -ex "set \$self = \$dlopen(\"$libpath\", 6)" \ + -ex "call \$dlclose(\$self)" \ + -ex "call \$dlclose(\$self)" \ + \ + -ex "call \$dlerror()" \ + -ex "detach" \ + -ex "quit" + + exit 0; +fi + if grep -q "$libpath" "/proc/$pid/maps"; then echo -e "hl-cheat already loaded. Reloading...\n"; @@ -18,9 +36,9 @@ if grep -q "$libpath" "/proc/$pid/maps"; then -ex "set \$dlclose = (int (*)(void*))dlclose" \ -ex "set \$dlerror = (char* (*)(void))dlerror" \ \ - -ex "set \$self = \$dlopen(\"$libpath\", 6)" \ - -ex "call \$dlclose(\$self)" \ - -ex "call \$dlclose(\$self)" \ + -ex "set \$self = \$dlopen(\"$libpath\", 6)" \ + -ex "call \$dlclose(\$self)" \ + -ex "call \$dlclose(\$self)" \ \ -ex "call \$dlopen(\"$libpath\", 2)" \ -ex "call \$dlerror()" \