mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-22 05:27:01 +01:00
8.1.11_record_failed_access_file.sh 8.1.12_record_privileged_commands.sh 8.1.13_record_successful_mount.sh 8.1.14_record_file_deletions.sh 8.1.15_record_sudoers_edit.sh 8.1.16_record_sudo_usage.sh 8.1.17_record_kernel_modules.sh 8.1.18_freeze_auditd_conf.sh
This commit is contained in:
parent
2ad4260ffb
commit
488886305f
68
bin/hardening/8.1.11_record_failed_access_file.sh
Executable file
68
bin/hardening/8.1.11_record_failed_access_file.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.11 Collect Unsuccessful Unauthorized Access Attempts to Files (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-a always,exit -F arch=b64 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=4294967295 -k access
|
||||||
|
-a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=4294967295 -k access
|
||||||
|
-a always,exit -F arch=b64 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=4294967295 -k access
|
||||||
|
-a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=4294967295 -k access'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
68
bin/hardening/8.1.12_record_privileged_commands.sh
Executable file
68
bin/hardening/8.1.12_record_privileged_commands.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.12 Collect Use of Privileged Commands (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# Find all files with setuid or setgid set
|
||||||
|
AUDIT_PARAMS=$(find / -xdev \( -perm -4000 -o -perm -2000 \) -type f | awk '{print \
|
||||||
|
"-a always,exit -F path=" $1 " -F perm=x -F auid>=1000 -F auid!=4294967295 \
|
||||||
|
-k privileged" }')
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
66
bin/hardening/8.1.13_record_successful_mount.sh
Executable file
66
bin/hardening/8.1.13_record_successful_mount.sh
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.13 Collect Successful File System Mounts (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-a always,exit -F arch=b64 -S mount -F auid>=1000 -F auid!=4294967295 -k mounts
|
||||||
|
-a always,exit -F arch=b32 -S mount -F auid>=1000 -F auid!=4294967295 -k mounts'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
66
bin/hardening/8.1.14_record_file_deletions.sh
Executable file
66
bin/hardening/8.1.14_record_file_deletions.sh
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.14 Collect File Deletion Events by User (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid>=1000 -F auid!=4294967295 -k delete
|
||||||
|
-a always,exit -F arch=b32 -S unlink -S unlinkat -S rename -S renameat -F auid>=1000 -F auid!=4294967295 -k delete'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
66
bin/hardening/8.1.15_record_sudoers_edit.sh
Executable file
66
bin/hardening/8.1.15_record_sudoers_edit.sh
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.15 Collect Changes to System Administration Scope (sudoers) (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-w /etc/sudoers -p wa -k sudoers
|
||||||
|
-w /etc/sudoers.d/ -p wa -k sudoers'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
65
bin/hardening/8.1.16_record_sudo_usage.sh
Executable file
65
bin/hardening/8.1.16_record_sudo_usage.sh
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.16 Collect System Administrator Actions (sudolog) (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-w /var/log/auth.log -p wa -k sudoaction'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
68
bin/hardening/8.1.17_record_kernel_modules.sh
Executable file
68
bin/hardening/8.1.17_record_kernel_modules.sh
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.17 Collect Kernel Module Loading and Unloading (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-w /sbin/insmod -p x -k modules
|
||||||
|
-w /sbin/rmmod -p x -k modules
|
||||||
|
-w /sbin/modprobe -p x -k modules
|
||||||
|
-a always,exit -F arch=b64 -S init_module -S delete_module -k modules'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
65
bin/hardening/8.1.18_freeze_auditd_conf.sh
Executable file
65
bin/hardening/8.1.18_freeze_auditd_conf.sh
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian 7 Hardening
|
||||||
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 8.1.17 Collect Kernel Module Loading and Unloading (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
AUDIT_PARAMS='-e 2'
|
||||||
|
FILE='/etc/audit/audit.rules'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$AUDIT_VALUE is not in file $FILE"
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
IFS=$'\n'
|
||||||
|
for AUDIT_VALUE in $AUDIT_PARAMS; do
|
||||||
|
debug "$AUDIT_VALUE must be in file $FILE"
|
||||||
|
does_pattern_exists_in_file $FILE $AUDIT_VALUE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
warn "$AUDIT_VALUE is not in file $FILE, adding it"
|
||||||
|
add_end_of_file $FILE $AUDIT_VALUE
|
||||||
|
eval $(pkill -HUP -P 1 auditd)
|
||||||
|
else
|
||||||
|
ok "$AUDIT_VALUE present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ ! -r /etc/default/cis-hardenning ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardenning file, cannot source CIS_ROOT_DIR variable, aborting"
|
||||||
|
exit 128
|
||||||
|
else
|
||||||
|
. /etc/default/cis-hardenning
|
||||||
|
if [ -z $CIS_ROOT_DIR ]; then
|
||||||
|
echo "No CIS_ROOT_DIR variable, aborting"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
2
etc/conf.d/8.1.11_record_failed_access_file.cfg
Normal file
2
etc/conf.d/8.1.11_record_failed_access_file.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.12_record_privileged_commands.cfg
Normal file
2
etc/conf.d/8.1.12_record_privileged_commands.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.13_record_successful_mount.cfg
Normal file
2
etc/conf.d/8.1.13_record_successful_mount.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.14_record_file_deletions.cfg
Normal file
2
etc/conf.d/8.1.14_record_file_deletions.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.15_record_sudoers_edit.cfg
Normal file
2
etc/conf.d/8.1.15_record_sudoers_edit.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.16_record_sudo_usage.cfg
Normal file
2
etc/conf.d/8.1.16_record_sudo_usage.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.17_record_kernel_modules.cfg
Normal file
2
etc/conf.d/8.1.17_record_kernel_modules.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
2
etc/conf.d/8.1.18_freeze_auditd_conf.cfg
Normal file
2
etc/conf.d/8.1.18_freeze_auditd_conf.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Configuration for script of same name
|
||||||
|
status=enabled
|
Loading…
Reference in New Issue
Block a user