lynis/include/tests_insecure_services

768 lines
42 KiB
Bash

#!/bin/sh
#################################################################################
#
# Lynis
# ------------------
#
# Copyright 2007-2013, Michael Boelen
# Copyright 2007-2019, CISOfy
#
# Website : https://cisofy.com
# Blog : http://linux-audit.com
# GitHub : https://github.com/CISOfy/lynis
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Insecure services
#
#################################################################################
#
InsertSection "Insecure services"
#
#################################################################################
#
INETD_ACTIVE=0
INETD_CONFIG_FILE="${ROOTDIR}etc/inetd.conf"
XINETD_ACTIVE=0
XINETD_CONFIG_FILE="${ROOTDIR}etc/xinetd.conf"
XINETD_CONFIG_DIR="${ROOTDIR}etc/xinetd.d"
#
#################################################################################
#
# 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"
if [ ${SKIPTEST} -eq 0 ]; then
# Check for installed inetd daemon
LogText "Test: Checking if inetd is installed"
PackageIsInstalled inetd
if [ $? -eq 0 ]; then
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"
else
LogText "Result: inetd is NOT installed"
Display --indent 2 --text "- Checking inetd installation" --result "${STATUS_OK}" --color GREEN
fi
fi
#
#################################################################################
#
# 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 [ ${SKIPTEST} -eq 0 ]; then
# Check running processes
LogText "Test: Searching for active inet daemon"
IsRunning inetd
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: inetd is running"
Display --indent 2 --text "- Checking 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
fi
fi
#
#################################################################################
#
# Test : INSE-8004
# Description : Check for inetd configuration file
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"
if [ ${SKIPTEST} -eq 0 ]; then
# Check configuration file
LogText "Test: Searching for file ${INETD_CONFIG_FILE}"
if [ -f ${INETD_CONFIG_FILE} ]; then
LogText "Result: ${INETD_CONFIG_FILE} exists"
Display --indent 4 --text "- Checking inetd.conf" --result "${STATUS_FOUND}" --color WHITE
else
LogText "Result: ${INETD_CONFIG_FILE} does not exist"
Display --indent 4 --text "- Checking inetd.conf" --result "${STATUS_NOT_FOUND}" --color WHITE
fi
fi
#
#################################################################################
#
# Test : INSE-8006
# Description : Check for inetd configuration file contents if inetd is NOT active
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"
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
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
ReportSuggestion ${TEST_NO} "Although inetd is not running, make sure no services are enabled in ${INETD_CONFIG_FILE}, or remove inetd service"
fi
fi
#
#################################################################################
#
# Test : INSE-8016
# Description : Check for telnet enabled via inetd
if [ ${INETD_ACTIVE} -eq 1 -a -f ${INETD_CONFIG_FILE} ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no INSE-8016 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for telnet via inetd"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking telnet presence in inetd configuration"
FIND=$(${GREPBINARY} "^telnet" ${INETD_CONFIG_FILE})
if [ "${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
else
LogText "Result: telnet enabled in ${INETD_CONFIG_FILE}"
Display --indent 2 --text "- Checking inetd (telnet)" --result "${STATUS_WARNING}" --color RED
ReportSuggestion "${TEST_NO}" "Disable telnet in inetd configuration and use SSH instead"
AddHP 1 3
fi
fi
#
#################################################################################
#
# Test : INSE-8100
# Description : Check for installed xinetd daemon
Register --test-no INSE-8100 --weight L --network NO --category security --description "Check for installed xinetd daemon"
if [ ${SKIPTEST} -eq 0 ]; then
# Check for installed xinetd daemon
LogText "Test: Checking for installed xinetd daemon"
PackageIsInstalled xinetd
if [ $? -eq 0 ]; then
LogText "Result: xinetd is installed"
Display --indent 2 --text "- Checking xinetd installation" --result "${STATUS_SUGGESTION}" --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
fi
fi
#
#################################################################################
#
# 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"
if [ ${SKIPTEST} -eq 0 ]; then
# Check running processes
LogText "Test: Searching for active xinet daemon"
IsRunning xinetd
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: xinetd is running"
Display --indent 4 --text "- Checking 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
fi
fi
#
#################################################################################
#
# Test : INSE-8104
# Description : Check for xinetd configuration file
if [ ${XINETD_ACTIVE} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no INSE-8104 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for enabled xinet daemon"
if [ ${SKIPTEST} -eq 0 ]; then
# Check configuration file
LogText "Test: Searching for file ${XINETD_CONFIG_FILE}"
if [ -f ${XINETD_CONFIG_FILE} ]; then
LogText "Result: ${XINETD_CONFIG_FILE} exists"
Display --indent 6 --text "- Checking 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
fi
fi
#
#################################################################################
#
# Test : INSE-8106
# Description : Check for xinetd configuration file contents if xinetd is NOT active
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)
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
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
ReportSuggestion ${TEST_NO} "Although xinetd is not running, make sure no services are enabled in ${XINETD_CONFIG_DIR}, or remove xinetd service"
fi
fi
#
#################################################################################
#
# 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"
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
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
fi
fi
#
#################################################################################
#
# 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
#
#################################################################################
#
# Test : INSE-8200
# Description : Check if tcp_wrappers is installed when inetd/xinetd is active
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=""
PACKAGES="tcp_wrappers tcpd"
for PACKAGE in ${PACKAGES}; do
PackageIsInstalled ${PACKAGE}
if [ $? -eq 0 ];then
FOUND=${PACKAGE}
fi
done
if [ ${FOUND} ]; 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"
fi
fi
#
#################################################################################
#
# Test : INSE-8300
# 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=""
PACKAGES="rsh rsh-client rsh-redone-client"
for PACKAGE in ${PACKAGES}; do
PackageIsInstalled ${PACKAGE}
if [ $? -eq 0 ];then
FOUND=${PACKAGE}
fi
done
if [ ${FOUND} ]; 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"
else
LogText "Result: rsh client is NOT installed"
Display --indent 2 --text "- Checking rsh client installation" --result "${STATUS_OK}" --color GREEN
fi
fi
#
#################################################################################
#
# 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
#
#################################################################################
#
# Test : INSE-8304
# Description : Check if rsh server is installed
Register --test-no INSE-8342 --weight L --network NO --category security --description "Check if rsh server is installed"
if [ ${SKIPTEST} -eq 0 ]; then
# Check if rsh server is installed
LogText "Test: Checking if rsh server is installed"
FOUND=""
PACKAGES="rsh-server rsh-redone-server"
for PACKAGE in ${PACKAGES}; do
PackageIsInstalled ${PACKAGE}
if [ $? -eq 0 ];then
FOUND=${PACKAGE}
fi
done
if [ ${FOUND} ]; 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"
else
LogText "Result: rsh server is NOT installed"
Display --indent 2 --text "- Checking rsh server installation" --result "${STATUS_OK}" --color GREEN
fi
fi
#
#################################################################################
#
# Test : INSE-8310
# Description : Check if telnet client is installed
Register --test-no INSE-8310 --weight L --network NO --category security --description "Check if telnet client is installed"
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
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"
else
LogText "Result: telnet client is NOT installed"
Display --indent 2 --text "- Checking telnet client installation" --result "${STATUS_OK}" --color GREEN
fi
fi
#
#################################################################################
#
# Test : INSE-8312
# Description : Check if telnet server is installed
Register --test-no INSE-8322 --weight L --network NO --category security --description "Check if telnet server is installed"
if [ ${SKIPTEST} -eq 0 ]; then
# Check if TFTP server is installed
LogText "Test: Checking if telnet server is installed"
FOUND=""
PACKAGES="telnetd telnet-server"
for PACKAGE in ${PACKAGES}; do
PackageIsInstalled ${PACKAGE}
if [ $? -eq 0 ];then
FOUND=${PACKAGE}
fi
done
if [ ${FOUND} ]; 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"
else
LogText "Result: telnet server is NOT installed"
Display --indent 2 --text "- Checking telnet server installation" --result "${STATUS_OK}" --color GREEN
fi
fi
#
#################################################################################
#
if [ ! -z "${LAUNCHCTL_BINARY}" ]; then PREQS_MET="YES"; SKIPREASON=""; else PREQS_MET="NO"; SKIPREASON="No launchctl binary on this system"; fi
Register --test-no INSE-8050 --os "macOS" --preqs-met ${PREQS_MET} --skip-reason "${SKIPREASON}" --weight M --network NO --category security --description "Check for insecure services on macOS"
if [ ${SKIPTEST} -eq 0 ]; then
TEST_SERVICES="com.apple.fingerd"
for ITEM in ${TEST_SERVICES}; do
if ${LAUNCHCTL_BINARY} print-enabled system | grep -sq ${ITEM}; then
Display --indent 2 --text "- $text" --result "${STATUS_NO}" --color RED
LogText "Result: found ${ITEM}, which is considered an insecure service"
AddSuggestion "${TEST_NO}" "Consider disabling service ${ITEM}" "launchctl" "-"
AddHP 0 1
else
Display --indent 2 --text "- $text" --result "${STATUS_OK}" --color GREEN
LogText "Result: $text, OK"
AddHP 1 1
fi
done
fi
#
#################################################################################
#
# To do:
# - mark in report when a system was tested for any insecure services
WaitForKeyPress
#
#================================================================================
# Lynis - Security Auditing and System Hardening for Linux and UNIX - https://cisofy.com