2014-08-26 17:33:55 +02:00
#!/bin/sh
#################################################################################
#
# Lynis
# ------------------
#
2016-03-13 16:00:39 +01:00
# Copyright 2007-2013, Michael Boelen
2017-02-09 13:35:40 +01:00
# Copyright 2007-2017, CISOfy
2016-03-13 16:00:39 +01:00
#
# Website : https://cisofy.com
# Blog : http://linux-audit.com
# GitHub : https://github.com/CISOfy/lynis
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
2016-09-10 16:12:44 +02:00
INETD_CONFIG_FILE="${ROOTDIR}etc/inetd.conf"
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
# Test : INSE-8002
# Description : Check for inetd status
2016-07-24 17:22:00 +02:00
Register --test-no INSE-8002 --weight L --network NO --category security --description "Check for enabled inet daemon"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
2014-09-15 10:32:36 +02:00
# Check running processes
2015-12-21 21:17:15 +01:00
LogText "Test: Searching for active inet daemon"
2014-09-15 10:32:36 +02:00
IsRunning inetd
if [ ${RUNNING} -eq 1 ]; then
2015-12-21 21:17:15 +01:00
LogText "Result: inetd is running"
2016-06-18 11:14:01 +02:00
Display --indent 2 --text "- Checking inetd status" --result "ACTIVE" --color GREEN
2014-09-15 10:32:36 +02:00
INETD_ACTIVE=1
2016-09-05 12:56:58 +02:00
else
2015-12-21 21:17:15 +01:00
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
2014-09-15 10:32:36 +02:00
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
2016-07-24 17:22:00 +02:00
Register --test-no INSE-8004 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for enabled inet daemon"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
2014-09-15 10:32:36 +02:00
# Check configuration file
2015-12-21 21:17:15 +01:00
LogText "Test: Searching for file ${INETD_CONFIG_FILE}"
2014-09-15 10:32:36 +02:00
if [ -f ${INETD_CONFIG_FILE} ]; then
2015-12-21 21:17:15 +01:00
LogText "Result: ${INETD_CONFIG_FILE} exists"
2016-06-18 11:14:01 +02:00
Display --indent 4 --text "- Checking inetd.conf" --result "${STATUS_FOUND}" --color WHITE
2016-09-05 12:56:58 +02:00
else
2015-12-21 21:17:15 +01:00
LogText "Result: ${INETD_CONFIG_FILE} does not exist"
2016-06-18 11:14:01 +02:00
Display --indent 4 --text "- Checking inetd.conf" --result "${STATUS_NOT_FOUND}" --color WHITE
2014-09-15 10:32:36 +02:00
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
2016-07-24 17:22:00 +02:00
Register --test-no INSE-8006 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check configuration of inetd when disabled"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
2014-09-15 10:32:36 +02:00
# Check if any service is enabled in /etc/inetd.conf (inetd is not active, see test 8002)
2015-12-21 21:17:15 +01:00
LogText "Test: check if all services are disabled if inetd is disabled"
2016-09-05 12:56:58 +02:00
FIND=$(${GREPBINARY} -v "^#" ${INETD_CONFIG_FILE} | ${GREPBINARY} -v "^$")
if [ -z "${FIND}" ]; then
LogText "Result: no services found in ${INETD_CONFIG_FILE}"
2016-06-18 11:14:01 +02:00
Display --indent 4 --text "- Checking inetd.conf services" --result "${STATUS_OK}" --color GREEN
2016-09-05 12:56:58 +02:00
else
LogText "Result: found services in inetd, even though inetd is not running"
2016-06-18 11:14:01 +02:00
Display --indent 4 --text "- Checking inetd.conf services" --result "${STATUS_SUGGESTION}" --color YELLOW
2016-09-05 12:56:58 +02:00
ReportSuggestion ${TEST_NO} "Although inetd is not running, make sure no services are enabled in ${INETD_CONFIG_FILE}, or remove inetd service"
2014-09-15 10:32:36 +02:00
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
2016-07-24 17:22:00 +02:00
Register --test-no INSE-8016 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for telnet via inetd"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
2015-12-21 21:17:15 +01:00
LogText "Test: checking telnet presence in inetd configuration"
2016-09-05 12:56:58 +02:00
FIND=$(${GREPBINARY} "^telnet" ${INETD_CONFIG_FILE})
2014-09-15 10:32:36 +02:00
if [ "${FIND}" = "" ]; then
2015-12-21 21:17:15 +01:00
LogText "Result: telnet not enabled in ${INETD_CONFIG_FILE}"
2016-06-18 11:14:01 +02:00
Display --indent 2 --text "- Checking inetd (telnet)" --result "${STATUS_NOT_FOUND}" --color GREEN
2014-09-15 10:38:13 +02:00
AddHP 3 3
2016-09-05 12:56:58 +02:00
else
2015-12-21 21:17:15 +01:00
LogText "Result: telnet enabled in ${INETD_CONFIG_FILE}"
2016-06-18 11:14:01 +02:00
Display --indent 2 --text "- Checking inetd (telnet)" --result "${STATUS_WARNING}" --color RED
2014-09-15 10:38:13 +02:00
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
#
#################################################################################
#
2016-10-05 09:50:06 +02:00
if [ ! -z "${LAUNCHCTL_BINARY}" ]; then PREQS_MET="YES"; SKIPREASON=""; else PREQS_MET="NO"; SKIPREASON="No launchctl binary on this system"; fi
2016-11-05 11:53:22 +01:00
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"
2016-10-05 09:50:06 +02:00
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
2014-08-26 17:33:55 +02:00
2016-04-28 12:31:57 +02:00
WaitForKeyPress
2014-08-26 17:33:55 +02:00
#
#================================================================================
2016-03-13 16:03:46 +01:00
# Lynis - Security Auditing and System Hardening for Linux and UNIX - https://cisofy.com