| 
									
										
										
										
											2023-07-19 20:13:24 +02:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | pid=$(pidof "hl_linux") | 
					
						
							|  |  |  | libpath=$(realpath "libhlcheat.so") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-26 22:01:33 +02:00
										 |  |  | if [ "$pid" == "" ]; then | 
					
						
							|  |  |  |    echo "inject.sh: process not running." | 
					
						
							|  |  |  |    exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:25:11 +02:00
										 |  |  | # Used to echo the command. For debugging. | 
					
						
							|  |  |  | #set -x | 
					
						
							| 
									
										
										
										
											2023-07-19 20:13:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:29:41 +02:00
										 |  |  | 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" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-26 22:01:33 +02:00
										 |  |  |     exit 0 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:29:41 +02:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:25:11 +02:00
										 |  |  | if grep -q "$libpath" "/proc/$pid/maps"; then | 
					
						
							|  |  |  |     echo -e "hl-cheat already loaded. Reloading...\n"; | 
					
						
							| 
									
										
										
										
											2023-07-19 20:13:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:25:11 +02:00
										 |  |  |     # 0x2 -> RTLD_NOW | 
					
						
							|  |  |  |     # 0x6 -> RTLD_LAZY | RTLD_NOLOAD | 
					
						
							|  |  |  |     # For more info on the 3 mid lines, see self_unload() in main.c | 
					
						
							|  |  |  |     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"    \
 | 
					
						
							|  |  |  |                                                             \
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:29:41 +02:00
										 |  |  |          -ex "set \$self = \$dlopen(\"$libpath\", 6)"       \
 | 
					
						
							|  |  |  |          -ex "call \$dlclose(\$self)"                       \
 | 
					
						
							|  |  |  |          -ex "call \$dlclose(\$self)"                       \
 | 
					
						
							| 
									
										
										
										
											2023-07-21 06:25:11 +02:00
										 |  |  |                                                             \
 | 
					
						
							|  |  |  |          -ex "call \$dlopen(\"$libpath\", 2)"               \
 | 
					
						
							|  |  |  |          -ex "call \$dlerror()"                             \
 | 
					
						
							|  |  |  |          -ex "detach"                                       \
 | 
					
						
							|  |  |  |          -ex "quit" | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |     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 "call \$dlopen(\"$libpath\", 2)"               \
 | 
					
						
							|  |  |  |          -ex "call \$dlerror()"                             \
 | 
					
						
							|  |  |  |          -ex "detach"                                       \
 | 
					
						
							|  |  |  |          -ex "quit" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set +x | 
					
						
							| 
									
										
										
										
											2023-07-19 20:31:02 +02:00
										 |  |  | echo -e "\nDone." |