mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 13:52:17 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
106fa5fc8a | |||
3a342b784a | |||
bc1aa65b91 | |||
dba1dae963 | |||
4add6ddc33 | |||
c17d04ecc2 | |||
cccc0881e9 | |||
9c3aa51982 | |||
b994ca11a7 | |||
f4e0aafacc |
1
.gitignore
vendored
1
.gitignore
vendored
@ -0,0 +1 @@
|
|||||||
|
tmp/shfmt
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of freevxfs filesystems."
|
DESCRIPTION="Disable mounting of freevxfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_VXFS_FS"
|
KERNEL_OPTION="CONFIG_VXFS_FS"
|
||||||
MODULE_NAME="freevxfs"
|
MODULE_NAME="freevxfs"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_NAME
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -30,8 +32,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -45,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of jffs2 filesystems."
|
DESCRIPTION="Disable mounting of jffs2 filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
||||||
MODULE_NAME="jffs2"
|
MODULE_NAME="jffs2"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_NAME
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -30,8 +32,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -45,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of hfs filesystems."
|
DESCRIPTION="Disable mounting of hfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFS_FS"
|
KERNEL_OPTION="CONFIG_HFS_FS"
|
||||||
MODULE_FILE="hfs"
|
MODULE_FILE="hfs"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_FILE
|
is_kernel_option_enabled "$KERNEL_OPTION" $MODULE_FILE
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -30,8 +32,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -45,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of hfsplus filesystems."
|
DESCRIPTION="Disable mounting of hfsplus filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
||||||
MODULE_FILE="hfsplus"
|
MODULE_FILE="hfsplus"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_FILE
|
is_kernel_option_enabled "$KERNEL_OPTION" $MODULE_FILE
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -30,8 +32,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -45,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of udf filesystems."
|
DESCRIPTION="Disable mounting of udf filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_UDF_FS"
|
KERNEL_OPTION="CONFIG_UDF_FS"
|
||||||
MODULE_FILE="udf"
|
MODULE_FILE="udf"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_FILE
|
is_kernel_option_enabled "$KERNEL_OPTION" $MODULE_FILE
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -30,8 +32,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -45,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of cramfs filesystems."
|
DESCRIPTION="Disable mounting of cramfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_CRAMFS"
|
KERNEL_OPTION="CONFIG_CRAMFS"
|
||||||
MODULE_NAME="cramfs"
|
MODULE_NAME="cramfs"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_NAME
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -31,8 +33,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -47,6 +49,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -56,8 +59,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,17 +12,18 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of squashfs filesytems."
|
DESCRIPTION="Disable mounting of squashfs filesytems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_SQUASHFS"
|
KERNEL_OPTION="CONFIG_SQUASHFS"
|
||||||
MODULE_FILE="squashfs"
|
MODULE_FILE="squashfs"
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION $MODULE_FILE
|
is_kernel_option_enabled "$KERNEL_OPTION" $MODULE_FILE
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$KERNEL_OPTION is disabled"
|
||||||
@ -31,8 +33,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled $KERNEL_OPTION
|
is_kernel_option_enabled "$KERNEL_OPTION"
|
||||||
if [ $FNRET = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
ok "$KERNEL_OPTION is disabled, nothing to do"
|
||||||
@ -47,6 +49,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -56,8 +59,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/tmp partition with noexec option."
|
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
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/log on separate partition."
|
DESCRIPTION="/var/log on separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -39,13 +42,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +60,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -66,8 +70,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/log/audit on a separate partition."
|
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
|
||||||
@ -39,13 +41,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +59,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -66,8 +69,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/home on a separate partition."
|
DESCRIPTION="/home on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -39,13 +42,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +60,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -66,8 +70,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/home partition with nodev option."
|
DESCRIPTION="/home partition with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -32,13 +32,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -51,18 +51,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -84,7 +85,7 @@ fi
|
|||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
# shellcheck source=/opt/debian-cis/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
|
@ -32,13 +32,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -51,18 +51,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -84,7 +85,7 @@ fi
|
|||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
# shellcheck source=/opt/debian-cis/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
|
@ -32,13 +32,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -51,18 +51,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -84,7 +85,7 @@ fi
|
|||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
# shellcheck source=/opt/debian-cis/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="nodev option for removable media partitions."
|
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
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
FNRET=0
|
FNRET=0
|
||||||
else
|
else
|
||||||
info "detected $PARTITION like"
|
info "detected $PARTITION like"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
@ -42,9 +45,9 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
fi
|
fi
|
||||||
@ -58,6 +61,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -67,8 +71,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="nosuid option for removable media partitions."
|
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
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
FNRET=0
|
FNRET=0
|
||||||
else
|
else
|
||||||
info "detected $PARTITION like"
|
info "detected $PARTITION like"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
@ -42,9 +45,9 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
fi
|
fi
|
||||||
@ -58,6 +61,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -67,8 +71,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="noexec option for removable media partitions."
|
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
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
FNRET=0
|
FNRET=0
|
||||||
else
|
else
|
||||||
info "detected $PARTITION like"
|
info "detected $PARTITION like"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
@ -42,9 +45,9 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
fi
|
fi
|
||||||
@ -58,6 +61,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -67,8 +71,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Set sticky bit on world writable directories to prevent users from deleting or renaming files that are not owned by them."
|
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
|
||||||
@ -46,6 +49,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -55,8 +59,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable automounting of devices."
|
DESCRIPTION="Disable automounting of devices."
|
||||||
|
|
||||||
SERVICE_NAME="autofs"
|
SERVICE_NAME="autofs"
|
||||||
@ -19,8 +22,8 @@ SERVICE_NAME="autofs"
|
|||||||
# 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() {
|
||||||
info "Checking if $SERVICE_NAME is enabled"
|
info "Checking if $SERVICE_NAME is enabled"
|
||||||
is_service_enabled $SERVICE_NAME
|
is_service_enabled "$SERVICE_NAME"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$SERVICE_NAME is enabled"
|
crit "$SERVICE_NAME is enabled"
|
||||||
else
|
else
|
||||||
ok "$SERVICE_NAME is disabled"
|
ok "$SERVICE_NAME is disabled"
|
||||||
@ -30,8 +33,8 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
info "Checking if $SERVICE_NAME is enabled"
|
info "Checking if $SERVICE_NAME is enabled"
|
||||||
is_service_enabled $SERVICE_NAME
|
is_service_enabled "$SERVICE_NAME"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
info "Disabling $SERVICE_NAME"
|
info "Disabling $SERVICE_NAME"
|
||||||
update-rc.d $SERVICE_NAME remove >/dev/null 2>&1
|
update-rc.d $SERVICE_NAME remove >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
@ -46,6 +49,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -55,8 +59,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure /tmp is configured (Scored)"
|
DESCRIPTION="Ensure /tmp is configured (Scored)"
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -39,13 +42,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +60,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -66,8 +70,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/tmp partition with nodev option."
|
DESCRIPTION="/tmp partition with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/tmp partition with nosuid option."
|
DESCRIPTION="/tmp partition with nosuid option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/tmp partition with noexec option."
|
DESCRIPTION="/tmp partition with noexec option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var on a separate partition."
|
DESCRIPTION="/var on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
@ -41,13 +44,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/tmp on a separate partition."
|
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
|
||||||
@ -41,13 +44,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
else
|
else
|
||||||
info "mounting $PARTITION"
|
info "mounting $PARTITION"
|
||||||
mount $PARTITION
|
mount "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/tmp partition with nodev option."
|
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
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="/var/tmp partition with nosuid option."
|
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
|
||||||
@ -28,13 +31,13 @@ audit () {
|
|||||||
FNRET=2
|
FNRET=2
|
||||||
else
|
else
|
||||||
ok "$PARTITION is a partition"
|
ok "$PARTITION is a partition"
|
||||||
has_mount_option $PARTITION $OPTION
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in fstab!"
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
else
|
else
|
||||||
ok "$PARTITION has $OPTION in fstab"
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
has_mounted_option $PARTITION $OPTION
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
warn "$PARTITION is not mounted with $OPTION at runtime"
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
@ -47,18 +50,18 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PARTITION is correctly set"
|
ok "$PARTITION is correctly set"
|
||||||
elif [ $FNRET = 2 ]; then
|
elif [ "$FNRET" = 2 ]; then
|
||||||
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
elif [ $FNRET = 1 ]; then
|
elif [ "$FNRET" = 1 ]; then
|
||||||
info "Adding $OPTION to fstab"
|
info "Adding $OPTION to fstab"
|
||||||
add_option_to_fstab $PARTITION $OPTION
|
add_option_to_fstab $PARTITION $OPTION
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ "$FNRET" = 3 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
remount_partition $PARTITION
|
remount_partition "$PARTITION"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="User and group root owner of grub bootloader config."
|
DESCRIPTION="User and group root owner of grub bootloader config."
|
||||||
|
|
||||||
# Assertion : Grub Based.
|
# Assertion : Grub Based.
|
||||||
@ -23,15 +26,15 @@ PERMISSIONS='400'
|
|||||||
|
|
||||||
# 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() {
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
@ -40,20 +43,20 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
info "fixing $FILE ownership to $USER:$GROUP"
|
info "fixing $FILE ownership to $USER:$GROUP"
|
||||||
chown $USER:$GROUP $FILE
|
chown $USER:$GROUP $FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,22 +64,22 @@ apply () {
|
|||||||
check_config() {
|
check_config() {
|
||||||
|
|
||||||
is_pkg_installed "grub-pc"
|
is_pkg_installed "grub-pc"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "Grub is not installed, not handling configuration"
|
warn "Grub is not installed, not handling configuration"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
does_user_exist $USER
|
does_user_exist $USER
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$USER does not exist"
|
crit "$USER does not exist"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
does_group_exist $GROUP
|
does_group_exist $GROUP
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$GROUP does not exist"
|
crit "$GROUP does not exist"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
@ -84,6 +87,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -93,8 +97,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Setting bootloader password to secure boot parameters."
|
DESCRIPTION="Setting bootloader password to secure boot parameters."
|
||||||
|
|
||||||
FILE='/boot/grub/grub.cfg'
|
FILE='/boot/grub/grub.cfg'
|
||||||
@ -21,13 +24,13 @@ PWD_PATTERN="^password_pbkdf2"
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_file $FILE "$USER_PATTERN"
|
does_pattern_exist_in_file $FILE "$USER_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$USER_PATTERN not present in $FILE"
|
crit "$USER_PATTERN not present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$USER_PATTERN is present in $FILE"
|
ok "$USER_PATTERN is present in $FILE"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $FILE "$PWD_PATTERN"
|
does_pattern_exist_in_file $FILE "$PWD_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PWD_PATTERN not present in $FILE"
|
crit "$PWD_PATTERN not present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PWD_PATTERN is present in $FILE"
|
ok "$PWD_PATTERN is present in $FILE"
|
||||||
@ -37,13 +40,13 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $FILE "$USER_PATTERN"
|
does_pattern_exist_in_file $FILE "$USER_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$USER_PATTERN not present in $FILE, please configure password for grub"
|
warn "$USER_PATTERN not present in $FILE, please configure password for grub"
|
||||||
else
|
else
|
||||||
ok "$USER_PATTERN is present in $FILE"
|
ok "$USER_PATTERN is present in $FILE"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $FILE "$PWD_PATTERN"
|
does_pattern_exist_in_file $FILE "$PWD_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$PWD_PATTERN not present in $FILE, please configure password for grub"
|
warn "$PWD_PATTERN not present in $FILE, please configure password for grub"
|
||||||
else
|
else
|
||||||
ok "$PWD_PATTERN is present in $FILE"
|
ok "$PWD_PATTERN is present in $FILE"
|
||||||
@ -54,11 +57,11 @@ apply () {
|
|||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
is_pkg_installed "grub-pc"
|
is_pkg_installed "grub-pc"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "grub-pc is not installed, not handling configuration"
|
warn "grub-pc is not installed, not handling configuration"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
@ -66,6 +69,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -75,8 +79,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Root password for single user mode."
|
DESCRIPTION="Root password for single user mode."
|
||||||
|
|
||||||
FILE="/etc/shadow"
|
FILE="/etc/shadow"
|
||||||
@ -20,7 +23,7 @@ PATTERN="^root:[*\!]:"
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_file $FILE $PATTERN
|
does_pattern_exist_in_file $FILE $PATTERN
|
||||||
if [ $FNRET != 1 ]; then
|
if [ "$FNRET" != 1 ]; then
|
||||||
crit "$PATTERN is present in $FILE"
|
crit "$PATTERN is present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $FILE $PATTERN
|
does_pattern_exist_in_file $FILE $PATTERN
|
||||||
if [ $FNRET != 1 ]; then
|
if [ "$FNRET" != 1 ]; then
|
||||||
warn "$PATTERN is present in $FILE, please put a root password"
|
warn "$PATTERN is present in $FILE, please put a root password"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Restrict core dumps."
|
DESCRIPTION="Restrict core dumps."
|
||||||
|
|
||||||
LIMIT_FILE='/etc/security/limits.conf'
|
LIMIT_FILE='/etc/security/limits.conf'
|
||||||
@ -32,7 +35,7 @@ audit () {
|
|||||||
debug "Files to search $LIMIT_FILE $LIMIT_FILES"
|
debug "Files to search $LIMIT_FILE $LIMIT_FILES"
|
||||||
for file in $LIMIT_FILE $LIMIT_FILES; do
|
for file in $LIMIT_FILE $LIMIT_FILES; do
|
||||||
does_pattern_exist_in_file $file $LIMIT_PATTERN
|
does_pattern_exist_in_file $file $LIMIT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
debug "$LIMIT_PATTERN not present in $file"
|
debug "$LIMIT_PATTERN not present in $file"
|
||||||
else
|
else
|
||||||
ok "$LIMIT_PATTERN present in $file"
|
ok "$LIMIT_PATTERN present in $file"
|
||||||
@ -44,9 +47,9 @@ audit () {
|
|||||||
crit "$LIMIT_PATTERN is not present in $LIMIT_FILE $LIMIT_FILES"
|
crit "$LIMIT_PATTERN is not present in $LIMIT_FILE $LIMIT_FILES"
|
||||||
fi
|
fi
|
||||||
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -56,17 +59,17 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $LIMIT_FILE $LIMIT_PATTERN
|
does_pattern_exist_in_file $LIMIT_FILE $LIMIT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$LIMIT_PATTERN not present in $LIMIT_FILE, adding at the end of $LIMIT_FILE"
|
warn "$LIMIT_PATTERN not present in $LIMIT_FILE, adding at the end of $LIMIT_FILE"
|
||||||
add_end_of_file $LIMIT_FILE "* hard core 0"
|
add_end_of_file $LIMIT_FILE "* hard core 0"
|
||||||
else
|
else
|
||||||
ok "$LIMIT_PATTERN present in $LIMIT_FILE"
|
ok "$LIMIT_PATTERN present in $LIMIT_FILE"
|
||||||
fi
|
fi
|
||||||
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -81,6 +84,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -90,8 +94,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enable NoExecute/ExecuteDisable to prevent buffer overflow attacks."
|
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'
|
||||||
@ -33,9 +36,9 @@ nx_supported_and_enabled() {
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_dmesg $PATTERN
|
does_pattern_exist_in_dmesg $PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
nx_supported_and_enabled
|
nx_supported_and_enabled
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in dmesg and NX seems unsupported or disabled"
|
crit "$PATTERN is not present in dmesg and NX seems unsupported or disabled"
|
||||||
else
|
else
|
||||||
ok "NX is supported and enabled"
|
ok "NX is supported and enabled"
|
||||||
@ -48,9 +51,9 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_dmesg $PATTERN
|
does_pattern_exist_in_dmesg $PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
nx_supported_and_enabled
|
nx_supported_and_enabled
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in dmesg and NX seems unsupported or disabled"
|
crit "$PATTERN is not present in dmesg and NX seems unsupported or disabled"
|
||||||
else
|
else
|
||||||
ok "NX is supported and enabled"
|
ok "NX is supported and enabled"
|
||||||
@ -67,6 +70,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -76,8 +80,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enable Randomized Virtual Memory Region Placement to prevent memory page exploits."
|
DESCRIPTION="Enable Randomized Virtual Memory Region Placement to prevent memory page exploits."
|
||||||
|
|
||||||
SYSCTL_PARAM='kernel.randomize_va_space'
|
SYSCTL_PARAM='kernel.randomize_va_space'
|
||||||
@ -19,10 +22,10 @@ SYSCTL_EXP_RESULT=2
|
|||||||
|
|
||||||
# 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() {
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -31,11 +34,11 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,15 +12,17 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable prelink to prevent libraries compromission."
|
DESCRIPTION="Disable prelink to prevent libraries compromission."
|
||||||
|
|
||||||
PACKAGE='prelink'
|
PACKAGE='prelink'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -29,11 +32,11 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
/usr/sbin/prelink -ua
|
/usr/sbin/prelink -ua
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -48,6 +51,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -57,8 +61,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,15 +12,17 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Activate AppArmor to enforce permissions control."
|
DESCRIPTION="Activate AppArmor to enforce permissions control."
|
||||||
|
|
||||||
PACKAGE='apparmor'
|
PACKAGE='apparmor'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is absent!"
|
crit "$PACKAGE is absent!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
@ -47,8 +50,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed, please install $PACKAGE and configure it"
|
crit "$PACKAGE is not installed, please install $PACKAGE and configure it"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
@ -84,6 +87,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -93,8 +97,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Remove OS information from motd"
|
DESCRIPTION="Remove OS information from motd"
|
||||||
|
|
||||||
FILE='/etc/motd'
|
FILE='/etc/motd'
|
||||||
@ -20,7 +23,7 @@ PATTERN='(\\v|\\r|\\m|\\s)'
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PATTERN is present in $FILE"
|
crit "$PATTERN is present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PATTERN is present in $FILE"
|
warn "$PATTERN is present in $FILE"
|
||||||
delete_line_in_file $FILE $PATTERN
|
delete_line_in_file $FILE $PATTERN
|
||||||
else
|
else
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Remove OS information from Login Warning Banners."
|
DESCRIPTION="Remove OS information from Login Warning Banners."
|
||||||
|
|
||||||
FILE='/etc/issue'
|
FILE='/etc/issue'
|
||||||
@ -20,7 +23,7 @@ PATTERN='(\\v|\\r|\\m|\\s)'
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PATTERN is present in $FILE"
|
crit "$PATTERN is present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PATTERN is present in $FILE"
|
warn "$PATTERN is present in $FILE"
|
||||||
delete_line_in_file $FILE $PATTERN
|
delete_line_in_file $FILE $PATTERN
|
||||||
else
|
else
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Remove OS information from remote Login Warning Banners."
|
DESCRIPTION="Remove OS information from remote Login Warning Banners."
|
||||||
|
|
||||||
FILE='/etc/issue.net'
|
FILE='/etc/issue.net'
|
||||||
@ -20,7 +23,7 @@ PATTERN='(\\v|\\r|\\m|\\s)'
|
|||||||
# 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() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PATTERN is present in $FILE"
|
crit "$PATTERN is present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PATTERN is present in $FILE"
|
warn "$PATTERN is present in $FILE"
|
||||||
delete_line_in_file $FILE $PATTERN
|
delete_line_in_file $FILE $PATTERN
|
||||||
else
|
else
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
||||||
|
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
@ -22,18 +25,18 @@ FILE='/etc/motd'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
@ -43,23 +46,23 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
info "$FILE does not exist"
|
info "$FILE does not exist"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
warn "fixing $FILE ownership to $USER:$GROUP"
|
warn "fixing $FILE ownership to $USER:$GROUP"
|
||||||
chown $USER:$GROUP $FILE
|
chown $USER:$GROUP $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
||||||
|
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
@ -22,18 +25,18 @@ FILE='/etc/issue'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
@ -43,23 +46,23 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
info "$FILE does not exist"
|
info "$FILE does not exist"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
warn "fixing $FILE ownership to $USER:$GROUP"
|
warn "fixing $FILE ownership to $USER:$GROUP"
|
||||||
chown $USER:$GROUP $FILE
|
chown $USER:$GROUP $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
DESCRIPTION="Checking root ownership and 644 permissions on banner files: /etc/motd|issue|issue.net ."
|
||||||
|
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
@ -22,18 +25,18 @@ FILE='/etc/issue.net'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
@ -43,23 +46,23 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
info "$FILE does not exist"
|
info "$FILE does not exist"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
warn "fixing $FILE ownership to $USER:$GROUP"
|
warn "fixing $FILE ownership to $USER:$GROUP"
|
||||||
chown $USER:$GROUP $FILE
|
chown $USER:$GROUP $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Set graphical warning banner."
|
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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -40,8 +44,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure updates, patches, and additional security software are installed (Not Scored)"
|
DESCRIPTION="Ensure updates, patches, and additional security software are installed (Not Scored)"
|
||||||
|
|
||||||
# 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
|
||||||
@ -47,6 +50,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -56,8 +60,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,15 +12,17 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure xinetd is not enabled."
|
DESCRIPTION="Ensure xinetd is not enabled."
|
||||||
|
|
||||||
PACKAGE='xinetd'
|
PACKAGE='xinetd'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -28,10 +31,10 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure bsd-inetd is not enabled."
|
DESCRIPTION="Ensure bsd-inetd is not enabled."
|
||||||
|
|
||||||
PACKAGES='openbsd-inetd inetutils-inetd'
|
PACKAGES='openbsd-inetd inetutils-inetd'
|
||||||
@ -19,8 +22,8 @@ PACKAGES='openbsd-inetd inetutils-inetd'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -31,10 +34,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure time synchronization is in use"
|
DESCRIPTION="Ensure time synchronization is in use"
|
||||||
|
|
||||||
PACKAGES="ntp chrony"
|
PACKAGES="ntp chrony"
|
||||||
@ -20,8 +23,8 @@ PACKAGES="ntp chrony"
|
|||||||
audit() {
|
audit() {
|
||||||
FOUND=false
|
FOUND=false
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "Time synchronization is available through $PACKAGE"
|
ok "Time synchronization is available through $PACKAGE"
|
||||||
FOUND=true
|
FOUND=true
|
||||||
fi
|
fi
|
||||||
@ -43,6 +46,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -52,5 +56,10 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/main.sh ] && . $CIS_ROOT_DIR/lib/main.sh
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
|
else
|
||||||
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Configure Network Time Protocol (ntp). Check restrict parameters and ntp daemon runs ad unprivileged user."
|
DESCRIPTION="Configure Network Time Protocol (ntp). Check restrict parameters and ntp daemon runs ad unprivileged user."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=ntp
|
HARDENING_EXCEPTION=ntp
|
||||||
|
|
||||||
PACKAGE='ntp'
|
PACKAGE='ntp'
|
||||||
@ -23,19 +27,19 @@ NTP_INIT_FILE='/etc/init.d/ntp'
|
|||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
ok "$PACKAGE is installed, checking configuration"
|
||||||
does_pattern_exist_in_file $NTP_CONF_FILE $NTP_CONF_DEFAULT_PATTERN
|
does_pattern_exist_in_file $NTP_CONF_FILE $NTP_CONF_DEFAULT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE"
|
crit "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE"
|
||||||
else
|
else
|
||||||
ok "$NTP_CONF_DEFAULT_PATTERN found in $NTP_CONF_FILE"
|
ok "$NTP_CONF_DEFAULT_PATTERN found in $NTP_CONF_FILE"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $NTP_INIT_FILE "^$NTP_INIT_PATTERN"
|
does_pattern_exist_in_file $NTP_INIT_FILE "^$NTP_INIT_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$NTP_INIT_PATTERN not found in $NTP_INIT_FILE"
|
crit "$NTP_INIT_PATTERN not found in $NTP_INIT_FILE"
|
||||||
else
|
else
|
||||||
ok "$NTP_INIT_PATTERN found in $NTP_INIT_FILE"
|
ok "$NTP_INIT_PATTERN found in $NTP_INIT_FILE"
|
||||||
@ -45,8 +49,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
crit "$PACKAGE is absent, installing it"
|
crit "$PACKAGE is absent, installing it"
|
||||||
@ -54,7 +58,7 @@ apply () {
|
|||||||
info "Checking $PACKAGE configuration"
|
info "Checking $PACKAGE configuration"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $NTP_CONF_FILE $NTP_CONF_DEFAULT_PATTERN
|
does_pattern_exist_in_file $NTP_CONF_FILE $NTP_CONF_DEFAULT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE, adding it"
|
warn "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE, adding it"
|
||||||
backup_file $NTP_CONF_FILE
|
backup_file $NTP_CONF_FILE
|
||||||
add_end_of_file $NTP_CONF_FILE "restrict -4 default kod notrap nomodify nopeer noquery"
|
add_end_of_file $NTP_CONF_FILE "restrict -4 default kod notrap nomodify nopeer noquery"
|
||||||
@ -62,7 +66,7 @@ apply () {
|
|||||||
ok "$NTP_CONF_DEFAULT_PATTERN found in $NTP_CONF_FILE"
|
ok "$NTP_CONF_DEFAULT_PATTERN found in $NTP_CONF_FILE"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $NTP_INIT_FILE "^$NTP_INIT_PATTERN"
|
does_pattern_exist_in_file $NTP_INIT_FILE "^$NTP_INIT_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$NTP_INIT_PATTERN not found in $NTP_INIT_FILE, adding it"
|
warn "$NTP_INIT_PATTERN not found in $NTP_INIT_FILE, adding it"
|
||||||
backup_file $NTP_INIT_FILE
|
backup_file $NTP_INIT_FILE
|
||||||
add_line_file_before_pattern $NTP_INIT_FILE $NTP_INIT_PATTERN "^UGID"
|
add_line_file_before_pattern $NTP_INIT_FILE $NTP_INIT_PATTERN "^UGID"
|
||||||
@ -78,6 +82,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -87,8 +92,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Configure Network Time Protocol (ntp). Check restrict parameters and ntp daemon runs ad unprivileged user."
|
DESCRIPTION="Configure Network Time Protocol (ntp). Check restrict parameters and ntp daemon runs ad unprivileged user."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=ntp
|
HARDENING_EXCEPTION=ntp
|
||||||
|
|
||||||
PACKAGE=chrony
|
PACKAGE=chrony
|
||||||
@ -21,13 +25,13 @@ CONF_FILE='/etc/chrony/chrony.conf'
|
|||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
ok "$PACKAGE is installed, checking configuration"
|
||||||
does_pattern_exist_in_file $CONF_FILE $CONF_DEFAULT_PATTERN
|
does_pattern_exist_in_file $CONF_FILE $CONF_DEFAULT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$CONF_DEFAULT_PATTERN not found in $CONF_FILE"
|
crit "$CONF_DEFAULT_PATTERN not found in $CONF_FILE"
|
||||||
else
|
else
|
||||||
ok "$CONF_DEFAULT_PATTERN found in $CONF_FILE"
|
ok "$CONF_DEFAULT_PATTERN found in $CONF_FILE"
|
||||||
@ -47,6 +51,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -56,8 +61,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure HTTP server is not enabled."
|
DESCRIPTION="Ensure HTTP server is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=http
|
HARDENING_EXCEPTION=http
|
||||||
|
|
||||||
# Based on aptitude search '~Phttpd'
|
# Based on aptitude search '~Phttpd'
|
||||||
@ -21,8 +25,8 @@ PACKAGES='nginx apache2 lighttpd micro-httpd mini-httpd yaws boa bozohttpd'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -33,10 +37,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -51,6 +55,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -60,8 +65,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure IMAP and POP servers are not installed"
|
DESCRIPTION="Ensure IMAP and POP servers are not installed"
|
||||||
|
# shellcheck disable=2034
|
||||||
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'
|
||||||
@ -21,8 +25,8 @@ PACKAGES='citadel-server courier-imap cyrus-imapd-2.4 dovecot-imapd mailutils-im
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -33,10 +37,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -51,6 +55,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -60,8 +65,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure Samba is not enabled."
|
DESCRIPTION="Ensure Samba is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=samba
|
HARDENING_EXCEPTION=samba
|
||||||
|
|
||||||
PACKAGES='samba'
|
PACKAGES='samba'
|
||||||
@ -21,15 +25,15 @@ SERVICE='smbd'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
is_service_enabled $SERVICE
|
is_service_enabled $SERVICE
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "Service $SERVICE is enabled!"
|
crit "Service $SERVICE is enabled!"
|
||||||
else
|
else
|
||||||
ok "Service $SERVICE is disabled"
|
ok "Service $SERVICE is disabled"
|
||||||
@ -39,17 +43,17 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
is_service_enabled $SERVICE
|
is_service_enabled $SERVICE
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "Service $SERVICE is enabled!"
|
crit "Service $SERVICE is enabled!"
|
||||||
systemctl disable $SERVICE
|
systemctl disable $SERVICE
|
||||||
else
|
else
|
||||||
@ -64,6 +68,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -73,8 +78,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure HTTP-proxy is not enabled."
|
DESCRIPTION="Ensure HTTP-proxy is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=http
|
HARDENING_EXCEPTION=http
|
||||||
|
|
||||||
PACKAGES='squid3 squid'
|
PACKAGES='squid3 squid'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='squid3 squid'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enure SNMP server is not enabled."
|
DESCRIPTION="Enure SNMP server is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=snmp
|
HARDENING_EXCEPTION=snmp
|
||||||
|
|
||||||
PACKAGES='snmpd'
|
PACKAGES='snmpd'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='snmpd'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Configure Mail Transfert Agent for Local-Only Mode."
|
DESCRIPTION="Configure Mail Transfert Agent for Local-Only Mode."
|
||||||
|
# shellcheck disable=2034
|
||||||
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
|
||||||
@ -59,6 +63,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +73,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure rsync service is not enabled."
|
DESCRIPTION="Ensure rsync service is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=rsync
|
HARDENING_EXCEPTION=rsync
|
||||||
|
|
||||||
PACKAGE='rsync'
|
PACKAGE='rsync'
|
||||||
@ -22,13 +26,13 @@ RSYNC_DEFAULT_PATTERN_TO_SEARCH='RSYNC_ENABLE=true'
|
|||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$PACKAGE is not installed"
|
ok "$PACKAGE is not installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
ok "$PACKAGE is installed, checking configuration"
|
||||||
does_pattern_exist_in_file $RSYNC_DEFAULT_FILE "^$RSYNC_DEFAULT_PATTERN"
|
does_pattern_exist_in_file $RSYNC_DEFAULT_FILE "^$RSYNC_DEFAULT_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$RSYNC_DEFAULT_PATTERN not found in $RSYNC_DEFAULT_FILE"
|
crit "$RSYNC_DEFAULT_PATTERN not found in $RSYNC_DEFAULT_FILE"
|
||||||
else
|
else
|
||||||
ok "$RSYNC_DEFAULT_PATTERN found in $RSYNC_DEFAULT_FILE"
|
ok "$RSYNC_DEFAULT_PATTERN found in $RSYNC_DEFAULT_FILE"
|
||||||
@ -38,13 +42,13 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$PACKAGE is not installed"
|
ok "$PACKAGE is not installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
ok "$PACKAGE is installed, checking configuration"
|
||||||
does_pattern_exist_in_file $RSYNC_DEFAULT_FILE "^$RSYNC_DEFAULT_PATTERN"
|
does_pattern_exist_in_file $RSYNC_DEFAULT_FILE "^$RSYNC_DEFAULT_PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$RSYNC_DEFAULT_PATTERN not found in $RSYNC_DEFAULT_FILE, adding it"
|
warn "$RSYNC_DEFAULT_PATTERN not found in $RSYNC_DEFAULT_FILE, adding it"
|
||||||
backup_file $RSYNC_DEFAULT_FILE
|
backup_file $RSYNC_DEFAULT_FILE
|
||||||
replace_in_file $RSYNC_DEFAULT_FILE $RSYNC_DEFAULT_PATTERN_TO_SEARCH $RSYNC_DEFAULT_PATTERN
|
replace_in_file $RSYNC_DEFAULT_FILE $RSYNC_DEFAULT_PATTERN_TO_SEARCH $RSYNC_DEFAULT_PATTERN
|
||||||
@ -61,6 +65,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -70,8 +75,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# Legacy CIS Debian Hardening
|
# Legacy CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -13,7 +14,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure telnet server is not enabled. Recommended alternative : sshd (OpenSSH-server)."
|
DESCRIPTION="Ensure telnet server is not enabled. Recommended alternative : sshd (OpenSSH-server)."
|
||||||
|
|
||||||
# Based on aptitude search '~Ptelnet-server'
|
# Based on aptitude search '~Ptelnet-server'
|
||||||
@ -24,15 +27,15 @@ PATTERN='^telnet'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, checking configuration"
|
warn "$PACKAGE is installed, checking configuration"
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$FILE does not exist"
|
ok "$FILE does not exist"
|
||||||
else
|
else
|
||||||
does_pattern_exist_in_file $FILE $PATTERN
|
does_pattern_exist_in_file $FILE $PATTERN
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PATTERN exists, $PACKAGE services are enabled!"
|
crit "$PATTERN exists, $PACKAGE services are enabled!"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
@ -47,21 +50,21 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
fi
|
fi
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "$FILE does not exist"
|
ok "$FILE does not exist"
|
||||||
else
|
else
|
||||||
info "$FILE exists, checking patterns"
|
info "$FILE exists, checking patterns"
|
||||||
does_pattern_exist_in_file $FILE $PATTERN
|
does_pattern_exist_in_file $FILE $PATTERN
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PATTERN is present in $FILE, purging it"
|
warn "$PATTERN is present in $FILE, purging it"
|
||||||
backup_file $FILE
|
backup_file $FILE
|
||||||
ESCAPED_PATTERN=$(sed "s/|\|(\|)/\\\&/g" <<<$PATTERN)
|
ESCAPED_PATTERN=$(sed "s/|\|(\|)/\\\&/g" <<<$PATTERN)
|
||||||
@ -80,6 +83,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -89,8 +93,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure the X Window system is not installed."
|
DESCRIPTION="Ensure the X Window system is not installed."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=x11
|
HARDENING_EXCEPTION=x11
|
||||||
|
|
||||||
# Based on aptitude search '~Pxserver'
|
# Based on aptitude search '~Pxserver'
|
||||||
@ -21,8 +25,8 @@ PACKAGES='xserver-xorg-core xserver-xorg-core-dbg xserver-common xserver-xephyr
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -33,10 +37,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -51,6 +55,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -60,8 +65,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure Avahi server is not enabled."
|
DESCRIPTION="Ensure Avahi server is not enabled."
|
||||||
|
|
||||||
PACKAGES='avahi-daemon libavahi-common-data libavahi-common3 libavahi-core7'
|
PACKAGES='avahi-daemon libavahi-common-data libavahi-common3 libavahi-core7'
|
||||||
@ -19,8 +22,8 @@ PACKAGES='avahi-daemon libavahi-common-data libavahi-common3 libavahi-core7'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -31,10 +34,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure print server (Common Unix Print System) is not enabled."
|
DESCRIPTION="Ensure print server (Common Unix Print System) is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=cups
|
HARDENING_EXCEPTION=cups
|
||||||
|
|
||||||
PACKAGES='libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 cups-common cups-client cups-ppdc libcupsfilters1 cups-filters cups'
|
PACKAGES='libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 cups-common cups-client cups-ppdc libcupsfilters1 cups-filters cups'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 cups-comm
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure DHCP server is not enabled."
|
DESCRIPTION="Ensure DHCP server is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=dhcp
|
HARDENING_EXCEPTION=dhcp
|
||||||
|
|
||||||
PACKAGES='udhcpd isc-dhcp-server'
|
PACKAGES='udhcpd isc-dhcp-server'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='udhcpd isc-dhcp-server'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure LDAP is not enabled."
|
DESCRIPTION="Ensure LDAP is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=ldap
|
HARDENING_EXCEPTION=ldap
|
||||||
|
|
||||||
PACKAGES='slapd'
|
PACKAGES='slapd'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='slapd'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure Network File System (nfs) and RPC are not enabled."
|
DESCRIPTION="Ensure Network File System (nfs) and RPC are not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=nfs
|
HARDENING_EXCEPTION=nfs
|
||||||
|
|
||||||
PACKAGES='rpcbind nfs-kernel-server'
|
PACKAGES='rpcbind nfs-kernel-server'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='rpcbind nfs-kernel-server'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure Domain Name System (dns) server is not enabled."
|
DESCRIPTION="Ensure Domain Name System (dns) server is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=dns
|
HARDENING_EXCEPTION=dns
|
||||||
|
|
||||||
PACKAGES='bind9 unbound'
|
PACKAGES='bind9 unbound'
|
||||||
@ -20,8 +24,8 @@ PACKAGES='bind9 unbound'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +36,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +54,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +64,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,11 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure File Transfer Protocol (ftp) is not enabled."
|
DESCRIPTION="Ensure File Transfer Protocol (ftp) is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=ftp
|
HARDENING_EXCEPTION=ftp
|
||||||
|
|
||||||
# Based on aptitude search '~Pftp-server'
|
# Based on aptitude search '~Pftp-server'
|
||||||
@ -21,8 +25,8 @@ PACKAGES='ftpd ftpd-ssl heimdal-servers inetutils-ftpd krb5-ftpd muddleftpd prof
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -33,10 +37,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -51,6 +55,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -60,8 +65,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,15 +12,17 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
|
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
|
||||||
|
|
||||||
PACKAGE='nis'
|
PACKAGE='nis'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed!"
|
crit "$PACKAGE is installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -29,10 +32,10 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed, purging it"
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -46,6 +49,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -55,8 +59,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure rsh client is not installed, Recommended alternative : ssh."
|
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
|
||||||
@ -20,8 +23,8 @@ PACKAGES='rsh-client rsh-redone-client heimdal-clients'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -32,10 +35,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -50,6 +53,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -59,8 +63,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure talk client is not installed."
|
DESCRIPTION="Ensure talk client is not installed."
|
||||||
|
|
||||||
PACKAGES='talk inetutils-talk'
|
PACKAGES='talk inetutils-talk'
|
||||||
@ -19,8 +22,8 @@ PACKAGES='talk inetutils-talk'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -31,10 +34,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure telnet client is not installed."
|
DESCRIPTION="Ensure telnet client is not installed."
|
||||||
|
|
||||||
PACKAGES='telnet'
|
PACKAGES='telnet'
|
||||||
@ -19,8 +22,8 @@ PACKAGES='telnet'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -31,10 +34,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure ldap client is not installed."
|
DESCRIPTION="Ensure ldap client is not installed."
|
||||||
|
|
||||||
PACKAGES='ldap-utils'
|
PACKAGES='ldap-utils'
|
||||||
@ -19,8 +22,8 @@ PACKAGES='ldap-utils'
|
|||||||
# 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() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
crit "$PACKAGE is installed"
|
crit "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -31,10 +34,10 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
warn "$PACKAGE is installed, purging"
|
warn "$PACKAGE is installed, purging"
|
||||||
apt-get purge $PACKAGE -y
|
apt-get purge "$PACKAGE" -y
|
||||||
apt-get autoremove -y
|
apt-get autoremove -y
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is absent"
|
ok "$PACKAGE is absent"
|
||||||
@ -49,6 +52,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -58,8 +62,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,8 +12,10 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
HARDENING_EXCEPTION=gw
|
HARDENING_EXCEPTION=gw
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable IP forwarding."
|
DESCRIPTION="Disable IP forwarding."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.ip_forward net.ipv6.conf.all.forwarding'
|
SYSCTL_PARAMS='net.ipv4.ip_forward net.ipv6.conf.all.forwarding'
|
||||||
@ -22,11 +25,11 @@ SYSCTL_EXP_RESULT=0
|
|||||||
audit() {
|
audit() {
|
||||||
for SYSCTL_PARAM in $SYSCTL_PARAMS; do
|
for SYSCTL_PARAM in $SYSCTL_PARAMS; do
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET = 0 ] || [[ ! $SYSCTL_PARAM =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
if [ "$FNRET" = 0 ] || [[ ! $SYSCTL_PARAM =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -38,12 +41,12 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
for SYSCTL_PARAM in $SYSCTL_PARAMS; do
|
for SYSCTL_PARAM in $SYSCTL_PARAMS; do
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -58,6 +61,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -67,8 +71,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable send packet redirects to prevent malicious ICMP corruption."
|
DESCRIPTION="Disable send packet redirects to prevent malicious ICMP corruption."
|
||||||
|
|
||||||
#net.ipv4.conf.all.send_redirects = 0
|
#net.ipv4.conf.all.send_redirects = 0
|
||||||
@ -24,10 +27,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -41,12 +44,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -61,6 +64,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -70,8 +74,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable source routed packet acceptance."
|
DESCRIPTION="Disable source routed packet acceptance."
|
||||||
# set in config file
|
# set in config file
|
||||||
SYSCTL_PARAMS=''
|
SYSCTL_PARAMS=''
|
||||||
@ -20,14 +23,14 @@ SYSCTL_PARAMS=''
|
|||||||
audit() {
|
audit() {
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET = 0 ] || [[ ! $SYSCTL_VALUES =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
if [ "$FNRET" = 0 ] || [[ ! $SYSCTL_VALUES =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -42,12 +45,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT value -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT value -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -70,6 +73,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -79,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable ICMP redirect acceptance to prevent routing table corruption."
|
DESCRIPTION="Disable ICMP redirect acceptance to prevent routing table corruption."
|
||||||
# set in config file
|
# set in config file
|
||||||
SYSCTL_PARAMS=''
|
SYSCTL_PARAMS=''
|
||||||
@ -20,15 +23,15 @@ SYSCTL_PARAMS=''
|
|||||||
audit() {
|
audit() {
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET = 0 ] || [[ ! $SYSCTL_VALUES =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
if [ "$FNRET" = 0 ] || [[ ! $SYSCTL_VALUES =~ .*ipv6.* ]]; then # IPv6 is enabled or SYSCTL_VALUES doesn't contain ipv6
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
|
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -43,12 +46,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -71,6 +74,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -80,8 +84,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable secure ICMP redirect acceptance to prevent routing tables corruptions."
|
DESCRIPTION="Disable secure ICMP redirect acceptance to prevent routing tables corruptions."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.conf.all.secure_redirects=0 net.ipv4.conf.default.secure_redirects=0'
|
SYSCTL_PARAMS='net.ipv4.conf.all.secure_redirects=0 net.ipv4.conf.default.secure_redirects=0'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Log suspicious packets, like spoofed packets."
|
DESCRIPTION="Log suspicious packets, like spoofed packets."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.conf.all.log_martians=1 net.ipv4.conf.default.log_martians=1'
|
SYSCTL_PARAMS='net.ipv4.conf.all.log_martians=1 net.ipv4.conf.default.log_martians=1'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ignore broadcast requests to prevent attacks such as Smurf attack."
|
DESCRIPTION="Ignore broadcast requests to prevent attacks such as Smurf attack."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.icmp_echo_ignore_broadcasts=1'
|
SYSCTL_PARAMS='net.ipv4.icmp_echo_ignore_broadcasts=1'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist --Typo?"
|
warn "$SYSCTL_PARAM does not exist --Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enable bad error message protection to prevent logfiles fillup."
|
DESCRIPTION="Enable bad error message protection to prevent logfiles fillup."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.icmp_ignore_bogus_error_responses=1'
|
SYSCTL_PARAMS='net.ipv4.icmp_ignore_bogus_error_responses=1'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enable RFC-recommended source route validation."
|
DESCRIPTION="Enable RFC-recommended source route validation."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.conf.all.rp_filter=1 net.ipv4.conf.default.rp_filter=1'
|
SYSCTL_PARAMS='net.ipv4.conf.all.rp_filter=1 net.ipv4.conf.default.rp_filter=1'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Enable TCP-SYN cookie to prevent TCP-SYN flood attack."
|
DESCRIPTION="Enable TCP-SYN cookie to prevent TCP-SYN flood attack."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv4.tcp_syncookies=1'
|
SYSCTL_PARAMS='net.ipv4.tcp_syncookies=1'
|
||||||
@ -22,10 +25,10 @@ audit () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -39,12 +42,12 @@ apply () {
|
|||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable IPv6 router advertisements."
|
DESCRIPTION="Disable IPv6 router advertisements."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv6.conf.all.accept_ra=0 net.ipv6.conf.default.accept_ra=0'
|
SYSCTL_PARAMS='net.ipv6.conf.all.accept_ra=0 net.ipv6.conf.default.accept_ra=0'
|
||||||
@ -19,17 +22,17 @@ SYSCTL_PARAMS='net.ipv6.conf.all.accept_ra=0 net.ipv6.conf.default.accept_ra=0'
|
|||||||
# 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() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -41,19 +44,19 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT, fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT, fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
sysctl -w net.ipv4.route.flush=1 >/dev/null
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -69,6 +72,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -78,8 +82,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,15 +12,17 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Install TCP wrappers for simple access list management and standardized logging method for services."
|
DESCRIPTION="Install TCP wrappers for simple access list management and standardized logging method for services."
|
||||||
|
|
||||||
PACKAGE='tcpd'
|
PACKAGE='tcpd'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
@ -28,8 +31,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
crit "$PACKAGE is absent, installing it"
|
crit "$PACKAGE is absent, installing it"
|
||||||
@ -44,6 +47,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -53,8 +57,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Create /etc/hosts.allow ."
|
DESCRIPTION="Create /etc/hosts.allow ."
|
||||||
|
|
||||||
FILE='/etc/hosts.allow'
|
FILE='/etc/hosts.allow'
|
||||||
@ -19,7 +22,7 @@ FILE='/etc/hosts.allow'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
else
|
else
|
||||||
ok "$FILE exist"
|
ok "$FILE exist"
|
||||||
@ -29,7 +32,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$FILE does not exist, creating it"
|
warn "$FILE does not exist, creating it"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
warn "You may want to fill it with allowed networks"
|
warn "You may want to fill it with allowed networks"
|
||||||
@ -45,6 +48,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -54,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Create /etc/hosts.deny ."
|
DESCRIPTION="Create /etc/hosts.deny ."
|
||||||
|
|
||||||
FILE='/etc/hosts.deny'
|
FILE='/etc/hosts.deny'
|
||||||
@ -20,12 +23,12 @@ PATTERN='ALL: ALL'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
else
|
else
|
||||||
ok "$FILE exists, checking configuration"
|
ok "$FILE exists, checking configuration"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in $FILE, we have to deny everything"
|
crit "$PATTERN is not present in $FILE, we have to deny everything"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is present in $FILE"
|
ok "$PATTERN is present in $FILE"
|
||||||
@ -36,14 +39,14 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$FILE does not exist, creating it"
|
warn "$FILE does not exist, creating it"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
else
|
else
|
||||||
ok "$FILE exists"
|
ok "$FILE exists"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in $FILE, we have to deny everything"
|
crit "$PATTERN is not present in $FILE, we have to deny everything"
|
||||||
add_end_of_file $FILE "$PATTERN"
|
add_end_of_file $FILE "$PATTERN"
|
||||||
warn "YOU MAY HAVE CUT YOUR ACCESS, CHECK BEFORE DISCONNECTING"
|
warn "YOU MAY HAVE CUT YOUR ACCESS, CHECK BEFORE DISCONNECTING"
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Check 644 permissions and root:root ownership on /hosts.allow ."
|
DESCRIPTION="Check 644 permissions and root:root ownership on /hosts.allow ."
|
||||||
|
|
||||||
FILE='/etc/hosts.allow'
|
FILE='/etc/hosts.allow'
|
||||||
@ -21,14 +24,14 @@ GROUP='root'
|
|||||||
|
|
||||||
# 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() {
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
@ -37,12 +40,12 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +56,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -62,8 +66,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Check 644 permissions and root:root ownership on /etc/hosts.deny ."
|
DESCRIPTION="Check 644 permissions and root:root ownership on /etc/hosts.deny ."
|
||||||
|
|
||||||
FILE='/etc/hosts.deny'
|
FILE='/etc/hosts.deny'
|
||||||
@ -21,14 +24,14 @@ GROUP='root'
|
|||||||
|
|
||||||
# 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() {
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership "$FILE" "$USER" "$GROUP"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct ownership"
|
ok "$FILE has correct ownership"
|
||||||
else
|
else
|
||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
@ -37,12 +40,12 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
has_file_correct_permissions $FILE $PERMISSIONS
|
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
info "fixing $FILE permissions to $PERMISSIONS"
|
info "fixing $FILE permissions to $PERMISSIONS"
|
||||||
chmod 0$PERMISSIONS $FILE
|
chmod 0"$PERMISSIONS" "$FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +56,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -62,8 +66,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable Datagram Congestion Control Protocol (DCCP)."
|
DESCRIPTION="Disable Datagram Congestion Control Protocol (DCCP)."
|
||||||
|
|
||||||
# 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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -40,8 +44,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable Stream Control Transmission Protocol (SCTP)."
|
DESCRIPTION="Disable Stream Control Transmission Protocol (SCTP)."
|
||||||
|
|
||||||
# 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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -40,8 +44,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable Reliable Datagram Sockets (RDS)."
|
DESCRIPTION="Disable Reliable Datagram Sockets (RDS)."
|
||||||
|
|
||||||
# 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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -40,8 +44,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable Transperent Inter-Process Communication (TIPC)."
|
DESCRIPTION="Disable Transperent Inter-Process Communication (TIPC)."
|
||||||
|
|
||||||
# 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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -40,8 +44,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# run-shellcheck
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# OVH Security audit
|
# OVH Security audit
|
||||||
@ -22,7 +23,7 @@ FW_POLICY="DROP"
|
|||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
@ -60,6 +61,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -70,7 +72,7 @@ fi
|
|||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
# shellcheck source=/opt/debian-cis/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure firewall is active (iptables is installed, does not check for its configuration)."
|
DESCRIPTION="Ensure firewall is active (iptables is installed, does not check for its configuration)."
|
||||||
|
|
||||||
# Quick note here : CIS recommends your iptables rules to be persistent.
|
# Quick note here : CIS recommends your iptables rules to be persistent.
|
||||||
@ -21,8 +24,8 @@ PACKAGE='iptables'
|
|||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is not installed!"
|
crit "$PACKAGE is not installed!"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
@ -31,8 +34,8 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed $PACKAGE
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ $FNRET = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
else
|
else
|
||||||
crit "$PACKAGE is absent, installing it"
|
crit "$PACKAGE is absent, installing it"
|
||||||
@ -47,6 +50,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -56,8 +60,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Deactivate wireless interfaces."
|
DESCRIPTION="Deactivate wireless interfaces."
|
||||||
|
|
||||||
# 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
|
||||||
@ -31,6 +34,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -43,6 +47,7 @@ fi
|
|||||||
# echo "There is no /etc/default/cis-hardening file, cannot source CIS_ROOT_DIR variable, aborting"
|
# echo "There is no /etc/default/cis-hardening file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
# exit 128
|
# exit 128
|
||||||
#else
|
#else
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
# . /etc/default/cis-hardening
|
# . /etc/default/cis-hardening
|
||||||
# if [ -z ${CIS_ROOT_DIR:-} ]; then
|
# if [ -z ${CIS_ROOT_DIR:-} ]; then
|
||||||
# echo "No CIS_ROOT_DIR variable, aborting"
|
# echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
@ -51,8 +56,9 @@ fi
|
|||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable IPv6."
|
DESCRIPTION="Disable IPv6."
|
||||||
|
|
||||||
SYSCTL_PARAMS='net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1'
|
SYSCTL_PARAMS='net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1'
|
||||||
@ -19,17 +22,17 @@ SYSCTL_PARAMS='net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ip
|
|||||||
# 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() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -41,19 +44,19 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
does_sysctl_param_exists "net.ipv6"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
||||||
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
SYSCTL_PARAM=$(echo $SYSCTL_VALUES | cut -d= -f 1)
|
||||||
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
SYSCTL_EXP_RESULT=$(echo $SYSCTL_VALUES | cut -d= -f 2)
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
||||||
has_sysctl_param_expected_result $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT value, fixing"
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT value, fixing"
|
||||||
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
set_sysctl_param $SYSCTL_PARAM $SYSCTL_EXP_RESULT
|
||||||
warn "you may want to reboot or sysctl -p a file including $SYSCTL_PARAMS"
|
warn "you may want to reboot or sysctl -p a file including $SYSCTL_PARAMS"
|
||||||
elif [ $FNRET = 255 ]; then
|
elif [ "$FNRET" = 255 ]; then
|
||||||
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
else
|
else
|
||||||
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
@ -69,6 +72,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -78,8 +82,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Configure audit log storage size."
|
DESCRIPTION="Configure audit log storage size."
|
||||||
|
|
||||||
FILE='/etc/audit/auditd.conf'
|
FILE='/etc/audit/auditd.conf'
|
||||||
@ -21,12 +24,12 @@ VALUE=5
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
else
|
else
|
||||||
ok "$FILE exists, checking configuration"
|
ok "$FILE exists, checking configuration"
|
||||||
does_pattern_exist_in_file $FILE "^$PATTERN[[:space:]]"
|
does_pattern_exist_in_file $FILE "^$PATTERN[[:space:]]"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in $FILE"
|
crit "$PATTERN is not present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is present in $FILE"
|
ok "$PATTERN is present in $FILE"
|
||||||
@ -37,14 +40,14 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$FILE does not exist, creating it"
|
warn "$FILE does not exist, creating it"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
else
|
else
|
||||||
ok "$FILE exists"
|
ok "$FILE exists"
|
||||||
fi
|
fi
|
||||||
does_pattern_exist_in_file $FILE "^$PATTERN[[:space:]]"
|
does_pattern_exist_in_file $FILE "^$PATTERN[[:space:]]"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$PATTERN is not present in $FILE, adding it"
|
warn "$PATTERN is not present in $FILE, adding it"
|
||||||
add_end_of_file $FILE "$PATTERN = $VALUE"
|
add_end_of_file $FILE "$PATTERN = $VALUE"
|
||||||
else
|
else
|
||||||
@ -59,6 +62,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -68,8 +72,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable system on audit log full."
|
DESCRIPTION="Disable system on audit log full."
|
||||||
|
|
||||||
FILE='/etc/audit/auditd.conf'
|
FILE='/etc/audit/auditd.conf'
|
||||||
@ -20,7 +23,7 @@ OPTIONS=''
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
else
|
else
|
||||||
ok "$FILE exists, checking configuration"
|
ok "$FILE exists, checking configuration"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
||||||
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in $FILE"
|
crit "$PATTERN is not present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is present in $FILE"
|
ok "$PATTERN is present in $FILE"
|
||||||
@ -42,7 +45,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$FILE does not exist, creating it"
|
warn "$FILE does not exist, creating it"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
else
|
else
|
||||||
@ -54,10 +57,10 @@ apply () {
|
|||||||
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
||||||
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$PATTERN is not present in $FILE, adding it"
|
warn "$PATTERN is not present in $FILE, adding it"
|
||||||
does_pattern_exist_in_file $FILE "^$AUDIT_PARAM"
|
does_pattern_exist_in_file $FILE "^$AUDIT_PARAM"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
info "Parameter $AUDIT_PARAM seems absent from $FILE, adding at the end"
|
info "Parameter $AUDIT_PARAM seems absent from $FILE, adding at the end"
|
||||||
add_end_of_file $FILE "$AUDIT_PARAM = $AUDIT_VALUE"
|
add_end_of_file $FILE "$AUDIT_PARAM = $AUDIT_VALUE"
|
||||||
else
|
else
|
||||||
@ -86,6 +89,7 @@ EOF
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -95,8 +99,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Keep all auditing information."
|
DESCRIPTION="Keep all auditing information."
|
||||||
|
|
||||||
FILE='/etc/audit/auditd.conf'
|
FILE='/etc/audit/auditd.conf'
|
||||||
@ -20,7 +23,7 @@ OPTIONS='max_log_file_action=keep_logs'
|
|||||||
# 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() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
else
|
else
|
||||||
ok "$FILE exists, checking configuration"
|
ok "$FILE exists, checking configuration"
|
||||||
@ -30,7 +33,7 @@ audit () {
|
|||||||
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
||||||
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PATTERN is not present in $FILE"
|
crit "$PATTERN is not present in $FILE"
|
||||||
else
|
else
|
||||||
ok "$PATTERN is present in $FILE"
|
ok "$PATTERN is present in $FILE"
|
||||||
@ -42,7 +45,7 @@ audit () {
|
|||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_file_exist $FILE
|
does_file_exist $FILE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$FILE does not exist, creating it"
|
warn "$FILE does not exist, creating it"
|
||||||
touch $FILE
|
touch $FILE
|
||||||
else
|
else
|
||||||
@ -54,10 +57,10 @@ apply () {
|
|||||||
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
debug "$AUDIT_PARAM should be set to $AUDIT_VALUE"
|
||||||
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
PATTERN="^$AUDIT_PARAM[[:space:]]*=[[:space:]]*$AUDIT_VALUE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$PATTERN is not present in $FILE, adding it"
|
warn "$PATTERN is not present in $FILE, adding it"
|
||||||
does_pattern_exist_in_file $FILE "^$AUDIT_PARAM"
|
does_pattern_exist_in_file $FILE "^$AUDIT_PARAM"
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
info "Parameter $AUDIT_PARAM seems absent from $FILE, adding at the end"
|
info "Parameter $AUDIT_PARAM seems absent from $FILE, adding at the end"
|
||||||
add_end_of_file $FILE "$AUDIT_PARAM = $AUDIT_VALUE"
|
add_end_of_file $FILE "$AUDIT_PARAM = $AUDIT_VALUE"
|
||||||
else
|
else
|
||||||
@ -77,6 +80,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -86,8 +90,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
@ -11,7 +12,9 @@
|
|||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Collect discretionary access control (DAC) permission modification events."
|
DESCRIPTION="Collect discretionary access control (DAC) permission modification events."
|
||||||
|
|
||||||
AUDIT_PARAMS='-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>=1000 -F auid!=4294967295 -k perm_mod
|
AUDIT_PARAMS='-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>=1000 -F auid!=4294967295 -k perm_mod
|
||||||
@ -33,7 +36,7 @@ audit () {
|
|||||||
IFS=$d_IFS
|
IFS=$d_IFS
|
||||||
does_pattern_exist_in_file $FILE $AUDIT_VALUE
|
does_pattern_exist_in_file $FILE $AUDIT_VALUE
|
||||||
IFS=$c_IFS
|
IFS=$c_IFS
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$AUDIT_VALUE is not in file $FILE"
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
else
|
else
|
||||||
ok "$AUDIT_VALUE is present in $FILE"
|
ok "$AUDIT_VALUE is present in $FILE"
|
||||||
@ -48,7 +51,7 @@ apply () {
|
|||||||
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
debug "$AUDIT_VALUE should be in file $FILE"
|
debug "$AUDIT_VALUE should be in file $FILE"
|
||||||
does_pattern_exist_in_file $FILE $AUDIT_VALUE
|
does_pattern_exist_in_file $FILE $AUDIT_VALUE
|
||||||
if [ $FNRET != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
add_end_of_file $FILE $AUDIT_VALUE
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
eval $(pkill -HUP -P 1 auditd)
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
@ -65,6 +68,7 @@ check_config() {
|
|||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
@ -74,8 +78,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
||||||
. $CIS_ROOT_DIR/lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
|
. "$CIS_ROOT_DIR"/lib/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
||||||
exit 128
|
exit 128
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user