lynis/include/tests_snmp

110 lines
4.4 KiB
Plaintext
Raw Normal View History

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.
#
#################################################################################
#
# SNMP related tests
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
2016-09-10 16:12:44 +02:00
SNMP_DAEMON_CONFIG_LOCS="${ROOTDIR}etc/snmp"
2014-08-26 17:33:55 +02:00
SNMP_DAEMON_CONFIG=""
SNMP_DAEMON_RUNNING=0
#
#################################################################################
#
InsertSection "SNMP Support"
# Test : SNMP-3302
# Description : Check for a running SNMP daemon
Register --test-no SNMP-3302 --weight L --network NO --category security --description "Check for running SNMP daemon"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for a SNMP daemon"
2014-09-15 12:01:09 +02:00
# Check running processes
IsRunning snmpd
if [ ${RUNNING} -eq 1 ]; then
SNMP_DAEMON_RUNNING=1
LogText "Result: SNMP daemon is running"
Display --indent 2 --text "- Checking running SNMP daemon" --result "${STATUS_FOUND}" --color GREEN
2016-09-10 16:12:44 +02:00
else
LogText "Result: No running SNMP daemon found"
Display --indent 2 --text "- Checking running SNMP daemon" --result "${STATUS_NOT_FOUND}" --color WHITE
2014-09-15 12:01:09 +02:00
fi
2014-08-26 17:33:55 +02:00
fi
#
#################################################################################
#
# Test : SNMP-3304
# Description : Determine SNMP daemon configuration file location
if [ ${SNMP_DAEMON_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no SNMP-3304 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check SNMP daemon file location"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: searching for snmpd.conf file"
2014-09-15 12:01:09 +02:00
for I in ${SNMP_DAEMON_CONFIG_LOCS}; do
if [ -f "${I}/snmpd.conf" ]; then
2016-09-10 16:12:44 +02:00
LogText "Result: ${I}/snmpd.conf exists"
SNMP_DAEMON_CONFIG="${I}/snmpd.conf"
2014-09-15 12:01:09 +02:00
fi
done
2016-09-10 16:12:44 +02:00
if [ -z "${SNMP_DAEMON_CONFIG}" ]; then
LogText "Result: No snmpd configuration found"
Display --indent 4 --text "- Checking SNMP configuration" --result "${STATUS_NOT_FOUND}" --color WHITE
2016-09-10 16:12:44 +02:00
else
LogText "Result: using last found configuration file: ${SNMP_DAEMON_CONFIG}"
Display --indent 4 --text "- Checking SNMP configuration" --result "${STATUS_FOUND}" --color GREEN
2014-09-15 12:01:09 +02:00
fi
2014-08-26 17:33:55 +02:00
fi
#
#################################################################################
#
# Test : SNMP-3306
# Description : Determine SNMP communities
2017-04-23 20:06:54 +02:00
if [ ! -z "${SNMP_DAEMON_CONFIG}" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no SNMP-3306 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check SNMP communities"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
WARN=0
LogText "Test: reading active snmp communities"
2016-09-10 16:12:44 +02:00
FIND=$(${AWKBINARY} '/^com2sec/ { print $4 }' ${SNMP_DAEMON_CONFIG})
2014-08-26 17:33:55 +02:00
for I in ${FIND}; do
LogText "Output: ${I}"
2014-08-26 17:33:55 +02:00
if [ "${I}" = "public" -o "${I}" = "private" ]; then
LogText "Result: found easy guessable snmp community string (${I})"
2014-08-26 17:33:55 +02:00
WARN=1
AddHP 1 3
fi
done
# Check status of test
if [ ${WARN} -eq 0 ]; then
Display --indent 2 --text "- Checking SNMP community strings" --result "${STATUS_OK}" --color GREEN
2014-08-26 17:33:55 +02:00
AddHP 2 2
2016-09-10 16:12:44 +02:00
else
Display --indent 2 --text "- Checking SNMP community strings" --result "${STATUS_WARNING}" --color RED
ReportWarning ${TEST_NO} "Found easy guessable SNMP community string"
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
WaitForKeyPress
2014-08-26 17:33:55 +02:00
#
#================================================================================
2017-02-09 13:35:40 +01:00
# Lynis - Copyright 2007-2017 Michael Boelen, CISOfy - https://cisofy.com