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.
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
2015-01-03 12:45:22 +01:00
|
|
|
# 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
|
2016-07-24 17:22:00 +02:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: SNMP daemon is running"
|
2016-06-18 11:14:01 +02:00
|
|
|
Display --indent 2 --text "- Checking running SNMP daemon" --result "${STATUS_FOUND}" --color GREEN
|
2016-09-10 16:12:44 +02:00
|
|
|
else
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: No running SNMP daemon found"
|
2016-06-18 11:14:01 +02:00
|
|
|
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
|
2016-07-24 17:22:00 +02:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: No snmpd configuration found"
|
2016-06-18 11:14:01 +02:00
|
|
|
Display --indent 4 --text "- Checking SNMP configuration" --result "${STATUS_NOT_FOUND}" --color WHITE
|
2016-09-10 16:12:44 +02:00
|
|
|
else
|
|
|
|
LogText "Restult: using last found configuration file: ${SNMP_DAEMON_CONFIG}"
|
2016-06-18 11:14:01 +02:00
|
|
|
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
|
2016-09-10 16:12:44 +02:00
|
|
|
if [ ! "${SNMP_DAEMON_CONFIG}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
|
2016-07-24 17:22:00 +02:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
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
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Output: ${I}"
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ "${I}" = "public" -o "${I}" = "private" ]; then
|
2015-12-21 21:17:15 +01:00
|
|
|
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
|
2016-06-18 11:14:01 +02:00
|
|
|
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
|
2016-06-18 11:14:01 +02:00
|
|
|
Display --indent 2 --text "- Checking SNMP community strings" --result "${STATUS_WARNING}" --color RED
|
2016-08-10 07:13:19 +02:00
|
|
|
ReportWarning ${TEST_NO} "Found easy guessable SNMP community string"
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
|
2016-04-28 12:31:57 +02:00
|
|
|
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
|