/
usr
/
share
/
lynis
/
include
/
/usr/share/lynis/include
mkdir
upload
Name
Size
Mode
Actions
binaries
39476
0644
edit
dl
rm
consts
10898
0644
edit
dl
rm
data_upload
13788
0644
edit
dl
rm
functions
163241
0644
edit
dl
rm
helper_audit_dockerfile
8000
0644
edit
dl
rm
helper_configure
3748
0644
edit
dl
rm
helper_generate
7557
0644
edit
dl
rm
helper_show
22820
0644
edit
dl
rm
helper_system_remote_scan
3620
0644
edit
dl
rm
helper_update
3671
0644
edit
dl
rm
osdetection
48570
0644
edit
dl
rm
parameters
16874
0644
edit
dl
rm
profiles
27540
0644
edit
dl
rm
report
18915
0644
edit
dl
rm
tests_accounting
25852
0644
edit
dl
rm
tests_authentication
86063
0644
edit
dl
rm
tests_banners
8562
0644
edit
dl
rm
tests_boot_services
56034
0644
edit
dl
rm
tests_containers
11439
0644
edit
dl
rm
tests_crypto
19456
0644
edit
dl
rm
tests_custom.template
6942
0644
edit
dl
rm
tests_databases
24863
0644
edit
dl
rm
tests_dns
3467
0644
edit
dl
rm
tests_filesystems
50995
0644
edit
dl
rm
tests_file_integrity
22714
0644
edit
dl
rm
tests_file_permissions
3185
0644
edit
dl
rm
tests_firewalls
32270
0644
edit
dl
rm
tests_hardening
7187
0644
edit
dl
rm
tests_homedirs
9392
0644
edit
dl
rm
tests_insecure_services
27528
0644
edit
dl
rm
tests_kerberos
8063
0644
edit
dl
rm
tests_kernel
61403
0644
edit
dl
rm
tests_kernel_hardening
5752
0644
edit
dl
rm
tests_ldap
4055
0644
edit
dl
rm
tests_logging
33726
0644
edit
dl
rm
tests_mac_frameworks
15067
0644
edit
dl
rm
tests_mail_messaging
21967
0644
edit
dl
rm
tests_malware
21101
0644
edit
dl
rm
tests_memory_processes
7334
0644
edit
dl
rm
tests_nameservices
35361
0644
edit
dl
rm
tests_networking
41705
0644
edit
dl
rm
tests_php
29772
0644
edit
dl
rm
tests_ports_packages
83692
0644
edit
dl
rm
tests_printers_spoolers
14188
0644
edit
dl
rm
tests_scheduling
16131
0644
edit
dl
rm
tests_shells
13643
0644
edit
dl
rm
tests_snmp
4273
0644
edit
dl
rm
tests_squid
17156
0644
edit
dl
rm
tests_ssh
18026
0644
edit
dl
rm
tests_storage
3680
0644
edit
dl
rm
tests_storage_nfs
8603
0644
edit
dl
rm
tests_system_integrity
2098
0644
edit
dl
rm
tests_time
33413
0644
edit
dl
rm
tests_tooling
22624
0644
edit
dl
rm
tests_usb
21554
0644
edit
dl
rm
tests_virtualization
1992
0644
edit
dl
rm
tests_webservers
33977
0644
edit
dl
rm
tool_tips
2205
0644
edit
dl
rm
Edit:
/usr/share/lynis/include/tests_homedirs
(9392B)
#!/bin/sh ################################################################################# # # Lynis # ------------------ # # Copyright (c) Michael Boelen, CISOfy, and many contributors. # # Website : https://cisofy.com # Blog : https://linux-audit.com/ # GitHub : https://github.com/CISOfy/lynis # # 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. # ################################################################################# # # Home directories # ################################################################################# # InsertSection "${SECTION_HOME_DIRECTORIES}" # ################################################################################# # # Ignore some top level directories (not the sub directories below) IGNORE_HOME_DIRS="/bin /boot /cdrom /dev /etc /home /lib /lib64 /media /mnt /opt /proc /sbin /selinux /srv /sys /tmp /usr /var" # ################################################################################# # # Test : HOME-9302 # Description : Create list with home directories Register --test-no HOME-9302 --weight L --network NO --category security --description "Create list with home directories" if [ ${SKIPTEST} -eq 0 ]; then # Read sixth field of /etc/passwd LogText "Test: query ${ROOTDIR}etc/passwd to obtain home directories" FIND=$(${AWKBINARY} -F: '{ if ($1 !~ "#") print $6 }' ${ROOTDIR}etc/passwd | ${SORTBINARY} -u) for I in ${FIND}; do if [ -d ${I} ]; then LogText "Result: found home directory: ${I} (directory exists)" Report "home_directory[]=${I}" else LogText "Result: found home directory: ${I} (directory does not exist)" fi done fi # ################################################################################# # # Test : HOME-9304 # Description : Check if users' home directories permissions are 750 or more restrictive Register --test-no HOME-9304 --weight L --network NO --category security --description "Check if users' home directories permissions are 750 or more restrictive" if [ ${SKIPTEST} -eq 0 ]; then # Check if users' home directories permissions are 750 or more restrictive FOUND=0 USERDATA=$(${GREPBINARY} -E -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print }') while read -r LINE; do USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1) DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f6) LogText "Test: checking directory '${DIR}' for user '${USER}'" if [ -d "${DIR}" ]; then WRITE_GROUP_PERM=$(${LSBINARY} -ld ${DIR} | ${CUTBINARY} -f1 -d" " | ${CUTBINARY} -c6) OTHER_PERMS=$(${LSBINARY} -ld ${DIR} | ${CUTBINARY} -f1 -d" " | ${CUTBINARY} -c8-10) if [ ! ${WRITE_GROUP_PERM} = "-" -o ! ${OTHER_PERMS} = "---" ]; then LogText "Result: permissions of home directory ${DIR} of user ${USER} are not strict enough. Should be 750 or more restrictive. Change with: chmod 750 ${DIR}" FOUND=1 else LogText "Result: permissions of home directory ${DIR} of user ${USER} are fine" fi fi done << EOF ${USERDATA} EOF if [ ${FOUND} -eq 1 ]; then Display --indent 2 --text "- Permissions of home directories" --result "${STATUS_WARNING}" --color RED ReportSuggestion "${TEST_NO}" "Double check the permissions of home directories as some might be not strict enough." else Display --indent 2 --text "- Permissions of home directories" --result "${STATUS_OK}" --color GREEN LogText "Result: OK, all permissions of the home directories are 750 or more restrictive" fi fi # ################################################################################# # # Test : HOME-9306 # Description : Check if users own their home directories Register --test-no HOME-9306 --weight L --network NO --category security --description "Check if users own their home directories" if [ ${SKIPTEST} -eq 0 ]; then # Check if users own their home directories FOUND=0 USERDATA=$(${GREPBINARY} -E -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print }') while read -r LINE; do USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1) DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f6) LogText "Test: checking directory '${DIR}' for user '${USER}'" if [ -d "${DIR}" ]; then OWNER=$(ls -ld ${DIR} | awk -F" " '{ print $3 }') if [ ! "${OWNER}" = "${USER}" ]; then LogText "Result: the home directory ${DIR} of user ${USER} is owned by ${OWNER}. Correct: chown ${USER} ${DIR}" FOUND=1 else LogText "Result: ownership of home directory ${DIR} for user ${USER} looks to be correct" fi fi done << EOF ${USERDATA} EOF if [ ${FOUND} -eq 1 ]; then Display --indent 2 --text "- Ownership of home directories" --result "${STATUS_WARNING}" --color RED ReportSuggestion "${TEST_NO}" "Double check the ownership of home directories as some might be incorrect." else Display --indent 2 --text "- Ownership of home directories" --result "${STATUS_OK}" --color GREEN LogText "Result: OK, all users own their home directories" fi fi # ################################################################################# # # Test : HOME-9310 # Description : Check for suspicious shell history files Register --test-no HOME-9310 --weight L --network NO --category security --description "Checking for suspicious shell history files" if [ ${SKIPTEST} -eq 0 ]; then if [ -n "${HOMEDIRS}" ]; then if [ "${OS}" = "Solaris" ]; then # Solaris doesn't support -maxdepth FIND=$(${FINDBINARY} ${HOMEDIRS} -name ".*history" ! -type f -print) else FIND=$(${FINDBINARY} ${HOMEDIRS} -maxdepth 1 -name ".*history" ! -type f -print) fi if [ -z "${FIND}" ]; then Display --indent 2 --text "- Checking shell history files" --result "${STATUS_OK}" --color GREEN LogText "Result: Ok, history files are type 'file'." else Display --indent 2 --text "- Checking shell history files" --result "${STATUS_WARNING}" --color RED LogText "Result: the following files seem to be of the wrong file type:" LogText "Output: ${FIND}" LogText "Info: above files could be redirected files to avoid logging and should be investigated" ReportWarning "${TEST_NO}" "Incorrect file type found for shell history file" fi LogText "Remark: History files are normally of the type 'file'. Symbolic links and other types are suspicious." else Display --indent 2 --text "- Checking shell history files" --result "${STATUS_SKIPPED}" --color WHITE LogText "Result: Homedirs is empty, therefore test will be skipped" fi fi # ################################################################################# # # Test : HOME-9314 # Description : Check if non local paths are found in PATH, which can be a risk, but also bad for performance # (like searching on a filer, instead of local disk) #Register --test-no HOME-9314 --weight L --network NO --category security --description "Create list with home directories" # ################################################################################# # # Test : HOME-9350 # Description : Scan home directories for specific files, used in different tests later # Notes : For performance reasons we combine the scanning of different files, so inode caching is used # as much as possible for every find command # Profile opt : ignore-home-dir (multiple lines allowed), ignores home directory if [ -n "${REPORTFILE}" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi Register --test-no HOME-9350 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Collecting information from home directories" if [ ${SKIPTEST} -eq 0 ]; then IGNORE_HOME_DIRS=$(${GREPBINARY} "^ignore-home-dir=" ${REPORTFILE} | ${AWKBINARY} -F= '{ print $2 }') if [ -z "${IGNORE_HOME_DIRS}" ]; then LogText "Result: IGNORE_HOME_DIRS empty, no paths excluded" else LogText "Output: ${IGNORE_HOME_DIRS}" fi fi # ################################################################################# # WaitForKeyPress # #================================================================================ # Lynis - Security Auditing and System Hardening for Linux and UNIX - https://cisofy.com
Save
cmd:
run