From d0a730c321944093f33243b612edb8558d4e4e88 Mon Sep 17 00:00:00 2001 From: Samson-W Date: Wed, 7 Aug 2019 23:56:20 +0800 Subject: [PATCH] Modified 6.2~6.6 to be compatible with CentOS. --- bin/hardening/6.2_disable_avahi_server.sh | 18 +++++++++++++++--- bin/hardening/6.3_disable_print_server.sh | 18 +++++++++++++++--- bin/hardening/6.4_disable_dhcp.sh | 18 +++++++++++++++--- ...6.5_ensure_time_sync_server_is_installed.sh | 1 - bin/hardening/6.6_disable_ldap.sh | 18 +++++++++++++++--- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/bin/hardening/6.2_disable_avahi_server.sh b/bin/hardening/6.2_disable_avahi_server.sh index a810b9d..9d3a455 100755 --- a/bin/hardening/6.2_disable_avahi_server.sh +++ b/bin/hardening/6.2_disable_avahi_server.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9 or CentOS Hardening +# Modify by: Samson-W (samson@hardenedlinux.org) # # @@ -15,9 +16,13 @@ HARDENING_LEVEL=3 HARDENING_EXCEPTION=dns PACKAGES='avahi-daemon libavahi-common-data libavahi-common3 libavahi-core7' +PACKAGES_REDHAT='avahi' # This function will be called if the script status is on enabled / audit mode audit () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -34,6 +39,9 @@ audit () { # This function will be called if the script status is on enabled mode apply () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -41,8 +49,12 @@ apply () { warn "$PACKAGE is installed! But the exception is set to true, so don't need any operate." else crit "$PACKAGE is installed, purging it" - apt-get purge $PACKAGE -y - apt-get autoremove + if [ $OS_RELEASE -eq 2 ]; then + yum autoremove $PACKAGE -y + else + apt-get purge $PACKAGE -y + apt-get autoremove + fi fi else ok "$PACKAGE is absent" diff --git a/bin/hardening/6.3_disable_print_server.sh b/bin/hardening/6.3_disable_print_server.sh index 3f5cd9b..83f7328 100755 --- a/bin/hardening/6.3_disable_print_server.sh +++ b/bin/hardening/6.3_disable_print_server.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9 or CentOS Hardening +# Modify by: Samson-W (samson@hardenedlinux.org) # # @@ -15,9 +16,13 @@ HARDENING_LEVEL=3 HARDENING_EXCEPTION=cups PACKAGES='libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 cups-common cups-client cups-ppdc libcupsfilters1 cups-filters cups' +PACKAGES_REDHAT='cups' # This function will be called if the script status is on enabled / audit mode audit () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -34,6 +39,9 @@ audit () { # This function will be called if the script status is on enabled mode apply () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -41,8 +49,12 @@ apply () { warn "$PACKAGE is installed! But the exception is set to true, so don't need any operate." else crit "$PACKAGE is installed, purging it" - apt-get purge $PACKAGE -y - apt-get autoremove + if [ $OS_RELEASE -eq 2 ]; then + yum autoremove $PACKAGE -y + else + apt-get purge $PACKAGE -y + apt-get autoremove + fi fi else ok "$PACKAGE is absent" diff --git a/bin/hardening/6.4_disable_dhcp.sh b/bin/hardening/6.4_disable_dhcp.sh index d99e060..778b48b 100755 --- a/bin/hardening/6.4_disable_dhcp.sh +++ b/bin/hardening/6.4_disable_dhcp.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9 or CentOS Hardening +# Modify by: Samson-W (samson@hardenedlinux.org) # # @@ -15,9 +16,13 @@ HARDENING_LEVEL=3 HARDENING_EXCEPTION=dhcp PACKAGES='udhcpd isc-dhcp-server' +PACKAGES_REDHAT='dnsmasq' # This function will be called if the script status is on enabled / audit mode audit () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -34,6 +39,9 @@ audit () { # This function will be called if the script status is on enabled mode apply () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -41,8 +49,12 @@ apply () { warn "$PACKAGE is installed! But the exception is set to true, so don't need any operate." else crit "$PACKAGE is installed, purging it" - apt-get purge $PACKAGE -y - apt-get autoremove + if [ $OS_RELEASE -eq 2 ]; then + yum autoremove $PACKAGE -y + else + apt-get purge $PACKAGE -y + apt-get autoremove + fi fi else ok "$PACKAGE is absent" diff --git a/bin/hardening/6.5_ensure_time_sync_server_is_installed.sh b/bin/hardening/6.5_ensure_time_sync_server_is_installed.sh index bc54001..e561b63 100755 --- a/bin/hardening/6.5_ensure_time_sync_server_is_installed.sh +++ b/bin/hardening/6.5_ensure_time_sync_server_is_installed.sh @@ -14,7 +14,6 @@ set -u # One variable unset, it's over HARDENING_LEVEL=3 PACKAGES='ntp chrony' -PACKAGES_COUNT=$(echo $PACKAGES | wc -w) # This function will be called if the script status is on enabled / audit mode audit () { diff --git a/bin/hardening/6.6_disable_ldap.sh b/bin/hardening/6.6_disable_ldap.sh index 8d9b6ac..1e5c315 100755 --- a/bin/hardening/6.6_disable_ldap.sh +++ b/bin/hardening/6.6_disable_ldap.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9 or CentOS Hardening +# Modify by: Samson-W (samson@hardenedlinux.org) # # @@ -15,9 +16,13 @@ HARDENING_LEVEL=3 HARDENING_EXCEPTION=ldap PACKAGES='slapd' +PACKAGES_REDHAT='openldap-servers' # This function will be called if the script status is on enabled / audit mode audit () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -34,6 +39,9 @@ audit () { # This function will be called if the script status is on enabled mode apply () { + if [ $OS_RELEASE -eq 2 ]; then + PACKAGES=$PACKAGES_REDHAT + fi for PACKAGE in $PACKAGES; do is_pkg_installed $PACKAGE if [ $FNRET = 0 ]; then @@ -41,8 +49,12 @@ apply () { warn "$PACKAGE is installed! But the exception is set to true, so don't need any operate." else crit "$PACKAGE is installed, purging it" - apt-get purge $PACKAGE -y - apt-get autoremove + if [ $OS_RELEASE -eq 2 ]; then + yum autoremove $PACKAGE -y + else + apt-get purge $PACKAGE -y + apt-get autoremove + fi fi else ok "$PACKAGE is absent"