403Webshell
Server IP : 23.111.136.34  /  Your IP : 216.73.216.136
Web Server : Apache
System : Linux servidor.eurohost.com.br 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : meusitei ( 1072)
PHP Version : 5.6.40
Disable Function : show_source, system, shell_exec, passthru, proc_open
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/local/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/src/cpguard.sh
#!/bin/bash

#Install-Uninstall script for  cPGuard Checker plugin for cPanel / WHM
#Developed by https://www.OpsShield.com

#cPanel Version 3.17
#DA Version 3.16

echo "########################"
echo "########################"
echo "#####cPGuard manage script"
echo "#####Written and maintained by https://www.OpsShield.com"
echo "#####Please email sales@OpsShield.com for any questions regarding this software"
echo "########################"
echo "########################"
sleep 1

function cpanelinstall() {

HTTP=`which httpd`
ARC=`uname -i`
if [ ! $ARC = "x86_64" ]; then
        echo -ne "\r${red}cPGuard does not support 32 bit systems..Exiting installation [ ERROR ] ${NC}"
        exit
fi

if ! /usr/local/cpanel/3rdparty/bin/php -v | grep ionCube ; then
        echo -ne "\r${red}Please enable ionCube Module in cPanel PHP and try again[ ERROR ] ${NC}"
        echo -ne "\r${red}Please refer https://manage.opsshield.com/index.php/plugin/support_manager/knowledgebase/view/57/enable-ioncube-in-cpanel-php/1/ ${NC}"
        exit
fi

if [ $OS -eq 7 ]; then
        if [ ! -f /etc/yum.repos.d/epel.repo ]; then
                yum -y install epel-release
                sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
        fi
        echo "fs.inotify.max_user_watches = 5000000" > /etc/sysctl.d/cpguard.conf
        sysctl -p /etc/sysctl.d/cpguard.conf
elif [ $OS -eq 6 ]; then
        if [ ! -f /etc/yum.repos.d/epel.repo ]; then
                yum -y install epel-release.noarch
                rpm -Uvh https://downloads.opsshield.com/cpguard/atomic-release-1.0-21.el6.art.noarch.rpm
                sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
                sed -i -e "s/enabled = 1/enabled = 0/g" /etc/yum.repos.d/atomic.repo
        fi
        if ! grep -w "fs.inotify.max_user_watches = 5000000" /etc/sysctl.conf  >/dev/null 2>&1; then
                echo "fs.inotify.max_user_watches = 5000000" >> /etc/sysctl.conf
                sysctl -p
        fi
        ln -s /lib64/libpcre.so.0 /lib64/libpcre.so.1

fi

if [ $OS -eq 7 ]; then
        rpm -e --nodeps clamav-filesystem-0.101.4-3.el7.noarch clamav-devel-0.101.4-3.el7.x86_64 clamav-lib-0.101.4-3.el7.x86_64 clamav-data-0.101.4-3.el7.noarch clamav-0.101.4-3.el7.x86_64 clamav-update-0.101.4-3.el7.x86_64  > /dev/null 2>&1
elif [ $OS -eq 6 ]; then
        rpm -e --nodeps clamav-filesystem-0.101.4-2.el6.noarch clamav-devel-0.101.4-2.el6.x86_64 clamav-lib-0.101.4-2.el6.x86_64  clamav-data-0.101.4-2.el6.noarch clamav-0.101.4-2.el6.x86_64 clamav-update-0.101.4-2.el6.x86_64  > /dev/null 2>&1
fi

if [ $OS -eq 6 ]; then
                if grep 'exclude' /etc/yum.conf > /dev/null; then
                        if  [[  $(grep exclude /etc/yum.conf | grep clamav) ]]; then
                                sed -i -e "s/exclude=/#exclude=/g" /etc/yum.conf
                                yum install pcre2  json-c -y
                                yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                                sed -i -e "s/#exclude=/exclude=/g" /etc/yum.conf
                        else
                                yum install pcre2  json-c -y
                                yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                        fi
                else
                        yum install pcre2  json-c -y
                        yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                fi
else
        yum install pcre2 -y
        yum --disablerepo=*  --enablerepo=epel -y install clamav clamav-devel
        #yum --disablerepo=*  --enablerepo=epel -y update clamav clamav-devel
fi

yum --enablerepo=epel -y install  rkhunter

chmod 000 /etc/cron.daily/rkhunter


rpm -Uvh  https://downloads.opsshield.com/cpguard/rpms/cpguard-core-3.17-1.x86_64.rpm
rpm -Uvh  https://downloads.opsshield.com/cpguard/rpms/cpguard-whm-3.17-1.x86_64.rpm
rpm -Uvh  https://downloads.opsshield.com/cpguard/rpms/cpguard-cpanel-3.17-1.x86_64.rpm

if [ ! -d /usr/local/cpanel/whostmgr/docroot/cgi/cpguard ] && [ ! -d /etc/cpguard ]; then
        echo -ne "\r${red}cPGuard Installation has been failed..please contact Support for further assistance ${NC}"
        echo -ne '\n'
        exit
fi

cd /etc/cpguard/chkrootkit/
make sense

cp -p /etc/cpguard/cltypes.h /usr/include/

if $HTTP -M | grep security2 > /dev/null 2>&1; then
        if [ -f /etc/cpanel/ea4/is_ea4 ]; then
                EA=4
                CONFFILE="/etc/apache2/conf.d/modsec/modsec2.user.conf"
        else
                EA=3
                CONFFILE="/usr/local/apache/conf/modsec2.user.conf"
        fi

        grep -v  cpguard_modsec $CONFFILE  > /root/cpg_modsec_conf.tmp
        cat /root/cpg_modsec_conf.tmp > $CONFFILE
        if ! grep cpguard_modsec100 $CONFFILE > /dev/null; then
                echo "Include /etc/cpguard/cpguard_modsec100.conf" >> $CONFFILE
        fi
        rm -f /root/cpg_modsec_conf.tmp
else
        echo  -ne "\r${red}You should install ModSecurity First to make the HTTP Tools Working [ ERROR ]  ${NC}"
        echo -ne '\n'
fi


if [ ! -d /var/cpanel/apps ]; then
        mkdir /var/cpanel/apps
        chmod 755 /var/cpanel/apps
fi


mkdir /var/cpanel/rbl_info/  >/dev/null 2>&1
cp -p  /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/rbl/abuseat.yaml /var/cpanel/rbl_info/
cp -p /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/rbl/barracuda.yaml /var/cpanel/rbl_info/
cp -p /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/rbl/spameatingmonkey.yaml /var/cpanel/rbl_info/
cp -p /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/rbl/srbl_cpguard.yaml /var/cpanel/rbl_info/
echo "acl_abuseat_rbl=0" >> /etc/exim.conf.localopts
echo "acl_barracuda_rbl=0" >> /etc/exim.conf.localopts
echo "acl_spameatingmonkey_rbl=0" >> /etc/exim.conf.localopts
echo "acl_cpguardsrbl_rbl=0" >> /etc/exim.conf.localopts

mv /etc/cpguard/cron /etc/cron.d/cpguard
mv /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/cpguard_modsec100.conf /etc/cpguard/cpguard_modsec100.conf
mv /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/cpguard_modsec101.conf /etc/cpguard/cpguard_modsec101.conf

mkdir -p /opt/cpguard/
touch /opt/cpguard/tmpdb.txt
chmod 666 /opt/cpguard/tmpdb.txt

touch /etc/cpguard/cpguard.log
touch /opt/cpguard/BlockedIPs.log
touch /opt/cpguard/IPlist.txt
touch /opt/cpguard/blacklistips.txt
touch /opt/cpguard/whitelistips.txt
touch /opt/cpguard/whitelistdomains.txt
chown root.nobody /etc/cpguard/cpguard.log
chown root.nobody /opt/cpguard/BlockedIPs.log
chown root.nobody /opt/cpguard/IPlist.txt
chown root.nobody /opt/cpguard/blacklistips.txt
chmod 664 /etc/cpguard/cpguard.log
chmod 664 /opt/cpguard/BlockedIPs.log
chmod 664 /opt/cpguard/IPlist.txt
chmod 664 /opt/cpguard/blacklistips.txt

touch /etc/cpguard/whitelistusers.txt
touch /etc/cpguard/userwatch.txt
touch /etc/cpguard/whitelistfiles.txt
touch /etc/cpguard/blacklistfiles.txt
echo "mysql.sock" >> /etc/cpguard/whitelistfiles.txt
echo "1.sh" >> /etc/cpguard/blacklistfiles.txt
echo "libworker.so" >> /etc/cpguard/blacklistfiles.txt

touch /etc/cpguard/updations.txt

echo "Resgistering WHM Plugin..."
/usr/local/cpanel/bin/register_appconfig /etc/cpguard/whm.cpguard.conf

echo "Resgistering cPanel Plugin..."
/usr/local/cpanel/scripts/install_plugin /usr/local/cpanel/base/frontend/paper_lantern/cpguard/cpguard_paperlattern
ln -s /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/assets/plugins /usr/local/cpanel/base/frontend/paper_lantern/cpguard/assets/plugins

/usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/setup/install.php

sed -i -e "s/ErrorDocument 406/#ErrorDocument 406/g" /etc/apache2/conf.d/includes/errordocument.conf

echo "ALLOWIPCPROC=/usr/bin/postgres" >> /etc/rkhunter.conf

cp -p /etc/cpguard/scripts/cpgRecaptcha_en /usr/local/cpanel/cgi-sys/cpgRecaptcha
chmod 755 /usr/local/cpanel/cgi-sys/cpgRecaptcha
chown root.wheel /usr/local/cpanel/cgi-sys/cpgRecaptcha

if which cagefsctl >/dev/null 2>&1; then
        echo "Updating CageFS Skelton....it may take  a while"
        sleep 3
        cagefsctl --force-update
fi

/scripts/restartsrv httpd > /dev/null

/usr/sbin/csf -a 104.248.44.154 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 159.89.96.209 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 94.237.29.205 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 37.97.190.233 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 72.14.186.130 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 188.116.8.88 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 45.77.35.77 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 94.130.24.31 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 37.97.189.139 "cPGuard" > /dev/null 2>&1


rm -f /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/setup/db.sql

if [ -d /usr/local/cpanel/whostmgr/docroot/cgi/cpguard ] && [ -d /etc/cpguard ]; then
        echo -ne '\n'
        echo -ne '\n'
        echo -ne "cPGuard  installation has been completed ${green}[SUCCESS] ${NC}"
        echo -ne '\n'
        echo -ne "\r${green}Please refer the initial settings documentation and apply license to complete the installation procedure ${NC}"
        echo -ne '\n'

        if [ $OS -eq 6 ]; then
                if grep exclude /etc/yum.conf > /dev/null; then
                        if  [[ ! $(grep exclude /etc/yum.conf | grep clamav) ]]; then
                                sed -i  -e '/exclude/s/$/ clamav*/' /etc/yum.conf
                        fi
                else
                        echo "exclude = clamav*" >> /etc/yum.conf
                fi
        fi

else
        echo -ne "\r${red}cPGuard Installation has been failed..please contact Support for further assistance ${NC}"
        echo -ne '\n'
fi

}

function cpaneluninstall() {

/usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/whostmgr/docroot/cgi/cpguard/scripts/service_manager.php stop
/usr/local/cpanel/scripts/uninstall_plugin /usr/local/cpanel/base/frontend/paper_lantern/cpguard/cpguard_paperlattern
/usr/local/cpanel/bin/unregister_appconfig cPGuard
rpm -e cpguard-core  >/dev/null 2>&1
rpm -e cpguard-whm  >/dev/null 2>&1
rpm -e cpguard-cpanel  >/dev/null 2>&1
rm -rf /etc/cpguard
rm -rf  /usr/local/cpanel/whostmgr/docroot/cgi/cpguard
sed -i '/acl_abuseat_rbl/d' /etc/exim.conf.localopts
sed -i '/acl_barracuda_rbl/d' /etc/exim.conf.localopts
sed -i '/acl_spameatingmonkey_rbl/d' /etc/exim.conf.localopts
rm -f /var/cpanel/rbl_info/abuseat.yaml
rm -f /var/cpanel/rbl_info/barracuda.yaml
rm -f /var/cpanel/rbl_info/spameatingmonkey.yaml
rm -f /var/cpanel/rbl_info/srbl_cpguard.yaml
rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/barracuda_rbl
rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/spameatingmonkey_rbl
rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/abuseat_rbl
rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/cpguardsrbl_rbl
rm -f /etc/cron.d/cpguard
rm -f /usr/local/cpanel/cgi-sys/cpgRecaptcha
rm -rf /opt/cpguard
if [ -f /etc/cpanel/ea4/is_ea4 ]; then
        EA=4
        CONFFILE="/etc/apache2/conf.d/modsec/modsec2.user.conf"
else
        EA=3
        CONFFILE="/usr/local/apache/conf/modsec2.user.conf"
fi

sed -i '/cpguard_modsec100.conf/d'  $CONFFILE

/scripts/buildeximconf > /dev/null
/scripts/restartsrv exim > /dev/null
/scripts/restartsrv httpd > /dev/null

mysql <<EOF
drop database cpanel_cpguard;
EOF

rpm -e cpguard-core >/dev/null 2>&1

}


###########################

function dainstall() {

HTTP=`which httpd`
ARC=`uname -i`
if [ ! $ARC = "x86_64" ]; then
        echo -ne "\r${red}cPGuard does not support 32 bit systems..Exiting installation [ ERROR ] ${NC}"
        exit
fi

PHPVER=`php -v | head -1 | awk -F" " {'print $2'} | awk -F"." {'print $1'}`
rm -f /usr/local/bin/cpgphp
if [ $PHPVER -eq 7 ]; then
        PHPSUBVER=`php -v | head -1 | awk -F" " {'print $2'} | awk -F"." {'print $2'}`
        if [ $PHPSUBVER -eq 1 ]; then
                ln -s /usr/local/bin/php /usr/local/bin/cpgphp
        elif [ $PHPSUBVER -eq 2 ]; then
                ln -s /usr/local/bin/php /usr/local/bin/cpgphp
        elif [ $PHPSUBVER -eq 3 ]; then
                ln -s /usr/local/bin/php /usr/local/bin/cpgphp
        elif [ $PHPSUBVER -eq 0  ]; then
                 echo -ne "\r${red}cPGuard requires PHP 7.1 or 7.2 or 7.3 to function on the server [ ERROR ] ${NC}"
                exit
        fi
elif [ -d /usr/local/php73 ]; then
        ln -s /usr/local/php73/bin/php /usr/local/bin/cpgphp
elif [ -d /usr/local/php72 ]; then
        ln -s /usr/local/php72/bin/php /usr/local/bin/cpgphp
elif [ -d /usr/local/php71 ]; then
        ln -s /usr/local/php71/bin/php /usr/local/bin/cpgphp
else
        echo -ne "\r${red}cPGuard requires PHP 7.1 or above to function on the server [ ERROR ] ${NC}"
        exit
fi


if [ $OS -eq 7 ]; then
        if [ ! -f /etc/yum.repos.d/epel.repo ]; then
                yum -y install epel-release
                sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
        fi
        echo "fs.inotify.max_user_watches = 5000000" > /etc/sysctl.d/cpguard.conf
        sysctl -p /etc/sysctl.d/cpguard.conf
elif [ $OS -eq 6 ]; then
        if [ ! -f /etc/yum.repos.d/epel.repo ]; then
                yum -y install epel-release.noarch
                rpm -Uvh https://downloads.opsshield.com/cpguard/atomic-release-1.0-21.el6.art.noarch.rpm
                sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
                sed -i -e "s/enabled = 1/enabled = 0/g" /etc/yum.repos.d/atomic.repo
        fi
        if ! grep -w "fs.inotify.max_user_watches = 5000000" /etc/sysctl.conf  >/dev/null 2>&1; then
                echo "fs.inotify.max_user_watches = 5000000" >> /etc/sysctl.conf
                sysctl -p
        fi
        ln -s /lib64/libpcre.so.0 /lib64/libpcre.so.1

fi

if [ $OS -eq 6 ]; then
                if grep 'exclude' /etc/yum.conf > /dev/null; then
                        if  [[  $(grep exclude /etc/yum.conf | grep clamav) ]]; then
                                sed -i -e "s/exclude=/#exclude=/g" /etc/yum.conf
                                yum install pcre2  json-c -y
                                yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                                sed -i -e "s/#exclude=/exclude=/g" /etc/yum.conf
                        else
                                yum install pcre2  json-c -y
                                yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                        fi
                else
                        yum install pcre2  json-c -y
                        yum --disablerepo=*  --enablerepo=atomic -y install clamav clamav-devel
                fi
else
        yum install pcre2 -y
        yum  --enablerepo=epel -y install clamav clamav-devel
        #yum --disablerepo=*  --enablerepo=epel -y update clamav clamav-devel
fi


yum --enablerepo=epel -y install  rkhunter

chmod 000 /etc/cron.daily/rkhunter


if [ ! -d /usr/local/directadmin/plugins ]; then
        mkdir /usr/local/directadmin/plugins
        chown diradmin:diradmin /usr/local/directadmin/plugins
fi

mkdir -p /usr/local/src/cpg
cd /usr/local/src/cpg
wget https://downloads.opsshield.com/cpguard/da/etc_cpguard.tar.gz
wget https://downloads.opsshield.com/cpguard/da/plugin_cpguard.tar.gz
tar -xvzf plugin_cpguard.tar.gz
tar -xvzf etc_cpguard.tar.gz
mv plugin_cpguard /usr/local/directadmin/plugins/cpguard
mv etc_cpguard /etc/cpguard
chown admin.admin /usr/local/directadmin/plugins/cpguard


if [ ! -d /usr/local/directadmin/plugins/cpguard ] && [ ! -d /etc/cpguard ]; then
        echo -ne "\r${red}cPGuard Installation has been failed..please contact Support for further assistance ${NC}"
        echo -ne '\n'
        exit
fi

PHPVER=`php -v | head -1 | awk -F" " {'print $2'} | awk -F"." {'print $1'}`
if [ $PHPVER -eq 7 ]; then
        PHPSUBVER=`php -v | head -1 | awk -F" " {'print $2'} | awk -F"." {'print $2'}`
        if [ $PHPSUBVER -eq 1 ]; then
                echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.1.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
        elif [ $PHPSUBVER -eq 2 ]; then
                echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.2.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
        elif [ $PHPSUBVER -eq 3 ]; then
                echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.3.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
        fi
elif [ -d /usr/local/php73 ]; then
        echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.3.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
elif [ -d /usr/local/php72 ]; then
        echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.2.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
elif [ -d /usr/local/php71 ]; then
        echo 'zend_extension=/usr/local/directadmin/plugins/cpguard/ioncube_loader_lin_7.1.so' >> /usr/local/directadmin/plugins/cpguard/php.ini
fi


cd /etc/cpguard/chkrootkit/
make sense


cp -p /etc/cpguard/cltypes.h /usr/include/

mv /etc/cpguard/cron /etc/cron.d/cpguard
mv /usr/local/directadmin/plugins/cpguard/cpguard_modsec100.conf /etc/cpguard/cpguard_modsec100.conf
mv /usr/local/directadmin/plugins/cpguard/cpguard_modsec101.conf /etc/cpguard/cpguard_modsec101.conf

touch /etc/cpguard/cpguard.log

touch /etc/cpguard/whitelistusers.txt
touch /etc/cpguard/userwatch.txt
touch /etc/cpguard/whitelistfiles.txt
touch /etc/cpguard/blacklistfiles.txt
touch /etc/cpguard/watchlist.txt
chown root.admin /etc/cpguard/whitelistusers.txt
chown root.admin /etc/cpguard/userwatch.txt
chown root.admin /etc/cpguard/whitelistfiles.txt
chown root.admin /etc/cpguard/blacklistfiles.txt
chmod 664 /etc/cpguard/whitelistusers.txt
chmod 664 /etc/cpguard/userwatch.txt
chmod 664 /etc/cpguard/whitelistfiles.txt
chmod 664 /etc/cpguard/blacklistfiles.txt

echo "mysql.sock" >> /etc/cpguard/whitelistfiles.txt
echo "1.sh" >> /etc/cpguard/blacklistfiles.txt
echo "libworker.so" >> /etc/cpguard/blacklistfiles.txt

mkdir  /opt/cpguard/
touch /opt/cpguard/tmpdb.txt
touch /opt/cpguard/BlockedIPs.log
touch /opt/cpguard/IPlist.txt
touch /opt/cpguard/blacklistips.txt
touch /opt/cpguard/whitelistips.txt
touch /opt/cpguard/whitelistdomains.txt
chmod 666 /opt/cpguard/tmpdb.txt
chmod 666 /opt/cpguard/BlockedIPs.log
chmod 666 /opt/cpguard/IPlist.txt
chmod 666 /opt/cpguard/blacklistips.txt
chown root.admin /opt/cpguard/whitelistips.txt
chmod 664 /opt/cpguard/whitelistips.txt
chown root.admin /opt/cpguard/whitelistdomains.txt
chmod 664 /opt/cpguard/whitelistdomains.txt
touch /etc/cpguard/conf/location.dat

mkdir /etc/cpguard/logs
chown root.admin /etc/cpguard/logs
chmod 775 /etc/cpguard/logs
touch /etc/cpguard/logs/php_errors.log
touch /etc/cpguard/logs/application.log
touch /etc/cpguard/logs/install.log
chown root.admin /etc/cpguard/logs/application.log
chown root.admin /etc/cpguard/logs/install.log
chown root.admin /etc/cpguard/logs/php_errors.log
chmod 664 /etc/cpguard/logs/application.log
chmod 664 /etc/cpguard/logs/install.log
chmod 664 /etc/cpguard/logs/php_errors.log

touch /etc/cpguard/chkrootkit.log
touch /etc/cpguard/rkhunter.log
chmod 644 /etc/cpguard/chkrootkit.log
chmod 644 /etc/cpguard/rkhunter.log

chown -R admin.admin /usr/local/directadmin/plugins/cpguard

/usr/local/bin/cpgphp -nc/usr/local/directadmin/plugins/cpguard/php.ini /usr/local/directadmin/plugins/cpguard/cpguard/setup/install.php  > /dev/null 2>&1


chown root.admin /etc/cpguard/logs
chmod 775 /etc/cpguard/logs
chown root.admin /etc/cpguard/logs/application.log
chown root.admin /etc/cpguard/logs/install.log
chown root.admin /etc/cpguard/logs/php_errors.log
chmod 664 /etc/cpguard/logs/application.log
chmod 664 /etc/cpguard/logs/install.log
chmod 664 /etc/cpguard/logs/php_errors.log
chmod 644 /etc/cpguard/chkrootkit.log
chmod 644 /etc/cpguard/rkhunter.log


chown admin.root /usr/local/directadmin/plugins/cpguard/data
chmod 775 /usr/local/directadmin/plugins/cpguard/data
chown root.admin /usr/local/directadmin/plugins/cpguard/data/domainowners
chown root.admin /usr/local/directadmin/plugins/cpguard/data/csf.conf
chown root.admin /usr/local/directadmin/plugins/cpguard/data/ip_list.txt
chmod 664 /usr/local/directadmin/plugins/cpguard/data/domainowners
chmod 664 /usr/local/directadmin/plugins/cpguard/data/csf.conf
chmod 664 /usr/local/directadmin/plugins/cpguard/data/ip_list.txt

chown root.admin /etc/cpguard/conf/main.conf
chmod 664 /etc/cpguard/conf/main.conf

echo "ALLOWIPCPROC=/usr/bin/postgres" >> /etc/rkhunter.conf

if which cagefsctl >/dev/null 2>&1; then
        echo "Updating CageFS Skelton....it may take  a while"
        sleep 3
        cagefsctl --force-update
fi


/usr/sbin/csf -a 104.248.44.154 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 159.89.96.209 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 94.237.29.205 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 37.97.190.233 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 72.14.186.130 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 188.116.8.88 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 45.77.35.77 "cPGuard" > /dev/null 2>&1
/usr/sbin/csf -a 94.130.24.31 "cPGuard" > /dev/null 2>&1


#rm -f /usr/local/directadmin/plugins/cpguard/cpguard/setup/
rm -f /usr/local/directadmin/plugins/cpguard/cpguard/setup/db.sql
rm -rf /usr/local/src/cpg

if [ -d /usr/local/directadmin/plugins/cpguard ] && [ -d /etc/cpguard ]; then
        echo -ne '\n'
        echo -ne '\n'
        echo -ne "cPGuard  installation has been completed ${green}[SUCCESS] ${NC}"
        echo -ne '\n'
        echo -ne "\r${green}Please refer the initial settings documentation and apply license to complete the installation procedure ${NC}"
        echo -ne '\n'
else
        echo -ne "\r${red}cPGuard Installation has been failed..please contact Support for further assistance ${NC}"
        echo -ne '\n'
fi

}

function dauninstall() {

/usr/local/directadmin/plugins/cpguard/cpguard/scripts/service_manager.php stop >/dev/null 2>&1
#yum remove clamav* -y
rm -rf /etc/cpguard
rm -rf  /usr/local/directadmin/plugins/cpguard
rm -f /etc/cron.d/cpguard
rm -rf /var/www/html/cpg
rm -rf /opt/cpguard

rm -f /etc/modsecurity.d/cpguard_waf.conf
rm -f /usr/local/directadmin/custombuild/custom/modsecurity/conf/cpguard_waf.conf
service  httpd restart > /dev/null 2>&1

#mysql <<EOF
#drop database cpanel_cpguard;
#EOF

}

#Main
red='\e[0;31m'
green='\e[0;32m'
blue='\e[4;34m'
NC='\e[0m'

if [ -f /etc/os-release ]; then
        OS=7
else
        OS=6
fi

if [ -f /usr/local/cpanel/cpsrvd ]; then
	CP="cpanel"
elif [ -f /usr/local/directadmin/directadmin ]; then
	CP="directadmin"
else	
	echo -ne "\r${red}You need to install cPanel or DirectAdmin on your server before installing cPGuard ${NC}"
        echo -ne '\n'
	exit
fi

if [ $# -eq 0 ]; then
        echo -ne "\r${red}Wrong option. Possible options are install OR uninstall ${NC}"
        echo -ne '\n'
elif [ $1 == "install" ]; then
	if [ $CP == "cpanel" ]; then
		echo -ne "\r${blue}Detected cPanel Control Panel ${NC}"
		echo -ne '\n'
		sleep 1
        	cpanelinstall
	elif [ $CP == "directadmin" ]; then
		echo -ne "\r${blue}Detected DirectAdmin Control Panel ${NC}"
		echo -ne '\n'
                sleep 1
                dainstall
	fi
elif [ $1 == "uninstall" ]; then
	if [ $CP == "cpanel" ]; then
                echo -ne "\r${blue}Detected cPanel Control Panel ${NC}"
	        echo -ne '\n'
                sleep 1
                cpaneluninstall
		echo "Sorry to see that you have uninstalled cPGuard on your server"
		echo "Please leave your feedback at https://opsshield.surveysparrow.com/s/Customer-Satisfaction-Survey/tt-a27b1c"
	elif [ $CP == "directadmin" ]; then
                echo -ne "\r${blue}Detected DirectAdmin Control Panel ${NC}"
		echo -ne '\n'
                sleep 1
                dauninstall
		echo "Sorry to see that you have uninstalled cPGuard on your server"
		echo "Please leave your feedback at https://opsshield.surveysparrow.com/s/Customer-Satisfaction-Survey/tt-a27b1c"
	fi
else
        echo -ne "\r${red}Wrong option. Possible options are install OR uninstall ${NC}"
        echo -ne '\n'
fi


Youez - 2016 - github.com/yon3zu
LinuXploit