Adding batch mode to output just one line of text (no colors) in order to be parsed by computer tools

Adding DESCRIPTION field in tests and [INFO] DESCRIPTION in main
Update README with --batch mode info
Add --batch mode in hardening.sh

Change summary to make it oneliner when batch mode
AUDIT_SUMMARY PASSED_CHECKS:95 RUN_CHECKS:191 TOTAL_CHECKS_AVAIL:191 CONFORMITY_PERCENTAGE:49.74
This commit is contained in:
Charles Herlin 2017-10-31 17:44:15 +01:00
parent 8a7f9ddad5
commit 67df4da781
195 changed files with 283 additions and 28 deletions

View File

@ -85,6 +85,10 @@ specific root read-only files. You need to provide a sudoers file in /etc/sudoer
with NOPASWD option, since checks are executed with ``sudo -n`` option, that will with NOPASWD option, since checks are executed with ``sudo -n`` option, that will
not prompt for a password. not prompt for a password.
``--batch``: While performing system audit, this option sets LOGLEVEL to 'ok' and
captures all output to print only one line once the check is done, formatted like :
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
## Hacking ## Hacking
**Getting the source** **Getting the source**

View File

@ -23,6 +23,7 @@ AUDIT_ALL_ENABLE_PASSED=0
ALLOW_SERVICE_LIST=0 ALLOW_SERVICE_LIST=0
SET_HARDENING_LEVEL=0 SET_HARDENING_LEVEL=0
SUDO_MODE='' SUDO_MODE=''
BATCH_MODE=''
usage() { usage() {
cat << EOF cat << EOF
@ -91,6 +92,11 @@ OPTIONS:
the '-n' option instructs sudo not to prompt for a password. the '-n' option instructs sudo not to prompt for a password.
Finally note that '--sudo' mode only works for audit mode. Finally note that '--sudo' mode only works for audit mode.
--batch
While performing system audit, this option sets LOGLEVEL to 'ok' and
captures all output to print only one line once the check is done, formatted like :
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
EOF EOF
exit 0 exit 0
} }
@ -135,6 +141,10 @@ while [[ $# > 0 ]]; do
--sudo) --sudo)
SUDO_MODE='--sudo' SUDO_MODE='--sudo'
;; ;;
--batch)
BATCH_MODE='--batch'
LOGLEVEL=ok
;;
-h|--help) -h|--help)
usage usage
;; ;;
@ -160,6 +170,8 @@ fi
[ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh [ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh
[ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh [ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh
if [ $BATCH_MODE ]; then MACHINE_LOG_LEVEL=3; fi
# If --allow-service-list is specified, don't run anything, just list the supported services # If --allow-service-list is specified, don't run anything, just list the supported services
if [ "$ALLOW_SERVICE_LIST" = 1 ] ; then if [ "$ALLOW_SERVICE_LIST" = 1 ] ; then
declare -a HARDENING_EXCEPTIONS_LIST declare -a HARDENING_EXCEPTIONS_LIST
@ -206,16 +218,16 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
fi fi
info "Treating $SCRIPT" info "Treating $SCRIPT"
if [ $AUDIT = 1 ]; then if [ $AUDIT = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE" debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE $BATCH_MODE"
$SCRIPT --audit $SUDO_MODE $SCRIPT --audit $SUDO_MODE $BATCH_MODE
elif [ $AUDIT_ALL = 1 ]; then elif [ $AUDIT_ALL = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE" debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
$SCRIPT --audit-all $SUDO_MODE $SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
elif [ $AUDIT_ALL_ENABLE_PASSED = 1 ]; then elif [ $AUDIT_ALL_ENABLE_PASSED = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE" debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE" $BATCH_MODE
$SCRIPT --audit-all $SUDO_MODE $SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
elif [ $APPLY = 1 ]; then elif [ $APPLY = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT" debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT"
$SCRIPT $SCRIPT
@ -233,7 +245,7 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
sed -i -re 's/^status=.+/status=enabled/' $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg sed -i -re 's/^status=.+/status=enabled/' $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg
info "Status set to enabled in $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg" info "Status set to enabled in $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg"
fi fi
;; ;;
1) 1)
debug "$SCRIPT failed" debug "$SCRIPT failed"
FAILED_CHECKS=$((FAILED_CHECKS+1)) FAILED_CHECKS=$((FAILED_CHECKS+1))
@ -245,19 +257,32 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
esac esac
TOTAL_CHECKS=$((TOTAL_CHECKS+1)) TOTAL_CHECKS=$((TOTAL_CHECKS+1))
done done
TOTAL_TREATED_CHECKS=$((TOTAL_CHECKS-DISABLED_CHECKS)) TOTAL_TREATED_CHECKS=$((TOTAL_CHECKS-DISABLED_CHECKS))
printf "%40s\n" "################### SUMMARY ###################" if [ $BATCH_MODE ]; then
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS" BATCH_SUMMARY="AUDIT_SUMMARY "
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS" BATCH_SUMMARY+="PASSED_CHECKS:${PASSED_CHECKS:-0} "
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS" BATCH_SUMMARY+="RUN_CHECKS:${TOTAL_TREATED_CHECKS:-0} "
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS" BATCH_SUMMARY+="TOTAL_CHECKS_AVAIL:${TOTAL_CHECKS:-0}"
printf "%30s %.2f %%\n" "Enabled Checks Percentage :" "$( echo "($TOTAL_TREATED_CHECKS/$TOTAL_CHECKS) * 100" | bc -l)" if [ $TOTAL_TREATED_CHECKS != 0 ]; then
if [ $TOTAL_TREATED_CHECKS != 0 ]; then BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:$(printf "%.2f" $( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l))"
printf "%30s %.2f %%\n" "Conformity Percentage :" "$( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l)" else
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
fi
echo $BATCH_SUMMARY
else else
printf "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0 printf "%40s\n" "################### SUMMARY ###################"
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s %.2f %%\n" "Enabled Checks Percentage :" "$( echo "($TOTAL_TREATED_CHECKS/$TOTAL_CHECKS) * 100" | bc -l)"
if [ $TOTAL_TREATED_CHECKS != 0 ]; then
printf "%30s %.2f %%\n" "Conformity Percentage :" "$( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l)"
else
printf "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0
fi
fi fi

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Install updates, patches and additional secutiry software."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Set password expiration days."
PACKAGE='login' PACKAGE='login'
OPTIONS='PASS_MAX_DAYS=90' OPTIONS='PASS_MAX_DAYS=90'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Set password change minimum number of days."
PACKAGE='login' PACKAGE='login'
OPTIONS='PASS_MIN_DAYS=7' OPTIONS='PASS_MIN_DAYS=7'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Set password expiration warning days."
PACKAGE='login' PACKAGE='login'
OPTIONS='PASS_WARN_AGE=7' OPTIONS='PASS_WARN_AGE=7'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Disable system accounts, preventing them from interactive login."
SHELL='/bin/false' SHELL='/bin/false'
FILE='/etc/passwd' FILE='/etc/passwd'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Set default group for root account to 0."
USER='root' USER='root'
EXPECTED_GID='0' EXPECTED_GID='0'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Set default mask for users to 077."
USER='root' USER='root'
PATTERN='umask 077' PATTERN='umask 077'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Lock inactive user accounts."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Checking root ownership and 644 permissions on banner files : /etc/motd|issue|issue.net ."
PERMISSIONS='644' PERMISSIONS='644'
USER='root' USER='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Remove OS information from Login Warning Banners."
FILES='/etc/motd /etc/issue /etc/issue.net' FILES='/etc/motd /etc/issue /etc/issue.net'
PATTERN='(\\v|\\r|\\m|\\s)' PATTERN='(\\v|\\r|\\m|\\s)'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Set graphical warning banner."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Find SUID system executables."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Find SGID system executables."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/passwd to 644."
FILE='/etc/passwd' FILE='/etc/passwd'
PERMISSIONS='644' PERMISSIONS='644'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/shadow to 640."
FILE='/etc/shadow' FILE='/etc/shadow'
PERMISSIONS='640' PERMISSIONS='640'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/group to 644."
FILE='/etc/group' FILE='/etc/group'
PERMISSIONS='644' PERMISSIONS='644'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on /etc/passwd."
FILE='/etc/passwd' FILE='/etc/passwd'
USER='root' USER='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on etc/shadow."
FILE='/etc/shadow' FILE='/etc/shadow'
USER='root' USER='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on /etc/group."
FILE='/etc/group' FILE='/etc/group'
USER='root' USER='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Find world writable files."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Find un-owned files and directories."
USER='root' USER='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Find un-grouped files and directories."
GROUP='root' GROUP='root'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="No user's .rhosts file."
ERRORS=0 ERRORS=0
FILENAME=".rhosts" FILENAME=".rhosts"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="There is no group in /etc/passwd that is not in /etc/group."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Users are assigned valid home directories."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Check user home directory ownership."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="There is no duplicate UIDs."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="There is no duplicate GIDs."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="There is no duplicate usernames."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="There is no duplicate group names."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="There is no user .netrc files."
ERRORS=0 ERRORS=0
FILENAME='.netrc' FILENAME='.netrc'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="There is no user .forward files."
ERRORS=0 ERRORS=0
FILENAME='.forward' FILENAME='.forward'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Ensure password fields are not empty in /etc/shadow."
FILE='/etc/shadow' FILE='/etc/shadow'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="There is no user in shadow group (that can read /etc/shadow file)."
ERRORS=0 ERRORS=0
FILEGROUP='/etc/group' FILEGROUP='/etc/group'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/password file."
FILE='/etc/passwd' FILE='/etc/passwd'
RESULT='' RESULT=''

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/shadow file."
FILE='/etc/shadow' FILE='/etc/shadow'
RESULT='' RESULT=''

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/group file."
FILE='/etc/group' FILE='/etc/group'
RESULT='' RESULT=''

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Verify root is the only UID 0 account."
FILE='/etc/passwd' FILE='/etc/passwd'
RESULT='' RESULT=''

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure root path integrity."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Check permissions on user home directories."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Check user dot file permissions."
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Check user permissions on .netrc file."
PERMISSIONS="600" PERMISSIONS="600"
ERRORS=0 ERRORS=0

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/home partition with nodev option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/home" PARTITION="/home"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="nodev option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive # Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="noexec option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive # Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="nosuid option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive # Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/run/shm with nodev option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/run/shm" PARTITION="/run/shm"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/run/shm with nosuid option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/run/shm" PARTITION="/run/shm"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/run/shm with noexec option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/run/shm" PARTITION="/run/shm"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Set sticky bit on world writable directories to prevent users from deleting or renaming files that are not owned by them."
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of cramfs filesystems."
KERNEL_OPTION="CONFIG_CRAMFS" KERNEL_OPTION="CONFIG_CRAMFS"
MODULE_NAME="cramfs" MODULE_NAME="cramfs"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of freevxfs filesystems."
KERNEL_OPTION="CONFIG_VXFS_FS" KERNEL_OPTION="CONFIG_VXFS_FS"
MODULE_NAME="freevxfs" MODULE_NAME="freevxfs"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/tmp on a separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/tmp" PARTITION="/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of jffs2 filesystems."
KERNEL_OPTION="CONFIG_JFFS2_FS" KERNEL_OPTION="CONFIG_JFFS2_FS"
MODULE_NAME="jffs2" MODULE_NAME="jffs2"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of hfs filesystems."
KERNEL_OPTION="CONFIG_HFS_FS" KERNEL_OPTION="CONFIG_HFS_FS"
MODULE_FILE="hfs" MODULE_FILE="hfs"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of hfsplus filesystems."
KERNEL_OPTION="CONFIG_HFSPLUS_FS" KERNEL_OPTION="CONFIG_HFSPLUS_FS"
MODULE_FILE="hfsplus" MODULE_FILE="hfsplus"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of squashfs filesytems."
KERNEL_OPTION="CONFIG_SQUASHFS" KERNEL_OPTION="CONFIG_SQUASHFS"
MODULE_FILE="squashfs" MODULE_FILE="squashfs"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of udf filesystems."
KERNEL_OPTION="CONFIG_UDF_FS" KERNEL_OPTION="CONFIG_UDF_FS"
MODULE_FILE="udf" MODULE_FILE="udf"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable automounting of devices."
SERVICE_NAME="autofs" SERVICE_NAME="autofs"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/tmp partition with nodev option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/tmp" PARTITION="/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/tmp partition with nosuid option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/tmp" PARTITION="/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/tmp partition with noexec option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/tmp" PARTITION="/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/var on a separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var" PARTITION="/var"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/var/tmp on a separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/tmp" PARTITION="/var/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/var/tmp partition with nodev option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/tmp" PARTITION="/var/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="/var/tmp partition with nosuid option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/tmp" PARTITION="/var/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/var/tmp partition with noexec option."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/tmp" PARTITION="/var/tmp"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/var/log on separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/log" PARTITION="/var/log"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=4 HARDENING_LEVEL=4
DESCRIPTION="/var/log/audit on a separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/var/log/audit" PARTITION="/var/log/audit"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="/home on a separate partition."
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/home" PARTITION="/home"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="User and group root owner of grub bootloader config."
# Assertion : Grub Based. # Assertion : Grub Based.

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=1 HARDENING_LEVEL=1
DESCRIPTION="Permissions for root only on grub bootloader config."
# Assertion : Grub Based. # Assertion : Grub Based.

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Setting bootloader password to secure boot parameters."
FILE='/boot/grub/grub.cfg' FILE='/boot/grub/grub.cfg'
USER_PATTERN="^set superusers" USER_PATTERN="^set superusers"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Root password for single user mode."
FILE="/etc/shadow" FILE="/etc/shadow"
PATTERN="^root:[*\!]:" PATTERN="^root:[*\!]:"

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Restrict core dumps."
LIMIT_FILE='/etc/security/limits.conf' LIMIT_FILE='/etc/security/limits.conf'
LIMIT_DIR='/etc/security/limits.d' LIMIT_DIR='/etc/security/limits.d'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Enable NoExecute/ExecuteDisable to prevent buffer overflow attacks."
PATTERN='NX[[:space:]]\(Execute[[:space:]]Disable\)[[:space:]]protection:[[:space:]]active' PATTERN='NX[[:space:]]\(Execute[[:space:]]Disable\)[[:space:]]protection:[[:space:]]active'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Enable Randomized Virtual Memory Region Placement to prevent memory page exploits."
SYSCTL_PARAM='kernel.randomize_va_space' SYSCTL_PARAM='kernel.randomize_va_space'
SYSCTL_EXP_RESULT=2 SYSCTL_EXP_RESULT=2

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Disable prelink to prevent libraries compromission."
PACKAGE='prelink' PACKAGE='prelink'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Activate AppArmor to enforce permissions control."
PACKAGE='apparmor' PACKAGE='apparmor'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
PACKAGE='nis' PACKAGE='nis'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure rsh server is not enabled. Recommended alternative : sshd (openssh-server)."
# Based on aptitude search '~Prsh-server' # Based on aptitude search '~Prsh-server'
PACKAGES='rsh-server rsh-redone-server heimdal-servers' PACKAGES='rsh-server rsh-redone-server heimdal-servers'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure rsh client is not installed, Recommended alternative : ssh."
# Based on aptitude search '~Prsh-client', exluding ssh-client OFC # Based on aptitude search '~Prsh-client', exluding ssh-client OFC
PACKAGES='rsh-client rsh-redone-client heimdal-clients' PACKAGES='rsh-client rsh-redone-client heimdal-clients'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure talk server is not enabled."
PACKAGES='inetutils-talkd talkd' PACKAGES='inetutils-talkd talkd'
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure talk client is not installed."
PACKAGES='talk inetutils-talk' PACKAGES='talk inetutils-talk'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure telnet server is not enabled. Recommended alternative : sshd (OpenSSH-server)."
# Based on aptitude search '~Ptelnet-server' # Based on aptitude search '~Ptelnet-server'
PACKAGES='telnetd inetutils-telnetd telnetd-ssl krb5-telnetd heimdal-servers' PACKAGES='telnetd inetutils-telnetd telnetd-ssl krb5-telnetd heimdal-servers'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure tftp-server is not enabled."
PACKAGES='tftpd tftpd-hpa atftpd' PACKAGES='tftpd tftpd-hpa atftpd'
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure xinetd is not enabled."
PACKAGES='openbsd-inetd xinetd rlinetd' PACKAGES='openbsd-inetd xinetd rlinetd'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure chargen debugging network service is not enabled."
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'
PATTERN='^chargen' PATTERN='^chargen'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure daytime debugging network service is not enabled."
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'
PATTERN='^daytime' PATTERN='^daytime'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure echo debugging network service is not enabled."
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'
PATTERN='^echo' PATTERN='^echo'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure discard debugging network service is not enabled."
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'
PATTERN='^discard' PATTERN='^discard'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=2 HARDENING_LEVEL=2
DESCRIPTION="Ensure time debugging network service is not enabled."
FILE='/etc/inetd.conf' FILE='/etc/inetd.conf'
PATTERN='^time' PATTERN='^time'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure HTTP server is not enabled."
HARDENING_EXCEPTION=http HARDENING_EXCEPTION=http
# Based on aptitude search '~Phttpd' # Based on aptitude search '~Phttpd'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure IMAP and POP servers are not enabled."
HARDENING_EXCEPTION=mail HARDENING_EXCEPTION=mail
# Based on aptitude search '~Pimap-server' and aptitude search '~Ppop3-server' # Based on aptitude search '~Pimap-server' and aptitude search '~Ppop3-server'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure Samba is not enabled."
HARDENING_EXCEPTION=samba HARDENING_EXCEPTION=samba
PACKAGES='samba' PACKAGES='samba'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Ensure HTTP-proxy is not enabled."
HARDENING_EXCEPTION=http HARDENING_EXCEPTION=http
PACKAGES='squid3 squid' PACKAGES='squid3 squid'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Enure SNMP server is not enabled."
HARDENING_EXCEPTION=snmp HARDENING_EXCEPTION=snmp
PACKAGES='snmpd' PACKAGES='snmpd'

View File

@ -12,6 +12,7 @@ set -e # One error, it's over
set -u # One variable unset, it's over set -u # One variable unset, it's over
HARDENING_LEVEL=3 HARDENING_LEVEL=3
DESCRIPTION="Configure Mail Transfert Agent for Local-Only Mode."
HARDENING_EXCEPTION=mail HARDENING_EXCEPTION=mail
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode

Some files were not shown because too many files have changed in this diff Show More