lynis/include/tests_malware

248 lines
9.6 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.
#
#################################################################################
#
# Malware scanners
#
#################################################################################
#
InsertSection "Software: Malware scanners"
#
#################################################################################
#
CLAMD_RUNNING=0
CLAMSCAN_INSTALLED=0
ESET_DAEMON_RUNNING=0
FRESHCLAM_DAEMON_RUNNING=0
2015-05-04 13:37:36 +02:00
MCAFEE_SCANNER_RUNNING=0
2014-08-26 17:33:55 +02:00
MALWARE_SCANNER_INSTALLED=0
2015-05-04 13:37:36 +02:00
SOPHOS_SCANNER_RUNNING=0
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
# Test : MALW-3275
# Description : Check for installed tool (chkrootkit)
Register --test-no MALW-3275 --weight L --network NO --description "Check for chkrootkit"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking presence chkrootkit"
if [ ! "${CHKROOTKITBINARY}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking chkrootkit" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
logtext "Result: Found ${CHKROOTKITBINARY}"
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=chkrootkit"
2014-08-26 17:33:55 +02:00
else
logtext "Result: chkrootkit not found"
fi
fi
#
#################################################################################
#
# Test : MALW-3276
2015-09-07 17:35:07 +02:00
# Description : Check for installed tool (Rootkit Hunter)
2014-08-26 17:33:55 +02:00
Register --test-no MALW-3276 --weight L --network NO --description "Check for Rootkit Hunter"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking presence Rootkit Hunter"
if [ ! "${RKHUNTERBINARY}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking Rootkit Hunter" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
logtext "Result: Found ${RKHUNTERBINARY}"
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=rkhunter"
2014-08-26 17:33:55 +02:00
else
logtext "Result: Rootkit Hunter not found"
fi
fi
#
#################################################################################
#
# Test : MALW-3278
# Description : Check for installed tool (Linux Malware Detect or LMD)
Register --test-no MALW-3278 --weight L --network NO --description "Check for LMD"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking presence LMD"
if [ ! "${LMDBINARY}" = "" ]; then
Display --indent 2 --text "- Checking LMD (Linux Malware Detect)" --result "FOUND" --color GREEN
logtext "Result: Found ${LMDBINARY}"
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=lmd"
else
logtext "Result: LMD not found"
fi
fi
#
#################################################################################
2014-08-26 17:33:55 +02:00
#
# Test : MALW-3280
# Description : Check if an anti-virus tool is installed
2015-04-01 14:45:12 +02:00
Register --test-no MALW-3280 --weight L --network NO --description "Check if anti-virus tool is installed"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
FOUND=0
# ESET security products
logtext "Test: checking process esets_daemon"
IsRunning esets_daemon
if [ ${RUNNING} -eq 1 ]; then
FOUND=1
Display --indent 2 --text "- Checking ESET daemon" --result "FOUND" --color GREEN
logtext "Result: found ESET security product"
ESET_DAEMON_RUNNING=1
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=eset"
fi
# McAfee products
logtext "Test: checking process cma or cmdagent (McAfee)"
# cma is too generic to match on, so we want to ensure that it is related to McAfee first
if [ -x /opt/McAfee/cma/bin/cma ]; then
IsRunning cma
2015-05-04 13:37:36 +02:00
if [ ${RUNNING} -eq 1 ]; then MCAFEE_SCANNER_RUNNING=1; fi
else
IsRunning cmdagent
2015-05-04 13:37:36 +02:00
if [ ${RUNNING} -eq 1 ]; then MCAFEE_SCANNER_RUNNING=1; fi
fi
2015-05-04 13:37:36 +02:00
if [ ${MCAFEE_SCANNER_RUNNING} -eq 1 ]; then
2014-08-26 17:33:55 +02:00
FOUND=1
Display --indent 2 --text "- Checking McAfee" --result "FOUND" --color GREEN
logtext "Result: Found McAfee"
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=mcafee"
2014-08-26 17:33:55 +02:00
fi
2015-05-04 13:37:36 +02:00
# Sophos savscand/SophosScanD
logtext "Test: checking process savscand"
IsRunning savscand
if [ ${RUNNING} -eq 1 ]; then
FOUND=1
SOPHOS_SCANNER_RUNNING=1
2015-05-04 13:37:36 +02:00
fi
2014-08-26 17:33:55 +02:00
logtext "Test: checking process SophosScanD"
IsRunning SophosScanD
if [ ${RUNNING} -eq 1 ]; then
FOUND=1
SOPHOS_SCANNER_RUNNING=1
2015-05-04 13:37:36 +02:00
fi
if [ ${SOPHOS_SCANNER_RUNNING} -eq 1 ]; then
2014-08-26 17:33:55 +02:00
Display --indent 2 --text "- Checking Sophos" --result "FOUND" --color GREEN
logtext "Result: Found Sophos"
MALWARE_SCANNER_INSTALLED=1
AddHP 2 2
report "malware_scanner[]=sophos"
2014-08-26 17:33:55 +02:00
fi
if [ ${FOUND} -eq 0 ]; then
logtext "Result: no commercial anti-virus tools found"
2014-08-26 17:33:55 +02:00
AddHP 0 3
fi
fi
#
#################################################################################
#
# Test : MALW-3282
# Description : Check if clamscan is installed
Register --test-no MALW-3282 --weight L --network NO --description "Check for clamscan"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking presence clamscan"
if [ ! "${CLAMSCANBINARY}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking ClamAV scanner" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
logtext "Result: Found ${CLAMSCANBINARY}"
MALWARE_SCANNER_INSTALLED=1
CLAMSCAN_INSTALLED=1
2014-08-26 17:33:55 +02:00
AddHP 2 2
else
logtext "Result: clamscan couldn't be found"
fi
fi
#
#################################################################################
#
# Test : MALW-3284
# Description : Check running clamd process
Register --test-no MALW-3284 --weight L --network NO --description "Check for clamd"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking running ClamAV daemon (clamd)"
2014-09-19 01:10:43 +02:00
IsRunning clamd
if [ ${RUNNING} -eq 1 ]; then
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking ClamAV daemon" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
logtext "Result: found running clamd process"
MALWARE_SCANNER_INSTALLED=1
CLAMD_RUNNING=1
else
logtext "Result: clamd not running"
fi
fi
#
#################################################################################
#
# Test : MALW-3286
# Description : Check running freshclam if clamd process is running
if [ ${CLAMD_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no MALW-3286 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check for freshclam"
if [ ${SKIPTEST} -eq 0 ]; then
logtext "Test: checking running freshclam daemon"
2014-09-19 01:10:43 +02:00
IsRunning freshclam
if [ ${RUNNING} -eq 1 ]; then
FRESHCLAM_DAEMON_RUNNING=1
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking freshclam" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
logtext "Result: found running freshclam process"
AddHP 2 2
else
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking freshclam" --result "SUGGESTION" --color YELLOW
2014-08-26 17:33:55 +02:00
logtext "Result: freshclam is not running"
ReportSuggestion ${TEST_NO} "Confirm that freshclam is properly configured and keeps updating the ClamAV database"
fi
fi
#
#################################################################################
#
2015-07-22 16:28:11 +02:00
# Test : MALW-3288
# Description : Check for ClamXav (Mac OS X)
if [ -d /Applications/ClamXav.app/Contents/Resources/ScanningEngine/bin/ ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no MALW-3288 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check for ClamXav"
2014-09-25 19:08:47 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
2015-07-22 16:28:11 +02:00
CLAMSCANBINARY=`ls /Applications/ClamXav.app/Contents/Resources/ScanningEngine/bin/ 2> /dev/null | grep 'clamscan'`
if [ ! "${CLAMSCANBINARY}" = "" ]; then
logtext "Result: Found ClamXav clamscan installed"
Display --indent 2 --text "- Checking presence of ClamXav AV scanner" --result "FOUND" --color GREEN
MALWARE_SCANNER_INSTALLED=1
CLAMSCAN_INSTALLED=1
2015-07-22 16:28:11 +02:00
AddHP 3 3
2014-09-25 19:08:47 +02:00
else
2015-07-22 16:28:11 +02:00
logtext "Result: ClamXav malware scanner not found"
AddHP 0 3
2014-09-25 19:08:47 +02:00
fi
fi
#
#################################################################################
#
# Check if we found any of the ClamAV components
if [ ${CLAMSCAN_INSTALLED} -eq 1 -o ${CLAMD_RUNNING} -eq 1 -o ${FRESHCLAM_DAEMON_RUNNING} -eq 1 ]; then
report "malware_scanner[]=clamav"
fi
#
#################################################################################
2014-08-26 17:33:55 +02:00
#
report "malware_scanner_installed=${MALWARE_SCANNER_INSTALLED}"
2015-03-25 15:55:46 +01:00
2014-08-26 17:33:55 +02:00
wait_for_keypress
#
#================================================================================
2015-03-25 15:55:46 +01:00
# Lynis - Copyright 2007-2015, Michael Boelen, CISOfy - https://cisofy.com