lynis/include/tests_insecure_services

112 lines
4.9 KiB
Plaintext
Raw Normal View History

2014-08-26 17:33:55 +02:00
#!/bin/sh
#################################################################################
#
# Lynis
# ------------------
#
2015-07-22 16:28:11 +02:00
# Copyright 2007-2015, Michael Boelen, CISOfy (michael.boelen@cisofy.com)
# Web site: https://cisofy.com
2014-08-26 17:33:55 +02:00
#
# 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.
#
#################################################################################
#
# Unsecure services
#
#################################################################################
#
InsertSection "Insecure services"
#
#################################################################################
#
INETD_ACTIVE=0
INETD_CONFIG_FILE="/etc/inetd.conf"
#
#################################################################################
#
# Test : INSE-8002
# Description : Check for inetd status
Register --test-no INSE-8002 --weight L --network NO --description "Check for enabled inet daemon"
if [ ${SKIPTEST} -eq 0 ]; then
# Check running processes
2014-09-15 12:01:09 +02:00
logtext "Test: Searching for active inet daemon"
IsRunning inetd
if [ ${RUNNING} -eq 1 ]; then
logtext "Result: inetd is running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking inetd status" --result ACTIVE --color GREEN
INETD_ACTIVE=1
else
logtext "Result: inetd is NOT running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking inetd status" --result "NOT ACTIVE" --color GREEN
fi
2014-08-26 17:33:55 +02:00
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 --description "Check for enabled inet daemon"
if [ ${SKIPTEST} -eq 0 ]; then
# Check configuration file
2014-09-15 12:01:09 +02:00
logtext "Test: Searching for file ${INETD_CONFIG_FILE}"
if [ -f ${INETD_CONFIG_FILE} ]; then
logtext "Result: ${INETD_CONFIG_FILE} exists"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking inetd.conf" --result FOUND --color WHITE
else
logtext "Result: ${INETD_CONFIG_FILE} does not exist"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking inetd.conf" --result "NOT FOUND" --color WHITE
fi
2014-08-26 17:33:55 +02:00
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 --description "Check configuration of inetd when disabled"
2014-08-26 17:33:55 +02:00
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=`cat ${INETD_CONFIG_FILE} | grep -v "^#" | grep -v "^$"`
if [ "${FIND}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking inetd.conf services" --result OK --color GREEN
else
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking inetd.conf services" --result SUGGESTION --color YELLOW
ReportSuggestion ${TEST_NO} "Although inetd is not running, make sure no services are enabled in ${INETD_CONFIG_FILE}"
fi
2014-08-26 17:33:55 +02:00
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 --description "Check for telnet via inetd"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking telnet presence in inetd configuration"
FIND=`grep "^telnet" ${INETD_CONFIG_FILE}`
if [ "${FIND}" = "" ]; then
logtext "Result: telnet not enabled in ${INETD_CONFIG_FILE}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking inetd (telnet)" --result "NOT FOUND" --color GREEN
AddHP 3 3
else
logtext "Result: telnet enabled in ${INETD_CONFIG_FILE}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking inetd (telnet)" --result WARNING --color RED
ReportSuggestion "${TEST_NO}" "Disable telnet in inetd configuration and use SSH instead"
AddHP 1 3
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
wait_for_keypress
#
#================================================================================
2015-07-22 16:28:11 +02:00
# Lynis - Copyright 2007-2015, Michael Boelen, CISOfy - https://cisofy.com