From 99362242784c9efd25b84b38a347f10933af1e1a Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Thu, 4 Apr 2019 14:42:39 +0200 Subject: [PATCH] Merge of several tests, cleanup, minor code enhancements and restructure --- include/tests_insecure_services | 589 ++++++++------------------------ 1 file changed, 134 insertions(+), 455 deletions(-) diff --git a/include/tests_insecure_services b/include/tests_insecure_services index 9490fa32..afed850e 100644 --- a/include/tests_insecure_services +++ b/include/tests_insecure_services @@ -28,6 +28,7 @@ # INETD_ACTIVE=0 INETD_CONFIG_FILE="${ROOTDIR}etc/inetd.conf" + INETD_PACKAGE_INSTALLED=0 XINETD_ACTIVE=0 XINETD_CONFIG_FILE="${ROOTDIR}etc/xinetd.conf" XINETD_CONFIG_DIR="${ROOTDIR}etc/xinetd.d" @@ -35,19 +36,19 @@ ################################################################################# # # Test : INSE-8000 - # Description : Check for installed inetd daemon - Register --test-no INSE-8000 --weight L --network NO --category security --description "Check for installed inetd daemon" + # Description : Check for installed inetd package + Register --test-no INSE-8000 --weight L --network NO --category security --description "Installed inetd package" if [ ${SKIPTEST} -eq 0 ]; then # Check for installed inetd daemon LogText "Test: Checking if inetd is installed" - PackageIsInstalled inetd - if [ $? -eq 0 ]; then + if PackageIsInstalled "inetd"; then + INETD_PACKAGE_INSTALLED=1 LogText "Result: inetd is installed" - Display --indent 2 --text "- Checking inetd installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "If there are no inetd services required, it is recommended that the daemon be removed" + Display --indent 2 --text "- Installation of inetd package" --result "${STATUS_FOUND}" --color YELLOW + #ReportSuggestion ${TEST_NO} "If there are no inetd services required, it is recommended that the daemon be removed" else LogText "Result: inetd is NOT installed" - Display --indent 2 --text "- Checking inetd installation" --result "${STATUS_OK}" --color GREEN + Display --indent 2 --text "- Installation of inetd package" --result "${STATUS_NOT_FOUND}" --color GREEN fi fi # @@ -55,27 +56,27 @@ # # Test : INSE-8002 # Description : Check for inetd status - Register --test-no INSE-8002 --weight L --network NO --category security --description "Check for enabled inet daemon" + if [ ${INETD_PACKAGE_INSTALLED} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi + Register --test-no INSE-8002 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for enabled inet daemon" if [ ${SKIPTEST} -eq 0 ]; then # Check running processes LogText "Test: Searching for active inet daemon" - IsRunning inetd - if [ ${RUNNING} -eq 1 ]; then + if IsRunning "inetd"; then LogText "Result: inetd is running" - Display --indent 2 --text "- Checking inetd status" --result "ACTIVE" --color GREEN + Display --indent 4 --text "- inetd status" --result "ACTIVE" --color GREEN INETD_ACTIVE=1 else LogText "Result: inetd is NOT running" - Display --indent 2 --text "- Checking inetd status" --result "NOT ACTIVE" --color GREEN + Display --indent 4 --text "- inetd status" --result "NOT ACTIVE" --color GREEN fi fi # ################################################################################# # # Test : INSE-8004 - # Description : Check for inetd configuration file + # Description : Check for inetd configuration file (inetd) if [ ${INETD_ACTIVE} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8004 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for enabled inet daemon" + Register --test-no INSE-8004 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Presence of inetd configuration file" if [ ${SKIPTEST} -eq 0 ]; then # Check configuration file LogText "Test: Searching for file ${INETD_CONFIG_FILE}" @@ -95,15 +96,15 @@ if [ ${INETD_ACTIVE} -eq 0 -a -f ${INETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi Register --test-no INSE-8006 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check configuration of inetd when disabled" if [ ${SKIPTEST} -eq 0 ]; then - # Check if any service is enabled in /etc/inetd.conf (inetd is not active, see test 8002) - LogText "Test: check if all services are disabled if inetd is disabled" + # Check if any service is enabled in /etc/inetd.conf (inetd is not active, see test INSE-8002) + LogText "Test: check if all services are disabled when inetd is disabled" FIND=$(${GREPBINARY} -v "^#" ${INETD_CONFIG_FILE} | ${GREPBINARY} -v "^$") if [ -z "${FIND}" ]; then LogText "Result: no services found in ${INETD_CONFIG_FILE}" - Display --indent 4 --text "- Checking inetd.conf services" --result "${STATUS_OK}" --color GREEN + Display --indent 4 --text "- Checking enabled inetd services" --result "${STATUS_OK}" --color GREEN else LogText "Result: found services in inetd, even though inetd is not running" - Display --indent 4 --text "- Checking inetd.conf services" --result "${STATUS_SUGGESTION}" --color YELLOW + Display --indent 4 --text "- Checking enabled inetd services" --result "${STATUS_SUGGESTION}" --color YELLOW ReportSuggestion ${TEST_NO} "Although inetd is not running, make sure no services are enabled in ${INETD_CONFIG_FILE}, or remove inetd service" fi fi @@ -117,7 +118,7 @@ if [ ${SKIPTEST} -eq 0 ]; then LogText "Test: checking telnet presence in inetd configuration" FIND=$(${GREPBINARY} "^telnet" ${INETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then + if [ -z "${FIND}" ]; then LogText "Result: telnet not enabled in ${INETD_CONFIG_FILE}" Display --indent 2 --text "- Checking inetd (telnet)" --result "${STATUS_NOT_FOUND}" --color GREEN AddHP 3 3 @@ -140,11 +141,11 @@ PackageIsInstalled xinetd if [ $? -eq 0 ]; then LogText "Result: xinetd is installed" - Display --indent 2 --text "- Checking xinetd installation" --result "${STATUS_SUGGESTION}" --color YELLOW + Display --indent 2 --text "- Installation of xinetd package" --result "${STATUS_FOUND}" --color YELLOW ReportSuggestion ${TEST_NO} "If there are no xinetd services required, it is recommended that the daemon be removed" else LogText "Result: xinetd is NOT installed" - Display --indent 2 --text "- Checking xinetd installation" --result "${STATUS_OK}" --color GREEN + Display --indent 2 --text "- Installation of xinetd package" --result "${STATUS_OK}" --color GREEN fi fi # @@ -152,18 +153,17 @@ # # Test : INSE-8102 # Description : Check for xinetd status - Register --test-no INSE-8102 --weight L --network NO --category security --description "Check for enabled xinet daemon" + Register --test-no INSE-8102 --weight L --network NO --category security --description "Check for active xinet daemon" if [ ${SKIPTEST} -eq 0 ]; then # Check running processes - LogText "Test: Searching for active xinet daemon" - IsRunning xinetd - if [ ${RUNNING} -eq 1 ]; then + LogText "Test: Searching for active extended internet services daemon (xinetd)" + if IsRunning "xinetd"; then LogText "Result: xinetd is running" - Display --indent 4 --text "- Checking xinetd status" --result "ACTIVE" --color GREEN + Display --indent 4 --text "- xinetd status" --result "ACTIVE" --color GREEN XINETD_ACTIVE=1 else LogText "Result: xinetd is NOT running" - Display --indent 4 --text "- Checking xinetd status" --result "NOT ACTIVE" --color GREEN + Display --indent 4 --text "- xinetd status" --result "NOT ACTIVE" --color GREEN fi fi # @@ -176,12 +176,12 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check configuration file LogText "Test: Searching for file ${XINETD_CONFIG_FILE}" - if [ -f ${XINETD_CONFIG_FILE} ]; then + if [ -f "${XINETD_CONFIG_FILE}" ]; then LogText "Result: ${XINETD_CONFIG_FILE} exists" - Display --indent 6 --text "- Checking xinetd.conf" --result "${STATUS_FOUND}" --color WHITE + Display --indent 6 --text "- Configuration file (xinetd.conf)" --result "${STATUS_FOUND}" --color WHITE else LogText "Result: ${XINETD_CONFIG_FILE} does not exist" - Display --indent 6 --text "- Checking xinetd.conf" --result "${STATUS_NOT_FOUND}" --color WHITE + Display --indent 6 --text "- Configuration file (xinetd.conf)" --result "${STATUS_NOT_FOUND}" --color WHITE fi fi # @@ -192,15 +192,15 @@ if [ ${XINETD_ACTIVE} -eq 0 -a -f ${XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi Register --test-no INSE-8106 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check configuration of xinetd when disabled" if [ ${SKIPTEST} -eq 0 ]; then - # Check if any service is enabled in /etc/xinetd.d (xinetd is not active, see test 8102) + # Check if any service is enabled in /etc/xinetd.d (xinetd is not active, see test INSE-8102) LogText "Test: check if all services are disabled if xinetd is disabled" FIND=$(${GREPBINARY} -r "disable\s*=\s*no" ${XINETD_CONFIG_DIR}) if [ -z "${FIND}" ]; then LogText "Result: no services found in ${XINETD_CONFIG_DIR}" - Display --indent 6 --text "- Checking xinetd.d services" --result "${STATUS_OK}" --color GREEN + Display --indent 6 --text "- Enabled xinetd.d services" --result "${STATUS_NOT_FOUND}" --color GREEN else LogText "Result: found services in ${XINETD_CONFIG_DIR}, even though xinetd is not running" - Display --indent 6 --text "- Checking xinetd.d services" --result "${STATUS_SUGGESTION}" --color YELLOW + Display --indent 6 --text "- Enabled xinetd.d services" --result "${STATUS_FOUND}" --color YELLOW ReportSuggestion ${TEST_NO} "Although xinetd is not running, make sure no services are enabled in ${XINETD_CONFIG_DIR}, or remove xinetd service" fi fi @@ -208,350 +208,41 @@ ################################################################################# # # Test : INSE-8116 - # Description : Check for telnet enabled via xinetd - TELNET_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/telnet" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${TELNET_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8116 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for telnet via xinetd" + # Description : Check for insecure services enabled via xinetd + if [ ${XINETD_ACTIVE} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi + Register --test-no INSE-8116 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Insecure services enabled via xinetd" if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking telnet presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${TELNET_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: telnet not enabled in ${TELNET_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (telnet)" --result "${STATUS_DISABLED}" --color GREEN + XINETD_INSECURE_SERVICE_FOUND=0 + + ITEMS="chargen chargen-dgram chargen-stream daytime daytime-dgram daytime-stream discard discard-dgram discard-stream echo echo-dgram echo-stream time time-dgram time-stream ntalk rexec rlogin rsh talk telnet tftp" + + for SERVICE in ${ITEMS}; do + LogText "Test: checking service ${SERVICE}" + if ! SkipAtomicTest "${TEST_NO}:${SERVICE}"; then + FILE="${XINETD_CONFIG_DIR}/${SERVICE}" + if [ -f "${FILE}" ]; then + LogText "Test: checking status in xinetd configuration file (${FILE})" + FIND=$(${GREPBINARY} "disable\s*=\s*no" ${FILE}) + if [ ! -z "${FIND}" ]; then + LogText "Result: found insecure service enabled: ${SERVICE}" + XINETD_INSECURE_SERVICE_FOUND=1 + ReportSuggestion "${TEST_NO}" "Disable or remove any insecure services in the xinetd configuration" "${SERVICE}" "text:See log file for more details" + Report "insecure_service[]=${SERVICE}" + fi + fi + else + LogText "Result: skipped, as this item is excluded using the profile" + fi + done + + if [ ${XINETD_INSECURE_SERVICE_FOUND} -eq 0 ]; then + LogText "Result: no insecure services found in xinetd configuration" + Display --indent 6 --text "- Checking xinetd (insecure services)" --result "${STATUS_OK}" --color GREEN AddHP 3 3 else - LogText "Result: telnet enabled in ${TELNET_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (telnet)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable telnet in xinetd configuration and use SSH instead" - AddHP 1 3 - fi - fi -# -################################################################################# -# - # Test : INSE-8118 - # Description : Check for rsh enabled via xinetd - RSH_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/rsh" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${RSH_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8118 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for rsh via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking rsh presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${RSH_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: rsh not enabled in ${RSH_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rsh)" --result "${STATUS_DISABLED}" --color GREEN - AddHP 3 3 - else - LogText "Result: rsh enabled in ${RSH_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rsh)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable rsh in xinetd configuration and use SSH instead" - AddHP 1 3 - fi - fi -# -################################################################################# -# - # Test : INSE-8120 - # Description : Check for rlogin enabled via xinetd - RLOGIN_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/rlogin" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${RLOGIN_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8120 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for rlogin via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking rlogin presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${RLOGIN_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: rlogin not enabled in ${RLOGIN_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rlogin)" --result "${STATUS_DISABLED}" --color GREEN - AddHP 3 3 - else - LogText "Result: rlogin enabled in ${RLOGIN_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rlogin)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable rlogin in xinetd configuration and use SSH instead" - AddHP 1 3 - fi - fi -# -################################################################################# -# - # Test : INSE-8122 - # Description : Check for rexec enabled via xinetd - REXEC_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/rexec" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${REXEC_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8122 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for rexec via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking rexec presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${REXEC_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: rexec not enabled in ${REXEC_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rexec)" --result "${STATUS_DISABLED}" --color GREEN - AddHP 3 3 - else - LogText "Result: rexec enabled in ${REXEC_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rexec)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable rexec in xinetd configuration and use SSH instead" - AddHP 1 3 - fi - fi -# -################################################################################# -# - # Test : INSE-8124 - # Description : Check for talk enabled via xinetd - TALK_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/talk" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${TALK_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8124 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for talk via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking talk presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${TALK_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: talk not enabled in ${TALK_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (talk)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: talk enabled in ${TALK_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (talk)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable talk in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8126 - # Description : Check for ntalk enabled via xinetd - NTALK_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/ntalk" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${NTALK_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8126 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for ntalk via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking ntalk presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${NTALK_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: ntalk not enabled in ${NTALK_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (ntalk)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: ntalk enabled in ${NTALK_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (ntalk)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable ntalk in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8128 - # Description : Check for chargen-dgram enabled via xinetd - CHARGEN_DGRAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/chargen-dgram" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${CHARGEN_DGRAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8128 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for chargen-dgram via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking chargen-dgram presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${CHARGEN_DGRAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: chargen-dgram not enabled in ${CHARGEN_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (chargen-dgram)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: chargen-dgram enabled in ${CHARGEN_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (chargen-dgram)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable chargen-dgram in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8130 - # Description : Check for chargen-stream enabled via xinetd - CHARGEN_STREAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/chargen-stream" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${CHARGEN-STREAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8130 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for chargen-stream via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking chargen-stream presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${CHARGEN_STREAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: chargen-stream not enabled in ${CHARGEN_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (chargen-stream)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: chargen-stream enabled in ${CHARGEN_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (chargen-stream)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable chargen-stream in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8132 - # Description : Check for daytime-dgram enabled via xinetd - DAYTIME_DGRAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/daytime-dgram" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${DAYTIME_DGRAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8132 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for daytime-dgram via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking daytime-dgram presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${DAYTIME_DGRAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: daytime-dgram not enabled in ${DAYTIME_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (daytime-dgram)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: daytime-dgram enabled in ${DAYTIME_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (daytime-dgram)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable daytime-dgram in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8134 - # Description : Check for daytime-stream enabled via xinetd - DAYTIME_STREAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/daytime-stream" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${DAYTIME_STREAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8134 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for daytime-stream via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking daytime-stream presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${DAYTIME_STREAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: daytime-stream not enabled in ${DAYTIME_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (daytime-stream)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: daytime-stream enabled in ${DAYTIME_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (daytime-stream)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable daytime-stream in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8136 - # Description : Check for discard-dgram enabled via xinetd - DISCARD_DGRAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/discard-dgram" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${DISCARD_DGRAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8136 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for discard-dgram via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking discard-dgram presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${DISCARD_DGRAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: discard-dgram not enabled in ${DISCARD_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (discard-dgram)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: discard-dgram enabled in ${DISCARD_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (discard-dgram)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable discard-dgram in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8138 - # Description : Check for discard-stream enabled via xinetd - DISCARD_STREAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/discard-stream" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${DISCARD_STREAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8138 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for discard-stream via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking discard-stream presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${DISCARD_STREAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: discard-stream not enabled in ${DISCARD_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (discard-stream)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: discard-stream enabled in ${DISCARD_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (discard-stream)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable discard-stream in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8140 - # Description : Check for echo-dgram enabled via xinetd - ECHO_DGRAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/echo-dgram" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${ECHO_DGRAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8140 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for echo-dgram via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking echo-dgram presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${ECHO_DGRAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: echo-dgram not enabled in ${ECHO_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (echo-dgram)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: echo-dgram enabled in ${ECHO_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (echo-dgram)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable echo-dgram in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8142 - # Description : Check for echo-stream enabled via xinetd - ECHO_STREAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/echo-stream" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${ECHO_STREAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8142 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for echo-stream via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking echo-stream presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${ECHO_STREAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: echo-stream not enabled in ${ECHO_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (echo-stream)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: echo-stream enabled in ${ECHO_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (echo-stream)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable echo-stream in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8144 - # Description : Check for time-dgram enabled via xinetd - TIME_DGRAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/time-dgram" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${TIME_DGRAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8144 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for time-dgram via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking time-dgram presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${TIME_DGRAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: time-dgram not enabled in ${TIME_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (time-dgram)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: time-dgram enabled in ${TIME_DGRAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (time-dgram)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable time-dgram in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8146 - # Description : Check for time-stream enabled via xinetd - TIME_STREAM_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/time-stream" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${TIME_STREAM_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8146 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for time-stream via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking time-stream presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${TIME_STREAM_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: time-stream not enabled in ${TIME_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (time-stream)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: time-stream enabled in ${TIME_STREAM_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (time-stream)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable time-stream in xinetd configuration" - fi - fi -# -################################################################################# -# - # Test : INSE-8148 - # Description : Check for tftp enabled via xinetd - TFTP_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/tftp" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${TFTP_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8148 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for tftp via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking tftp presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${TFTP_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: tftp not enabled in ${TFTP_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (tftp)" --result "${STATUS_DISABLED}" --color GREEN - AddHP 3 3 - else - LogText "Result: tftp enabled in ${TFTP_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (tftp)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable tftp in xinetd configuration" - AddHP 1 3 + LogText "Result: one ore more insecure services discovered in xinetd configuration" + Display --indent 6 --text "- Checking xinetd (insecure services)" --result "${STATUS_WARNING}" --color RED + AddHP 0 3 fi fi # @@ -559,21 +250,21 @@ # # Test : INSE-8150 # Description : Check for rsync enabled via xinetd - RSYNC_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/rsync" - if [ ${XINETD_ACTIVE} -eq 1 -a -f ${RSYNC_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi - Register --test-no INSE-8150 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for rsync via xinetd" - if [ ${SKIPTEST} -eq 0 ]; then - LogText "Test: checking rsync presence in xinetd configuration" - FIND=$(${GREPBINARY} "disable\s*=\s*no" ${RSYNC_XINETD_CONFIG_FILE}) - if [ "${FIND}" = "" ]; then - LogText "Result: rsync not enabled in ${RSYNC_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rsync)" --result "${STATUS_DISABLED}" --color GREEN - else - LogText "Result: rsync enabled in ${RSYNC_XINETD_CONFIG_FILE}" - Display --indent 6 --text "- Checking xinetd (rsync)" --result "${STATUS_ENABLED}" --color RED - ReportSuggestion "${TEST_NO}" "Disable rsync in xinetd configuration" - fi - fi + #RSYNC_XINETD_CONFIG_FILE="${XINETD_CONFIG_DIR}/rsync" + #if [ ${XINETD_ACTIVE} -eq 1 -a -f ${RSYNC_XINETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi + #Register --test-no INSE-8150 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for rsync via xinetd" + #if [ ${SKIPTEST} -eq 0 ]; then + # LogText "Test: checking rsync presence in xinetd configuration" + # FIND=$(${GREPBINARY} "disable\s*=\s*no" ${RSYNC_XINETD_CONFIG_FILE}) + # if [ "${FIND}" = "" ]; then + # LogText "Result: rsync not enabled in ${RSYNC_XINETD_CONFIG_FILE}" + # Display --indent 6 --text "- Checking xinetd (rsync)" --result "${STATUS_DISABLED}" --color GREEN + # else + # LogText "Result: rsync enabled in ${RSYNC_XINETD_CONFIG_FILE}" + # Display --indent 6 --text "- Checking xinetd (rsync)" --result "${STATUS_ENABLED}" --color RED + # ReportSuggestion "${TEST_NO}" "Disable rsync in xinetd configuration" + # fi + #fi # ################################################################################# # @@ -582,23 +273,19 @@ if [ ${INETD_ACTIVE} -eq 1 -o ${XINETD_ACTIVE} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi Register --test-no INSE-8200 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check if tcp_wrappers is installed when inetd/xinetd is active" if [ ${SKIPTEST} -eq 0 ]; then - # Check if tcp_wrappers is installed when inetd/xinetd is active LogText "Test: Checking if tcp_wrappers is installed" - FOUND="" + FOUND=0 PACKAGES="tcp_wrappers tcpd" for PACKAGE in ${PACKAGES}; do - PackageIsInstalled ${PACKAGE} - if [ $? -eq 0 ];then - FOUND=${PACKAGE} - fi + if PackageIsInstalled ${PACKAGE}; then FOUND=1; fi done - if [ ${FOUND} ]; then + if [ ${FOUND} -eq 1 ]; then LogText "Result: tcp_wrappers is installed" Display --indent 2 --text "- Checking tcp_wrappers installation" --result "${STATUS_OK}" --color GREEN else LogText "Result: tcp_wrappers is NOT installed" Display --indent 2 --text "- Checking tcp_wrappers installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "When network services are using the inetd/xinetd service, the tcp_wrappers package should be installed" + #ReportSuggestion ${TEST_NO} "When network services are using the inetd/xinetd service, the tcp_wrappers package should be installed" fi fi # @@ -608,20 +295,16 @@ # Description : Check if rsh client is installed Register --test-no INSE-8300 --weight L --network NO --category security --description "Check if rsh client is installed" if [ ${SKIPTEST} -eq 0 ]; then - # Check if rsh is installed LogText "Test: Checking if rsh client is installed" - FOUND="" + FOUND=0 PACKAGES="rsh rsh-client rsh-redone-client" for PACKAGE in ${PACKAGES}; do - PackageIsInstalled ${PACKAGE} - if [ $? -eq 0 ];then - FOUND=${PACKAGE} - fi + if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi done - if [ ${FOUND} ]; then + if [ ${FOUND} -eq 1 ]; then LogText "Result: rsh client is installed" Display --indent 2 --text "- Checking rsh client installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "Rsh client contain numerous security exposures and have been replaced with the more secure SSH package" + ReportSuggestion ${TEST_NO} "Remove rsh client when it is not in use or replace with the more secure SSH package" else LogText "Result: rsh client is NOT installed" Display --indent 2 --text "- Checking rsh client installation" --result "${STATUS_OK}" --color GREEN @@ -631,36 +314,36 @@ ################################################################################# # # Test : INSE-8302 - # Description : Check presence of Rsh Trust Files - Register --test-no INSE-8302 --weight L --network NO --category security --description "Check presence of Rsh Trust Files" - if [ ${SKIPTEST} -eq 0 ]; then - # Check presence of Rsh Trust Files - FOUND=0 - for LINE in $(${CAT_BINARY} /etc/passwd | ${EGREPBINARY} -v '^(root|halt|sync|shutdown)' | ${AWKBINARY} -F: '($7 !="/sbin/nologin" && $7 != "/bin/false") { print }'); do - USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1) - DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f6) - if [ -d ${DIR} ]; then - for RHOSTS in ${DIR}/.rhosts; do - if [ ! -h ${RHOSTS} -a -f ${RHOSTS} ]; then - LogText "FOUND .rhosts file in home directory ${DIR} of ${USER}" - FOUND=1 - fi - done - fi - done - if [ -f /etc/hosts.equiv ];then - LogText "FOUND /etc/hosts.equiv" - FOUND=1 - fi - if [ ${FOUND} -eq 1 ]; then - LogText "Result: found one or more Rsh Trust Files" - Display --indent 4 --text "- Checking presence of Rsh Trust Files" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "Remove every Rsh Trust Files as they can allow unauthenticated access to a system" - else - LogText "Result: no Rsh Trust Files found" - Display --indent 4 --text "- Checking presence of Rsh Trust Files" --result "${STATUS_OK}" --color GREEN - fi - fi + # Description : Check presence of rsh Trust Files + #Register --test-no INSE-8302 --weight L --network NO --category security --description "Check presence of rsh Trust Files" + #if [ ${SKIPTEST} -eq 0 ]; then + # # Check presence of Rsh Trust Files + # FOUND=0 + # for LINE in $(${CAT_BINARY} /etc/passwd | ${EGREPBINARY} -v '^(root|halt|sync|shutdown)' | ${AWKBINARY} -F: '($7 !="/sbin/nologin" && $7 != "/bin/false") { print }'); do + # USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1) + # DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f6) + # if [ -d ${DIR} ]; then + # for RHOSTS in ${DIR}/.rhosts; do + # if [ ! -h ${RHOSTS} -a -f ${RHOSTS} ]; then + # LogText "FOUND .rhosts file in home directory ${DIR} of ${USER}" + # FOUND=1 + # fi + # done + # fi + # done + # if [ -f /etc/hosts.equiv ];then + # LogText "FOUND /etc/hosts.equiv" + # FOUND=1 + # fi + # if [ ${FOUND} -eq 1 ]; then + # LogText "Result: found one or more Rsh Trust Files" + # Display --indent 4 --text "- Checking presence of Rsh Trust Files" --result "${STATUS_SUGGESTION}" --color YELLOW + # ReportSuggestion ${TEST_NO} "Remove every Rsh Trust Files as they can allow unauthenticated access to a system" + # else + # LogText "Result: no Rsh Trust Files found" + # Display --indent 4 --text "- Checking presence of Rsh Trust Files" --result "${STATUS_OK}" --color GREEN + # fi + #fi # ################################################################################# # @@ -670,19 +353,16 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check if rsh server is installed LogText "Test: Checking if rsh server is installed" - FOUND="" + FOUND=0 PACKAGES="rsh-server rsh-redone-server" for PACKAGE in ${PACKAGES}; do - PackageIsInstalled ${PACKAGE} - if [ $? -eq 0 ];then - FOUND=${PACKAGE} - fi + if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi done - if [ ${FOUND} ]; then + if [ ${FOUND} -eq 1 ]; then LogText "Result: rsh server is installed" Display --indent 2 --text "- Checking rsh server installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "Removing the rsh-server package decreases the risk of the accidental (or intentional) activation of rsh services" - + ReportSuggestion ${TEST_NO} "Remove the rsh-server package and replace with a more secure alternative like SSH" + Report "insecure_service[]=rsh-server" else LogText "Result: rsh server is NOT installed" Display --indent 2 --text "- Checking rsh server installation" --result "${STATUS_OK}" --color GREEN @@ -697,11 +377,12 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check if telnet client is installed LogText "Test: Checking if telnet client is installed" - PackageIsInstalled telnet - if [ $? -eq 0 ]; then + if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi + if [ ${FOUND} -eq 1 ]; then LogText "Result: telnet client is installed" - Display --indent 2 --text "- Checking telnet client installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "telnet client contain numerous security exposures and have been replaced with the more secure SSH package" + Display --indent 2 --text "- Checking telnet client installation" --result "${STATUS_FOUND}" --color YELLOW + # Telnet client usage might be used for troubleshooting instead of system administration + #ReportSuggestion ${TEST_NO} "telnet client contain numerous security exposures and have been replaced with the more secure SSH package" else LogText "Result: telnet client is NOT installed" Display --indent 2 --text "- Checking telnet client installation" --result "${STATUS_OK}" --color GREEN @@ -716,18 +397,16 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check if TFTP server is installed LogText "Test: Checking if telnet server is installed" - FOUND="" + FOUND=0 PACKAGES="telnetd telnet-server" for PACKAGE in ${PACKAGES}; do - PackageIsInstalled ${PACKAGE} - if [ $? -eq 0 ];then - FOUND=${PACKAGE} - fi + if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi done - if [ ${FOUND} ]; then + if [ ${FOUND} -eq 1 ]; then LogText "Result: telnet server is installed" - Display --indent 2 --text "- Checking telnet server installation" --result "${STATUS_SUGGESTION}" --color YELLOW - ReportSuggestion ${TEST_NO} "Removing the ${FOUND} package decreases the risk of the accidental (or intentional) activation of telnet services" + Display --indent 2 --text "- Checking telnet server installation" --result "${STATUS_FOUND}" --color YELLOW + ReportSuggestion ${TEST_NO} "Removing the ${FOUND} package and replace with SSH when possible" + Report "insecure_service[]=telnet-server" else LogText "Result: telnet server is NOT installed" Display --indent 2 --text "- Checking telnet server installation" --result "${STATUS_OK}" --color GREEN