2014-08-26 17:33:55 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
# Lynis
|
|
|
|
# ------------------
|
|
|
|
#
|
2015-12-21 21:17:15 +01:00
|
|
|
# Copyright 2007-2016, Michael Boelen (michael.boelen@cisofy.com)
|
2015-07-22 17:37:11 +02:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
InsertSection "Storage"
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
AUTOMOUNTER_DAEMON_RUNNING=0
|
|
|
|
NFS_DAEMON_RUNNING=0
|
|
|
|
AUTOMOUNTER_DAEMON_TOOL=""
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
# Test : STRG-1840
|
|
|
|
# Description : Check for disabled USB storage
|
|
|
|
Register --test-no STRG-1840 --os Linux --weight L --network NO --description "Check if USB storage is disabled"
|
|
|
|
if [ ${SKIPTEST} -eq 0 ]; then
|
|
|
|
FOUND=0
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Test: Checking USB storage driver in directory /etc/modprobe.d and configuration file /etc/modprobe.conf"
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ -d /etc/modprobe.d ]; then
|
2014-08-28 13:58:41 +02:00
|
|
|
FIND=`ls /etc/modprobe.d/* 2> /dev/null`
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ ! "${FIND}" = "" ]; then
|
2015-10-25 17:00:58 +01:00
|
|
|
FIND=`egrep -r "install usb[-_]storage /bin/(false|true)" /etc/modprobe.d/* | grep -v "#"`
|
|
|
|
FIND2=`egrep -r "^blacklist usb[-_]storage" /etc/modprobe.d/*`
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ ! "${FIND}" = "" -o ! "${FIND2}" = "" ]; then
|
|
|
|
FOUND=1
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: found usb-storage driver in disabled state (blacklisted)"
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: uncommon situation. Found /etc/modprobe.d directory, but no files in it."
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -f /etc/modprobe.conf ]; then
|
2015-10-25 17:00:58 +01:00
|
|
|
FIND=`egrep "install usb[-_]storage /bin/(false|true)" /etc/modprobe.conf | grep "usb-storage" | grep -v "#"`
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ ! "${FIND}" = "" ]; then
|
|
|
|
FOUND=1
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: found usb-storage driver in disabled state"
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ${FOUND} -eq 0 ]; then
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: usb-storage driver is not explicitly disabled"
|
2014-09-15 12:01:09 +02:00
|
|
|
Display --indent 2 --text "- Checking usb-storage driver (modprobe config)" --result "NOT DISABLED" --color WHITE
|
2014-08-26 17:33:55 +02:00
|
|
|
ReportSuggestion ${TEST_NO} "Disable drivers like USB storage when not used, to prevent unauthorized storage or data theft"
|
|
|
|
AddHP 2 3
|
|
|
|
else
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: usb-storage driver is disabled"
|
2014-09-15 12:01:09 +02:00
|
|
|
Display --indent 2 --text "- Checking usb-storage driver (modprobe config)" --result "DISABLED" --color GREEN
|
2014-08-26 17:33:55 +02:00
|
|
|
AddHP 3 3
|
|
|
|
fi
|
2015-12-01 01:18:46 +01:00
|
|
|
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Test: Checking USB devices authorization to connect to the system"
|
2015-12-01 01:18:46 +01:00
|
|
|
FOUND=0
|
|
|
|
USBDEVICESPATH="/sys/bus/usb/devices/usb"
|
|
|
|
for device in "${USBDEVICESPATH}"*; do
|
|
|
|
if [ -e "${device}/authorized" ] || [ -e "${device}/authorized_default" ]; then
|
|
|
|
if [ `cat "${device}/authorized_default"` -eq 1 ]; then
|
|
|
|
FOUND=1
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Test: ${device} is authorized by default"
|
2016-03-08 09:50:28 +01:00
|
|
|
report "usb_authorized_default_device[]=${device}"
|
2015-12-01 01:18:46 +01:00
|
|
|
elif [ `cat "${device}/authorized"` -eq 1 ]; then
|
|
|
|
FOUND=1
|
2016-03-08 09:50:28 +01:00
|
|
|
LogText "Test: ${device} is authorized currently"
|
|
|
|
report "usb_authorized_device[]=${device}"
|
2015-12-01 01:18:46 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${FOUND} -eq 1 ]; then
|
2016-03-08 09:50:28 +01:00
|
|
|
LogText "Result: Some USB devices are authorized by default (or temporary) to connect to the system"
|
2015-12-01 01:18:46 +01:00
|
|
|
Display --indent 2 --text "- Checking USB devices authorization" --result "ENABLED" --color RED
|
2016-03-08 09:50:28 +01:00
|
|
|
# To-Be-Added: create documentation and enable the suggestion
|
|
|
|
#ReportSuggestion ${TEST_NO} "Disable USB devices authorization, to prevent unauthorized storage or data theft"
|
2015-12-01 01:18:46 +01:00
|
|
|
AddHP 0 3
|
|
|
|
else
|
2016-03-08 09:50:28 +01:00
|
|
|
LogText "Result: None USB devices are authorized by default (or temporary) to connect to the system"
|
2015-12-01 01:18:46 +01:00
|
|
|
Display --indent 2 --text "- Checking USB devices authorization" --result "DISABLED" --color GREEN
|
|
|
|
AddHP 3 3
|
|
|
|
fi
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
# Test : STRG-1846
|
|
|
|
# Description : Check for disabled firewire storage
|
2015-05-17 23:00:28 +02:00
|
|
|
# Explanation : Best option is to use the install function, or else drivers can still be loaded manually
|
2014-08-26 17:33:55 +02:00
|
|
|
Register --test-no STRG-1846 --os Linux --weight L --network NO --description "Check if firewire storage is disabled"
|
|
|
|
if [ ${SKIPTEST} -eq 0 ]; then
|
|
|
|
FOUND=0
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Test: Checking firewire storage driver in directory /etc/modprobe.d and configuration file /etc/modprobe.conf"
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ -d /etc/modprobe.d ]; then
|
2014-08-28 13:58:41 +02:00
|
|
|
FIND=`ls /etc/modprobe.d/* 2> /dev/null`
|
|
|
|
if [ ! "${FIND}" = "" ]; then
|
2015-10-25 17:00:58 +01:00
|
|
|
FIND1=`egrep "blacklist (ohci1394|firewire[-_]ohci|firewire-core)" /etc/modprobe.d/* | grep -v "#"`
|
|
|
|
FIND2=`egrep "install (ohci1394|firewire[-_]ohci|firewire-core) /bin/(false|true)" /etc/modprobe.d/* | grep -v "#"`
|
2014-08-28 13:58:41 +02:00
|
|
|
if [ ! "${FIND1}" = "" -o ! "${FIND2}" = "" ]; then
|
|
|
|
FOUND=1
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: found firewire ohci driver in disabled state"
|
2014-08-28 13:58:41 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: skipping /etc/modprobe.d, directory found but no files in it"
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -f /etc/modprobe.conf ]; then
|
2015-10-25 17:00:58 +01:00
|
|
|
FIND1=`egrep -r "blacklist (ohci1394|firewire[-_]ohci|firewire-core)" /etc/modprobe.conf | grep -v "#"`
|
|
|
|
FIND2=`egrep -r "install (ohci1394|firewire[-_]ohci|firewire-core) /bin/(false|true)" /etc/modprobe.conf | grep -v "#"`
|
2014-08-26 17:33:55 +02:00
|
|
|
if [ ! "${FIND1}" = "" -o ! "${FIND2}" = "" ]; then
|
|
|
|
FOUND=1
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: found firewire ohci driver in disabled state"
|
2014-08-26 17:33:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${FOUND} -eq 0 ]; then
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: firewire ohci driver is not explicitly disabled"
|
2014-09-15 12:01:09 +02:00
|
|
|
Display --indent 2 --text "- Checking firewire ohci driver (modprobe config)" --result "NOT DISABLED" --color WHITE
|
2014-08-26 17:33:55 +02:00
|
|
|
ReportSuggestion ${TEST_NO} "Disable drivers like firewire storage when not used, to prevent unauthorized storage or data theft"
|
|
|
|
# after blacklisting modules, make sure to remove them from the initram filesystem: update-initramfs -u
|
|
|
|
AddHP 2 3
|
|
|
|
else
|
2015-12-21 21:17:15 +01:00
|
|
|
LogText "Result: firewire ohci driver is disabled"
|
2014-09-15 12:01:09 +02:00
|
|
|
Display --indent 2 --text "- Checking firewire ohci driver (modprobe config)" --result "DISABLED" --color GREEN
|
2014-08-26 17:33:55 +02:00
|
|
|
AddHP 3 3
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
#
|
|
|
|
|
|
|
|
wait_for_keypress
|
|
|
|
|
|
|
|
#
|
|
|
|
#================================================================================
|
2015-12-21 21:17:15 +01:00
|
|
|
# Lynis - Copyright 2007-2016, CISOfy, Michael Boelen - https://cisofy.com
|