additional_hardening

additional_hardening(){
    clear
    f_banner
    echo -e "\e[34m---------------------------------------------------------------------------------------------------------\e[00m"
    echo -e "\e[93m[+]\e[00m Running additional Hardening Steps"
    echo -e "\e[34m---------------------------------------------------------------------------------------------------------\e[00m"
    echo ""
    echo "Running Additional Hardening Steps...."
    spinner
    echo tty1 > /etc/securetty
    chmod 0600 /etc/securetty
    chmod 700 /root
    chmod 600 /boot/grub/grub.cfg
    #Protect Against IP Spoofing
    echo nospoof on >> /etc/host.conf
    #Remove AT and Restrict Cron
    apt-get purge at
    echo " Securing Cron "
    touch /etc/cron.allow
    chmod 600 /etc/cron.allow
    awk -F: '{print $1}' /etc/passwd | grep -v root > /etc/cron.deny
    echo "Do you want to Disable USB Support for this Server? y/n" ; read usb_answer
    if [ "$usb_answer" == "y" ]; then
       echo "blacklist usb-storage" | sudo tee -a /etc/modprobe.d/blacklist.conf
       update-initramfs -u
       echo "OK"
       say_done
    else
       echo "OK"
       say_done
    fi
}

La función additional_hardening sigue algunos pasos para mejorar el nivel de seguridad de nuestro servidor. Vamos verlos en detalle.

    echo tty1 > /etc/securetty

Pasando solo esta directiva a /etc/securetty restringimos el acceso de root solo a una terminal local. Es por esto que para las tareas administrativas deben hacer un acceso remoto al servidor con el usuario que crearon y una vez dentro se cambian al usuario root.

    chmod 0600 /etc/securetty
    chmod 700 /root
    chmod 600 /boot/grub/grub.cfg

En esta sección colocamos permisos mas restrictivos a archivos críticos.

    echo nospoof on >> /etc/host.conf

Aquí protegemos al servidor contra el IP Spoofing.

apt-get purge at
    echo " Securing Cron "
    touch /etc/cron.allow
    chmod 600 /etc/cron.allow
    awk -F: '{print $1}' /etc/passwd | grep -v root > /etc/cron.deny

Aquí eliminamos AT y restringimos el uso de cron exclusivamente a root.


    echo "Do you want to Disable USB Support for this Server? y/n" ; read usb_answer
    if [ "$usb_answer" == "y" ]; then
       echo "blacklist usb-storage" | sudo tee -a /etc/modprobe.d/blacklist.conf
       update-initramfs -u
       echo "OK"
       say_done
    else
       echo "OK"

En esta sección a opción del usuario se deshabilita el soporte para almacenamiento USB.