mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 13:52:17 +02:00
Compare commits
94 Commits
Author | SHA1 | Date | |
---|---|---|---|
88e3a515ef | |||
55c1cdbdde | |||
6f5d714b55 | |||
a37c5bdc4e | |||
d6e5803252 | |||
922f28c200 | |||
70be679567 | |||
413277d7eb | |||
e62648d6a4 | |||
ef5c00fef5 | |||
20dacdf6c7 | |||
19ee1cabf8 | |||
5a1a70bbd3 | |||
a4969e6ba6 | |||
96f3b74334 | |||
89cf484cb9 | |||
13783423c2 | |||
b2f7460977 | |||
71f97062d7 | |||
1ec77dbb56 | |||
8f87d75293 | |||
41e3402b10 | |||
02673826a0 | |||
d5d5a39109 | |||
1bac756dcb | |||
75f6cce7f5 | |||
be1ad3e581 | |||
b4b7524156 | |||
455e58899d | |||
9ada868f43 | |||
4bddd8ee8b | |||
81dc308677 | |||
db4dc4d598 | |||
a9af957f7a | |||
0a6f8bdba6 | |||
d05ffaf9d5 | |||
41ccd5655a | |||
e46a85dc6c | |||
1caf0f489a | |||
de7dfe5956 | |||
8031c388c6 | |||
7b8e359590 | |||
f7f2f614aa | |||
605a768fe1 | |||
80a1146af7 | |||
7408216957 | |||
217895dfe6 | |||
bc5809f92e | |||
22d223fece | |||
ac76942ca7 | |||
cf42666833 | |||
6cbe8f572f | |||
982301d395 | |||
d18f5edfba | |||
6ede832685 | |||
0c17da012f | |||
6afed4eedb | |||
bad32f8078 | |||
47a818b832 | |||
fc88194eca | |||
2b2a91a564 | |||
5c313c8f31 | |||
11305a0980 | |||
1586dae0c5 | |||
1281860401 | |||
09ae131de9 | |||
1dd630e65b | |||
810fee4c8f | |||
ba93159a00 | |||
d014405e1f | |||
6cea326921 | |||
58cb064919 | |||
3ff3bb209f | |||
507eadc3cb | |||
aa3983c6d0 | |||
2dd753e5e7 | |||
bf3bfc2a91 | |||
a1a4295dcf | |||
e8ae07c2e8 | |||
13c88c7da2 | |||
9ba0361be0 | |||
71b70a2b8c | |||
176fb96fa4 | |||
c51a8ee9b8 | |||
e72c7aae15 | |||
8e6618eedf | |||
67df4da781 | |||
8a7f9ddad5 | |||
863adc9c84 | |||
4fc79c133f | |||
7077554bca | |||
76abf8da36 | |||
51f589923d | |||
b1f85d3f99 |
46
README.md
46
README.md
@ -1,6 +1,6 @@
|
|||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian 7/8/9 Hardening
|
||||||
|
|
||||||
Modular Debian 7/8 security hardening scripts based on [cisecurity.org](https://www.cisecurity.org)
|
Modular Debian 7/8/9 security hardening scripts based on [cisecurity.org](https://www.cisecurity.org)
|
||||||
recommendations. We use it at [OVH](https://www.ovh.com) to harden our PCI-DSS infrastructure.
|
recommendations. We use it at [OVH](https://www.ovh.com) to harden our PCI-DSS infrastructure.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
@ -80,6 +80,15 @@ configuration. It will run all scripts in audit mode. If a script passes,
|
|||||||
it will automatically be enabled for future runs. Do NOT use this option
|
it will automatically be enabled for future runs. Do NOT use this option
|
||||||
if you have already started to customize your configuration.
|
if you have already started to customize your configuration.
|
||||||
|
|
||||||
|
``--sudo``: Audit your system as a normal user, but allow sudo escalation to read
|
||||||
|
specific root read-only files. You need to provide a sudoers file in /etc/sudoers.d/
|
||||||
|
with NOPASWD option, since checks are executed with ``sudo -n`` option, that will
|
||||||
|
not prompt for a password.
|
||||||
|
|
||||||
|
``--batch``: While performing system audit, this option sets LOGLEVEL to 'ok' and
|
||||||
|
captures all output to print only one line once the check is done, formatted like :
|
||||||
|
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
||||||
|
|
||||||
## Hacking
|
## Hacking
|
||||||
|
|
||||||
**Getting the source**
|
**Getting the source**
|
||||||
@ -108,6 +117,39 @@ Code your check explaining what it does then if you want to test
|
|||||||
$ sed -i "s/status=.+/status=enabled/" etc/conf.d/99.99_custom_script.cfg
|
$ sed -i "s/status=.+/status=enabled/" etc/conf.d/99.99_custom_script.cfg
|
||||||
$ ./bin/hardening/99.99_custom_script.sh
|
$ ./bin/hardening/99.99_custom_script.sh
|
||||||
```
|
```
|
||||||
|
## Functional testing
|
||||||
|
|
||||||
|
Functional tests are available. They are to be run in a Docker environment.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./tests/docker_build_and_run_tests.sh <target> [name of test script...]
|
||||||
|
```
|
||||||
|
|
||||||
|
With `target` being like `debian8` or `debian9`.
|
||||||
|
|
||||||
|
Running without script arguments will run all tests in `./tests/hardening/` directory.
|
||||||
|
Or you can specify one or several test script to be run.
|
||||||
|
|
||||||
|
This will build a new Docker image from the current state of the projet and run
|
||||||
|
a container that will assess a blank Debian system compliance for each check.
|
||||||
|
For hardening audit points the audit is expected to fail, then be fixed so that
|
||||||
|
running the audit a second time will succeed.
|
||||||
|
For vulnerable items, the audit is expected to succeed on a blank
|
||||||
|
system, then the functional tests will introduce a weak point, that is expected
|
||||||
|
to be detected when running the audit test a second time. Finally running the `apply`
|
||||||
|
part of debian-cis script will restore a compliance state that is expected to be
|
||||||
|
assed by running the audit check a third time.
|
||||||
|
|
||||||
|
Functional tests can make use of the following helper functions :
|
||||||
|
|
||||||
|
* `describe <test description>`
|
||||||
|
* `run <usecase> <audit_script> <audit_script_options>`
|
||||||
|
* `register_test <test content (see below)>`
|
||||||
|
* `retvalshoudbe <integer>` check the script return value
|
||||||
|
* `contain "<SAMPLE TEXT>"` check that the output contains the following text
|
||||||
|
|
||||||
|
In order to write your own functional test, you will find a code skeleton in
|
||||||
|
`./src/skel.test`.
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -22,6 +22,8 @@ AUDIT_ALL=0
|
|||||||
AUDIT_ALL_ENABLE_PASSED=0
|
AUDIT_ALL_ENABLE_PASSED=0
|
||||||
ALLOW_SERVICE_LIST=0
|
ALLOW_SERVICE_LIST=0
|
||||||
SET_HARDENING_LEVEL=0
|
SET_HARDENING_LEVEL=0
|
||||||
|
SUDO_MODE=''
|
||||||
|
BATCH_MODE=''
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
@ -83,6 +85,18 @@ OPTIONS:
|
|||||||
The test number is the numbered prefix of the script,
|
The test number is the numbered prefix of the script,
|
||||||
i.e. the test number of 1.2_script_name.sh is 1.2.
|
i.e. the test number of 1.2_script_name.sh is 1.2.
|
||||||
|
|
||||||
|
--sudo
|
||||||
|
This option lets you audit your system as a normal user, but allows sudo
|
||||||
|
escalation to gain read-only access to root files. Note that you need to
|
||||||
|
provide a sudoers file with NOPASSWD option in /etc/sudoers.d/ because
|
||||||
|
the '-n' option instructs sudo not to prompt for a password.
|
||||||
|
Finally note that '--sudo' mode only works for audit mode.
|
||||||
|
|
||||||
|
--batch
|
||||||
|
While performing system audit, this option sets LOGLEVEL to 'ok' and
|
||||||
|
captures all output to print only one line once the check is done, formatted like :
|
||||||
|
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -124,6 +138,13 @@ while [[ $# > 0 ]]; do
|
|||||||
TEST_LIST[${#TEST_LIST[@]}]="$2"
|
TEST_LIST[${#TEST_LIST[@]}]="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--sudo)
|
||||||
|
SUDO_MODE='--sudo'
|
||||||
|
;;
|
||||||
|
--batch)
|
||||||
|
BATCH_MODE='--batch'
|
||||||
|
LOGLEVEL=ok
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
@ -134,6 +155,11 @@ while [[ $# > 0 ]]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# if no RUN_MODE was passed, usage and quit
|
||||||
|
if [ "$AUDIT" -eq 0 -a "$AUDIT_ALL" -eq 0 -a "$AUDIT_ALL_ENABLE_PASSED" -eq 0 -a "$APPLY" -eq 0 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
@ -149,6 +175,8 @@ fi
|
|||||||
[ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh
|
[ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh
|
||||||
[ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh
|
[ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh
|
||||||
|
|
||||||
|
if [ $BATCH_MODE ]; then MACHINE_LOG_LEVEL=3; fi
|
||||||
|
|
||||||
# If --allow-service-list is specified, don't run anything, just list the supported services
|
# If --allow-service-list is specified, don't run anything, just list the supported services
|
||||||
if [ "$ALLOW_SERVICE_LIST" = 1 ] ; then
|
if [ "$ALLOW_SERVICE_LIST" = 1 ] ; then
|
||||||
declare -a HARDENING_EXCEPTIONS_LIST
|
declare -a HARDENING_EXCEPTIONS_LIST
|
||||||
@ -188,7 +216,7 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
|
|||||||
# --only X has been specified at least once, is this script in my list ?
|
# --only X has been specified at least once, is this script in my list ?
|
||||||
SCRIPT_PREFIX=$(grep -Eo '^[0-9.]+' <<< "$(basename $SCRIPT)")
|
SCRIPT_PREFIX=$(grep -Eo '^[0-9.]+' <<< "$(basename $SCRIPT)")
|
||||||
SCRIPT_PREFIX_RE=$(sed -e 's/\./\\./g' <<< "$SCRIPT_PREFIX")
|
SCRIPT_PREFIX_RE=$(sed -e 's/\./\\./g' <<< "$SCRIPT_PREFIX")
|
||||||
if ! grep -qEw "$SCRIPT_PREFIX_RE" <<< "${TEST_LIST[@]}"; then
|
if ! grep -qwE "(^| )$SCRIPT_PREFIX_RE" <<< "${TEST_LIST[@]}"; then
|
||||||
# not in the list
|
# not in the list
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -197,14 +225,14 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
|
|||||||
info "Treating $SCRIPT"
|
info "Treating $SCRIPT"
|
||||||
|
|
||||||
if [ $AUDIT = 1 ]; then
|
if [ $AUDIT = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit"
|
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE $BATCH_MODE"
|
||||||
$SCRIPT --audit
|
$SCRIPT --audit $SUDO_MODE $BATCH_MODE
|
||||||
elif [ $AUDIT_ALL = 1 ]; then
|
elif [ $AUDIT_ALL = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all"
|
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
|
||||||
$SCRIPT --audit-all
|
$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
|
||||||
elif [ $AUDIT_ALL_ENABLE_PASSED = 1 ]; then
|
elif [ $AUDIT_ALL_ENABLE_PASSED = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all"
|
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE" $BATCH_MODE
|
||||||
$SCRIPT --audit-all
|
$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
|
||||||
elif [ $APPLY = 1 ]; then
|
elif [ $APPLY = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT"
|
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT"
|
||||||
$SCRIPT
|
$SCRIPT
|
||||||
@ -239,6 +267,18 @@ done
|
|||||||
|
|
||||||
TOTAL_TREATED_CHECKS=$((TOTAL_CHECKS-DISABLED_CHECKS))
|
TOTAL_TREATED_CHECKS=$((TOTAL_CHECKS-DISABLED_CHECKS))
|
||||||
|
|
||||||
|
if [ $BATCH_MODE ]; then
|
||||||
|
BATCH_SUMMARY="AUDIT_SUMMARY "
|
||||||
|
BATCH_SUMMARY+="PASSED_CHECKS:${PASSED_CHECKS:-0} "
|
||||||
|
BATCH_SUMMARY+="RUN_CHECKS:${TOTAL_TREATED_CHECKS:-0} "
|
||||||
|
BATCH_SUMMARY+="TOTAL_CHECKS_AVAIL:${TOTAL_CHECKS:-0}"
|
||||||
|
if [ $TOTAL_TREATED_CHECKS != 0 ]; then
|
||||||
|
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:$(printf "%.2f" $( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l))"
|
||||||
|
else
|
||||||
|
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
|
||||||
|
fi
|
||||||
|
becho $BATCH_SUMMARY
|
||||||
|
else
|
||||||
printf "%40s\n" "################### SUMMARY ###################"
|
printf "%40s\n" "################### SUMMARY ###################"
|
||||||
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
||||||
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS"
|
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS"
|
||||||
@ -250,3 +290,4 @@ if [ $TOTAL_TREATED_CHECKS != 0 ]; then
|
|||||||
else
|
else
|
||||||
printf "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0
|
printf "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Install updates, patches and additional secutiry software."
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set password expiration days."
|
||||||
|
|
||||||
PACKAGE='login'
|
PACKAGE='login'
|
||||||
OPTIONS='PASS_MAX_DAYS=90'
|
OPTIONS='PASS_MAX_DAYS=90'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set password change minimum number of days."
|
||||||
|
|
||||||
PACKAGE='login'
|
PACKAGE='login'
|
||||||
OPTIONS='PASS_MIN_DAYS=7'
|
OPTIONS='PASS_MIN_DAYS=7'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set password expiration warning days."
|
||||||
|
|
||||||
PACKAGE='login'
|
PACKAGE='login'
|
||||||
OPTIONS='PASS_WARN_AGE=7'
|
OPTIONS='PASS_WARN_AGE=7'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,15 +12,20 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Disable system accounts, preventing them from interactive login."
|
||||||
|
|
||||||
SHELL='/bin/false'
|
ACCEPTED_SHELLS='/bin/false /usr/sbin/nologin /sbin/nologin'
|
||||||
|
SHELL_TO_APPLY='/bin/false'
|
||||||
FILE='/etc/passwd'
|
FILE='/etc/passwd'
|
||||||
RESULT=''
|
RESULT=''
|
||||||
|
|
||||||
|
ACCEPTED_SHELLS_GREP=''
|
||||||
# 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 admin accounts have a login shell different than $SHELL"
|
shells_to_grep_helper
|
||||||
RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 && $7!="/usr/sbin/nologin" && $7!="/bin/false") {print}')
|
info "Checking if admin accounts have a login shell different than $ACCEPTED_SHELLS"
|
||||||
|
RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true )
|
||||||
|
IFS_BAK=$IFS
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for LINE in $RESULT; do
|
for LINE in $RESULT; do
|
||||||
debug "line : $LINE"
|
debug "line : $LINE"
|
||||||
@ -35,8 +40,9 @@ audit () {
|
|||||||
debug "$ACCOUNT not found in exceptions"
|
debug "$ACCOUNT not found in exceptions"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
IFS=$IFS_BAK
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some admin accounts don't have $SHELL as their login shell"
|
crit "Some admin accounts don't have any of $ACCEPTED_SHELLS as their login shell"
|
||||||
crit "$RESULT"
|
crit "$RESULT"
|
||||||
else
|
else
|
||||||
ok "All admin accounts deactivated"
|
ok "All admin accounts deactivated"
|
||||||
@ -45,7 +51,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 () {
|
||||||
RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 && $7!="/usr/sbin/nologin" && $7!="/bin/false") {print}')
|
RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true )
|
||||||
|
IFS_BAK=$IFS
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for LINE in $RESULT; do
|
for LINE in $RESULT; do
|
||||||
debug "line : $LINE"
|
debug "line : $LINE"
|
||||||
@ -60,22 +67,29 @@ apply () {
|
|||||||
debug "$ACCOUNT not found in exceptions"
|
debug "$ACCOUNT not found in exceptions"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
IFS=$IFS_BAK
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
warn "Some admin accounts don't have $SHELL as their login shell -- Fixing"
|
warn "Some admin accounts don't have any of $ACCEPTED_SHELLS as their login shell -- Fixing"
|
||||||
warn "$RESULT"
|
warn "$RESULT"
|
||||||
for USER in $( echo "$RESULT" | cut -d: -f 1 ); do
|
for USER in $( echo "$RESULT" | cut -d: -f 1 ); do
|
||||||
info "Setting $SHELL as $USER login shell"
|
info "Setting $SHELL_TO_APPLY as $USER login shell"
|
||||||
usermod -s $SHELL $USER
|
usermod -s "$SHELL_TO_APPLY" "$USER"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
ok "All admin accounts deactivated, nothing to apply"
|
ok "All admin accounts deactivated, nothing to apply"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shells_to_grep_helper(){
|
||||||
|
for shell in $ACCEPTED_SHELLS; do
|
||||||
|
ACCEPTED_SHELLS_GREP+=" -e $shell"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# This function will create the config file for this check with default values
|
# This function will create the config file for this check with default values
|
||||||
create_config() {
|
create_config() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
status=disabled
|
status=audit
|
||||||
# Put here your exceptions concerning admin accounts shells separated by spaces
|
# Put here your exceptions concerning admin accounts shells separated by spaces
|
||||||
EXCEPTIONS=""
|
EXCEPTIONS=""
|
||||||
EOF
|
EOF
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Set default group for root account to 0."
|
||||||
|
|
||||||
USER='root'
|
USER='root'
|
||||||
EXPECTED_GID='0'
|
EXPECTED_GID='0'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set default mask for users to 077."
|
||||||
|
|
||||||
USER='root'
|
USER='root'
|
||||||
PATTERN='umask 077'
|
PATTERN='umask 077'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Lock inactive user accounts."
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Checking root ownership and 644 permissions on banner files : /etc/motd|issue|issue.net ."
|
||||||
|
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
USER='root'
|
USER='root'
|
||||||
@ -21,6 +22,11 @@ FILES='/etc/motd /etc/issue /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 () {
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
|
does_file_exist $FILE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$FILE does not exist"
|
||||||
|
continue
|
||||||
|
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"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Remove OS information from Login Warning Banners."
|
||||||
|
|
||||||
FILES='/etc/motd /etc/issue /etc/issue.net'
|
FILES='/etc/motd /etc/issue /etc/issue.net'
|
||||||
PATTERN='(\\v|\\r|\\m|\\s)'
|
PATTERN='(\\v|\\r|\\m|\\s)'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set graphical warning banner."
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,21 +11,32 @@
|
|||||||
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
|
||||||
|
DESCRIPTION="Find SUID system executables."
|
||||||
|
IGNORED_PATH=''
|
||||||
|
|
||||||
# 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 there are suid files"
|
info "Checking if there are suid files"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -4000 -print)
|
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }' )
|
||||||
for BINARY in $RESULT; do
|
# shellcheck disable=2086
|
||||||
if grep -q $BINARY <<< "$EXCEPTIONS"; then
|
if [ ! -z $IGNORED_PATH ]; then
|
||||||
|
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -4000 -regextype 'egrep' ! -regex "$IGNORED_PATH" -print)
|
||||||
|
else
|
||||||
|
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -4000 -print)
|
||||||
|
fi
|
||||||
|
BAD_BINARIES=""
|
||||||
|
for BINARY in $FOUND_BINARIES; do
|
||||||
|
if grep -qw "$BINARY" <<< "$EXCEPTIONS"; then
|
||||||
debug "$BINARY is confirmed as an exception"
|
debug "$BINARY is confirmed as an exception"
|
||||||
RESULT=$(sed "s!$BINARY!!" <<< $RESULT)
|
else
|
||||||
|
BAD_BINARIES="$BAD_BINARIES $BINARY"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$BAD_BINARIES" ]; then
|
||||||
crit "Some suid files are present"
|
crit "Some suid files are present"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< "$BAD_BINARIES" | sort | uniq | tr '\n' ' ')
|
||||||
crit "$FORMATTED_RESULT"
|
crit "$FORMATTED_RESULT"
|
||||||
else
|
else
|
||||||
ok "No unknown suid files found"
|
ok "No unknown suid files found"
|
||||||
@ -40,9 +51,9 @@ apply () {
|
|||||||
# This function will create the config file for this check with default values
|
# This function will create the config file for this check with default values
|
||||||
create_config() {
|
create_config() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
status=disabled
|
status=audit
|
||||||
# Put Here your valid suid binaries so that they do not appear during the audit
|
# Put Here your valid suid binaries so that they do not appear during the audit
|
||||||
EXCEPTIONS="/bin/mount /bin/ping /bin/ping6 /bin/su /bin/umount /usr/bin/chfn /usr/bin/chsh /usr/bin/fping /usr/bin/fping6 /usr/bin/gpasswd /usr/bin/mtr /usr/bin/newgrp /usr/bin/passwd /usr/bin/sudo /usr/bin/sudoedit /usr/lib/openssh/ssh-keysign /usr/lib/pt_chown /usr/bin/at"
|
EXCEPTIONS="/bin/mount /usr/bin/mount /bin/ping /usr/bin/ping /bin/ping6 /usr/bin/ping6 /bin/su /usr/bin/su /bin/umount /usr/bin/umount /usr/bin/chfn /usr/bin/chsh /usr/bin/fping /usr/bin/fping6 /usr/bin/gpasswd /usr/bin/mtr /usr/bin/newgrp /usr/bin/passwd /usr/bin/sudo /usr/bin/sudoedit /usr/lib/openssh/ssh-keysign /usr/lib/pt_chown /usr/bin/at"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,21 +11,32 @@
|
|||||||
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
|
||||||
|
DESCRIPTION="Find SGID system executables."
|
||||||
|
IGNORED_PATH=''
|
||||||
|
|
||||||
# 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 there are sgid files"
|
info "Checking if there are sgid files"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -2000 -print)
|
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }' )
|
||||||
for BINARY in $RESULT; do
|
# shellcheck disable=2086
|
||||||
if grep -q $BINARY <<< "$EXCEPTIONS"; then
|
if [ ! -z $IGNORED_PATH ]; then
|
||||||
|
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -2000 -regextype 'egrep' ! -regex "$IGNORED_PATH" -print)
|
||||||
|
else
|
||||||
|
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -2000 -print)
|
||||||
|
fi
|
||||||
|
BAD_BINARIES=""
|
||||||
|
for BINARY in $FOUND_BINARIES; do
|
||||||
|
if grep -qw "$BINARY" <<< "$EXCEPTIONS"; then
|
||||||
debug "$BINARY is confirmed as an exception"
|
debug "$BINARY is confirmed as an exception"
|
||||||
RESULT=$(sed "s!$BINARY!!" <<< $RESULT)
|
else
|
||||||
|
BAD_BINARIES="$BAD_BINARIES $BINARY"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$BAD_BINARIES" ]; then
|
||||||
crit "Some sgid files are present"
|
crit "Some sgid files are present"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< "$BAD_BINARIES" | sort | uniq | tr '\n' ' ')
|
||||||
crit "$FORMATTED_RESULT"
|
crit "$FORMATTED_RESULT"
|
||||||
else
|
else
|
||||||
ok "No unknown sgid files found"
|
ok "No unknown sgid files found"
|
||||||
@ -40,9 +51,9 @@ apply () {
|
|||||||
# This function will create the config file for this check with default values
|
# This function will create the config file for this check with default values
|
||||||
create_config() {
|
create_config() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
status=disabled
|
status=audit
|
||||||
# Put here valid binaries with sgid enabled separated by spaces
|
# Put here valid binaries with sgid enabled separated by spaces
|
||||||
EXCEPTIONS="/sbin/unix_chkpwd /usr/bin/bsd-write /usr/bin/chage /usr/bin/crontab /usr/bin/expiry /usr/bin/mutt_dotlock /usr/bin/screen /usr/bin/ssh-agent /usr/bin/wall /usr/sbin/postdrop /usr/sbin/postqueue /usr/bin/at /usr/bin/dotlockfile /usr/bin/mail-lock /usr/bin/mail-touchlock /usr/bin/mail-unlock"
|
EXCEPTIONS="/sbin/unix_chkpwd /usr/sbin/unix_chkpwd /usr/bin/bsd-write /usr/bin/chage /usr/bin/crontab /usr/bin/expiry /usr/bin/mutt_dotlock /usr/bin/screen /usr/bin/ssh-agent /usr/bin/wall /usr/sbin/postdrop /usr/sbin/postqueue /usr/bin/at /usr/bin/dotlockfile /usr/bin/mail-lock /usr/bin/mail-touchlock /usr/bin/mail-unlock"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check permissions on /etc/passwd to 644."
|
||||||
|
|
||||||
FILE='/etc/passwd'
|
FILE='/etc/passwd'
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check permissions on /etc/shadow to 640."
|
||||||
|
|
||||||
FILE='/etc/shadow'
|
FILE='/etc/shadow'
|
||||||
PERMISSIONS='640'
|
PERMISSIONS='640'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check permissions on /etc/group to 644."
|
||||||
|
|
||||||
FILE='/etc/group'
|
FILE='/etc/group'
|
||||||
PERMISSIONS='644'
|
PERMISSIONS='644'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check user/group to root on /etc/passwd."
|
||||||
|
|
||||||
FILE='/etc/passwd'
|
FILE='/etc/passwd'
|
||||||
USER='root'
|
USER='root'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check user/group to root on etc/shadow."
|
||||||
|
|
||||||
FILE='/etc/shadow'
|
FILE='/etc/shadow'
|
||||||
USER='root'
|
USER='root'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Check user/group to root on /etc/group."
|
||||||
|
|
||||||
FILE='/etc/group'
|
FILE='/etc/group'
|
||||||
USER='root'
|
USER='root'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,11 +12,13 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Find world writable files."
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
info "Checking if there are world writable files"
|
info "Checking if there are world writable files"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -0002 -print 2>/dev/null)
|
FS_NAMES=$(df --local -P | awk {'if (NR!=1) print $6'} )
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -0002 -print 2>/dev/null)
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some world writable files are present"
|
crit "Some world writable files are present"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,13 +12,20 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Find un-owned files and directories."
|
||||||
|
|
||||||
USER='root'
|
USER='root'
|
||||||
|
EXCLUDED=''
|
||||||
|
|
||||||
# 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 there are unowned files"
|
info "Checking if there are unowned files"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -print 2>/dev/null)
|
FS_NAMES=$(df --local -P | awk {'if (NR!=1) print $6'} )
|
||||||
|
if [ ! -z $EXCLUDED ]; then
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nouser -regextype 'egrep' ! -regex "$EXCLUDED" -print 2>/dev/null)
|
||||||
|
else
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nouser -print 2>/dev/null)
|
||||||
|
fi
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some unowned files are present"
|
crit "Some unowned files are present"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
||||||
@ -30,7 +37,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 () {
|
||||||
|
if [ ! -z $EXCLUDED ]; then
|
||||||
|
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -regextype 'egrep' ! -regex "$EXCLUDED" -ls 2>/dev/null)
|
||||||
|
else
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -ls 2>/dev/null)
|
||||||
|
fi
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
warn "Applying chown on all unowned files in the system"
|
warn "Applying chown on all unowned files in the system"
|
||||||
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -print 2>/dev/null | xargs chown $USER
|
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -print 2>/dev/null | xargs chown $USER
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,13 +12,20 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Find un-grouped files and directories."
|
||||||
|
|
||||||
GROUP='root'
|
GROUP='root'
|
||||||
|
EXCLUDED=''
|
||||||
|
|
||||||
# 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 there are ungrouped files"
|
info "Checking if there are ungrouped files"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -print 2>/dev/null)
|
FS_NAMES=$(df --local -P | awk {'if (NR!=1) print $6'} )
|
||||||
|
if [ ! -z $EXCLUDED ]; then
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nogroup -regextype 'egrep' ! -regex "$EXCLUDED" -print 2>/dev/null)
|
||||||
|
else
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nogroup -print 2>/dev/null)
|
||||||
|
fi
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some ungrouped files are present"
|
crit "Some ungrouped files are present"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
||||||
@ -30,7 +37,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 () {
|
||||||
|
if [ ! -z $EXCLUDED ]; then
|
||||||
|
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -regextype 'egrep' ! -regex "$EXCLUDED" -ls 2>/dev/null)
|
||||||
|
else
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -ls 2>/dev/null)
|
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -ls 2>/dev/null)
|
||||||
|
fi
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
warn "Applying chgrp on all ungrouped files in the system"
|
warn "Applying chgrp on all ungrouped files in the system"
|
||||||
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -print 2>/dev/null | xargs chgrp $GROUP
|
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -print 2>/dev/null | xargs chgrp $GROUP
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="No user's .rhosts file."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
FILENAME=".rhosts"
|
FILENAME=".rhosts"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="There is no group in /etc/passwd that is not in /etc/group."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Users are assigned valid home directories."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ audit () {
|
|||||||
USER=$(awk -F: {'print $1'} <<< $LINE)
|
USER=$(awk -F: {'print $1'} <<< $LINE)
|
||||||
USERID=$(awk -F: {'print $2'} <<< $LINE)
|
USERID=$(awk -F: {'print $2'} <<< $LINE)
|
||||||
DIR=$(awk -F: {'print $3'} <<< $LINE)
|
DIR=$(awk -F: {'print $3'} <<< $LINE)
|
||||||
if [ $USERID -ge 1000 -a ! -d "$DIR" -a $USER != "nfsnobody" -a $USER != "nobody" ]; then
|
if [ $USERID -ge 1000 -a ! -d "$DIR" -a $USER != "nfsnobody" -a $USER != "nobody" -a "$DIR" != "/nonexistent" ]; then
|
||||||
crit "The home directory ($DIR) of user $USER does not exist."
|
crit "The home directory ($DIR) of user $USER does not exist."
|
||||||
ERRORS=$((ERRORS+1))
|
ERRORS=$((ERRORS+1))
|
||||||
fi
|
fi
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,25 +12,39 @@
|
|||||||
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="Check user home directory ownership."
|
||||||
|
EXCEPTIONS=""
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=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 () {
|
||||||
RESULT=$(cat /etc/passwd | awk -F: '{ print $1 ":" $3 ":" $6 }')
|
RESULT=$(awk -F: '{ print $1 ":" $3 ":" $6 }' /etc/passwd )
|
||||||
for LINE in $RESULT; do
|
for LINE in $RESULT; do
|
||||||
debug "Working on $LINE"
|
debug "Working on $LINE"
|
||||||
USER=$(awk -F: {'print $1'} <<< $LINE)
|
USER=$(awk -F: '{print $1}' <<< "$LINE")
|
||||||
USERID=$(awk -F: {'print $2'} <<< $LINE)
|
USERID=$(awk -F: '{print $2}' <<< "$LINE")
|
||||||
DIR=$(awk -F: {'print $3'} <<< $LINE)
|
DIR=$(awk -F: '{print $3}' <<< "$LINE")
|
||||||
if [ $USERID -ge 500 -a -d "$DIR" -a $USER != "nfsnobody" ]; then
|
if [ "$USERID" -ge 500 ] && [ -d "$DIR" ] && [ "$USER" != "nfsnobody" ]; then
|
||||||
OWNER=$(stat -L -c "%U" "$DIR")
|
OWNER=$(stat -L -c "%U" "$DIR")
|
||||||
if [ "$OWNER" != "$USER" ]; then
|
if [ "$OWNER" != "$USER" ]; then
|
||||||
|
EXCEP_FOUND=0
|
||||||
|
for excep in $EXCEPTIONS; do
|
||||||
|
if [ "$DIR:$USER:$OWNER" = "$excep" ]; then
|
||||||
|
ok "The home directory ($DIR) of user $USER is owned by $OWNER but is part of exceptions ($DIR:$USER:$OWNER)."
|
||||||
|
EXCEP_FOUND=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$EXCEP_FOUND" -eq 0 ]; then
|
||||||
crit "The home directory ($DIR) of user $USER is owned by $OWNER."
|
crit "The home directory ($DIR) of user $USER is owned by $OWNER."
|
||||||
ERRORS=$((ERRORS+1))
|
ERRORS=$((ERRORS+1))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $ERRORS = 0 ]; then
|
if [ $ERRORS = 0 ]; then
|
||||||
@ -39,17 +54,26 @@ 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 () {
|
||||||
cat /etc/passwd | awk -F: '{ print $1 " " $3 " " $6 }' | while read USER USERID DIR; do
|
awk -F: '{ print $1 " " $3 " " $6 }' /etc/passwd | while read -r USER USERID DIR; do
|
||||||
if [ $USERID -ge 500 -a -d "$DIR" -a $USER != "nfsnobody" ]; then
|
if [ "$USERID" -ge 500 ] && [ -d "$DIR" ] && [ "$USER" != "nfsnobody" ]; then
|
||||||
OWNER=$(stat -L -c "%U" "$DIR")
|
OWNER=$(stat -L -c "%U" "$DIR")
|
||||||
if [ "$OWNER" != "$USER" ]; then
|
if [ "$OWNER" != "$USER" ]; then
|
||||||
warn "The home directory ($DIR) of user $USER is owned by $OWNER."
|
warn "The home directory ($DIR) of user $USER is owned by $OWNER."
|
||||||
chown $USER $DIR
|
chown "$USER" "$DIR"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function will create the config file for this check with default values
|
||||||
|
create_config() {
|
||||||
|
cat <<EOF
|
||||||
|
status=audit
|
||||||
|
# Specify here exception for which owner of user's home directory is not the user
|
||||||
|
# "home:user:owner home2:user2:owner2"
|
||||||
|
EXCEPTIONS=""
|
||||||
|
EOF
|
||||||
|
}
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
:
|
:
|
||||||
@ -66,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,26 +11,37 @@
|
|||||||
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="Checking for duplicate UIDs."
|
||||||
|
EXCEPTIONS=""
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=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 () {
|
||||||
RESULT=$(cat /etc/passwd | cut -f3 -d":" | sort -n | uniq -c | awk {'print $1":"$2'} )
|
RESULT=$(cut -f3 -d":" < /etc/passwd | sort -n | uniq -c | awk '{print $1":"$2}' )
|
||||||
|
FOUND_EXCEPTIONS=""
|
||||||
for LINE in $RESULT; do
|
for LINE in $RESULT; do
|
||||||
debug "Working on line $LINE"
|
debug "Working on line $LINE"
|
||||||
OCC_NUMBER=$(awk -F: {'print $1'} <<< $LINE)
|
OCC_NUMBER=$(awk -F: '{print $1}' <<< "$LINE")
|
||||||
USERID=$(awk -F: {'print $2'} <<< $LINE)
|
USERID=$(awk -F: '{print $2}' <<< "$LINE")
|
||||||
if [ $OCC_NUMBER -gt 1 ]; then
|
if [ "$OCC_NUMBER" -gt 1 ]; then
|
||||||
USERS=$(awk -F: '($3 == n) { print $1 }' n=$USERID /etc/passwd | xargs)
|
USERS=$(awk -F: '($3 == n) { print $1 }' n="$USERID" /etc/passwd | xargs)
|
||||||
|
ID_NAMES="($USERID): ${USERS}"
|
||||||
|
if echo "$EXCEPTIONS" | grep -qw "$USERID"; then
|
||||||
|
debug "$USERID is confirmed as an exception"
|
||||||
|
FOUND_EXCEPTIONS="$FOUND_EXCEPTIONS $ID_NAMES"
|
||||||
|
else
|
||||||
ERRORS=$((ERRORS+1))
|
ERRORS=$((ERRORS+1))
|
||||||
crit "Duplicate UID ($USERID): ${USERS}"
|
crit "Duplicate UID $ID_NAMES"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $ERRORS = 0 ]; then
|
if [ $ERRORS = 0 ]; then
|
||||||
ok "No duplicate UIDs"
|
ok "No duplicate UIDs${FOUND_EXCEPTIONS:+ apart from configured exceptions:}${FOUND_EXCEPTIONS}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +50,20 @@ apply () {
|
|||||||
info "Editing automatically uids may seriously harm your system, report only here"
|
info "Editing automatically uids may seriously harm your system, report only here"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function will create the config file for this check with default values
|
||||||
|
create_config() {
|
||||||
|
cat <<EOF
|
||||||
|
status=audit
|
||||||
|
# Put here valid UIDs for which multiple usernames are accepted
|
||||||
|
EXCEPTIONS=""
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
:
|
if [ -z "$EXCEPTIONS" ]; then
|
||||||
|
EXCEPTIONS="@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
@ -55,8 +77,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,21 +11,24 @@
|
|||||||
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="There is no duplicate GIDs."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=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 () {
|
||||||
RESULT=$(cat /etc/group | cut -f3 -d":" | sort -n | uniq -c | awk {'print $1":"$2'} )
|
RESULT=$(cut -f3 -d":" /etc/group | sort -n | uniq -c | awk '{print $1":"$2}' )
|
||||||
for LINE in $RESULT; do
|
for LINE in $RESULT; do
|
||||||
debug "Working on line $LINE"
|
debug "Working on line $LINE"
|
||||||
OCC_NUMBER=$(awk -F: {'print $1'} <<< $LINE)
|
OCC_NUMBER=$(awk -F: '{print $1}' <<< "$LINE")
|
||||||
GROUPID=$(awk -F: {'print $2'} <<< $LINE)
|
GROUPID=$(awk -F: '{print $2}' <<< "$LINE")
|
||||||
if [ $OCC_NUMBER -gt 1 ]; then
|
if [ "$OCC_NUMBER" -gt 1 ]; then
|
||||||
USERS=$(awk -F: '($3 == n) { print $1 }' n=$GROUPID /etc/passwd | xargs)
|
GROUP=$(awk -F: '($3 == n) { print $1 }' n="$GROUPID" /etc/group | xargs)
|
||||||
ERRORS=$((ERRORS+1))
|
ERRORS=$((ERRORS+1))
|
||||||
crit "Duplicate GID ($GROUPID): ${USERS}"
|
crit "Duplicate GID ($GROUPID): ${GROUP}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -55,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="There is no duplicate usernames."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="There is no duplicate group names."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="There is no user .netrc files."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
FILENAME='.netrc'
|
FILENAME='.netrc'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="There is no user .forward files."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
FILENAME='.forward'
|
FILENAME='.forward'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,13 +12,14 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Ensure password fields are not empty in /etc/shadow."
|
||||||
|
|
||||||
FILE='/etc/shadow'
|
FILE='/etc/shadow'
|
||||||
|
|
||||||
# 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 accounts have an empty password"
|
info "Checking if accounts have an empty password"
|
||||||
RESULT=$(cat $FILE | awk -F: '($2 == "" ) { print $1 }')
|
RESULT=$($SUDO_CMD cat $FILE | awk -F: '($2 == "" ) { print $1 }')
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some accounts have an empty password"
|
crit "Some accounts have an empty password"
|
||||||
crit $RESULT
|
crit $RESULT
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="There is no user in shadow group (that can read /etc/shadow file)."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
FILEGROUP='/etc/group'
|
FILEGROUP='/etc/group'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Verify no legacy + entries exist in /etc/password file."
|
||||||
|
|
||||||
FILE='/etc/passwd'
|
FILE='/etc/passwd'
|
||||||
RESULT=''
|
RESULT=''
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Verify no legacy + entries exist in /etc/shadow file."
|
||||||
|
|
||||||
FILE='/etc/shadow'
|
FILE='/etc/shadow'
|
||||||
RESULT=''
|
RESULT=''
|
||||||
@ -19,7 +20,7 @@ RESULT=''
|
|||||||
# 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 accounts have a legacy password entry"
|
info "Checking if accounts have a legacy password entry"
|
||||||
if grep '^+:' $FILE -q; then
|
if $SUDO_CMD grep '^+:' $FILE -q; then
|
||||||
RESULT=$(grep '^+:' $FILE)
|
RESULT=$(grep '^+:' $FILE)
|
||||||
crit "Some accounts have a legacy password entry"
|
crit "Some accounts have a legacy password entry"
|
||||||
crit $RESULT
|
crit $RESULT
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Verify no legacy + entries exist in /etc/group file."
|
||||||
|
|
||||||
FILE='/etc/group'
|
FILE='/etc/group'
|
||||||
RESULT=''
|
RESULT=''
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,7 +11,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=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="Verify root is the only UID 0 account."
|
||||||
|
EXCEPTIONS=""
|
||||||
|
|
||||||
FILE='/etc/passwd'
|
FILE='/etc/passwd'
|
||||||
RESULT=''
|
RESULT=''
|
||||||
@ -19,23 +23,24 @@ RESULT=''
|
|||||||
# 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 accounts have uid 0"
|
info "Checking if accounts have uid 0"
|
||||||
RESULT=$(cat $FILE | awk -F: '($3 == 0 && $1!="root" ) { print $1 }')
|
RESULT=$(awk -F: '($3 == 0 && $1!="root" ) { print $1 }' "$FILE" )
|
||||||
|
FOUND_EXCEPTIONS=""
|
||||||
for ACCOUNT in $RESULT; do
|
for ACCOUNT in $RESULT; do
|
||||||
debug "Account : $ACCOUNT"
|
debug "Account : $ACCOUNT"
|
||||||
debug "Exceptions : $EXCEPTIONS"
|
debug "Exceptions : $EXCEPTIONS"
|
||||||
debug "echo \"$EXCEPTIONS\" | grep -q $ACCOUNT"
|
debug "echo \"$EXCEPTIONS\" | grep -qw $ACCOUNT"
|
||||||
if echo "$EXCEPTIONS" | grep -q $ACCOUNT; then
|
if echo "$EXCEPTIONS" | grep -qw "$ACCOUNT"; then
|
||||||
debug "$ACCOUNT is confirmed as an exception"
|
debug "$ACCOUNT is confirmed as an exception"
|
||||||
RESULT=$(sed "s!$ACCOUNT!!" <<< "$RESULT")
|
RESULT=$(sed "s!$ACCOUNT!!" <<< "$RESULT")
|
||||||
|
FOUND_EXCEPTIONS="$FOUND_EXCEPTIONS $ACCOUNT"
|
||||||
else
|
else
|
||||||
debug "$ACCOUNT not found in exceptions"
|
debug "$ACCOUNT not found in exceptions"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some accounts have uid 0"
|
crit "Some accounts have uid 0: $(tr '\n' ' ' <<< "$RESULT")"
|
||||||
crit $RESULT
|
|
||||||
else
|
else
|
||||||
ok "No account with uid 0 appart from root and potential configured exceptions"
|
ok "No account with uid 0 appart from root ${FOUND_EXCEPTIONS:+and configured exceptions:}$FOUND_EXCEPTIONS"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +52,8 @@ apply () {
|
|||||||
# This function will create the config file for this check with default values
|
# This function will create the config file for this check with default values
|
||||||
create_config() {
|
create_config() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
status=disabled
|
status=audit
|
||||||
# Put here valid accounts with uid 0 separated by spaces
|
# Put here valid accounts with uid 0 separated by spaces
|
||||||
EXCEPTIONS=""
|
EXCEPTIONS=""
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -71,8 +76,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure root path integrity."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Check permissions on user home directories."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ apply () {
|
|||||||
# This function will create the config file for this check with default values
|
# This function will create the config file for this check with default values
|
||||||
create_config() {
|
create_config() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
status=disabled
|
status=audit
|
||||||
# Put here user home directories exceptions, separated by spaces
|
# Put here user home directories exceptions, separated by spaces
|
||||||
EXCEPTIONS=""
|
EXCEPTIONS=""
|
||||||
EOF
|
EOF
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Check user dot file permissions."
|
||||||
|
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Check user permissions on .netrc file."
|
||||||
|
|
||||||
PERMISSIONS="600"
|
PERMISSIONS="600"
|
||||||
ERRORS=0
|
ERRORS=0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="/home partition with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/home"
|
PARTITION="/home"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="nodev option for removable media partitions."
|
||||||
|
|
||||||
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="noexec option for removable media partitions."
|
||||||
|
|
||||||
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="nosuid option for removable media partitions."
|
||||||
|
|
||||||
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,7 +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=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="/run/shm with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/run/shm"
|
PARTITION="/run/shm"
|
||||||
@ -20,6 +24,7 @@ OPTION="nodev"
|
|||||||
# 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 "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
@ -78,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=/opt/debian-cis/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,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,7 +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=2
|
HARDENING_LEVEL=2
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="/run/shm with nosuid option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/run/shm"
|
PARTITION="/run/shm"
|
||||||
@ -20,6 +24,7 @@ OPTION="nosuid"
|
|||||||
# 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 "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
@ -78,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=/opt/debian-cis/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,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -11,7 +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
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="/run/shm with noexec option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/run/shm"
|
PARTITION="/run/shm"
|
||||||
@ -20,6 +24,7 @@ OPTION="noexec"
|
|||||||
# 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 "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
@ -78,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=/opt/debian-cis/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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,11 +12,13 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Set sticky bit on world writable directories to prevent users from deleting or renaming files that are not owned by them."
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
info "Checking if setuid is set on world writable Directories"
|
info "Checking if setuid is set on world writable Directories"
|
||||||
RESULT=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
FS_NAMES=$(df --local -P | awk {'if (NR!=1) print $6'} )
|
||||||
|
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
||||||
if [ ! -z "$RESULT" ]; then
|
if [ ! -z "$RESULT" ]; then
|
||||||
crit "Some world writable directories are not on sticky bit mode!"
|
crit "Some world writable directories are not on sticky bit mode!"
|
||||||
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of cramfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_CRAMFS"
|
KERNEL_OPTION="CONFIG_CRAMFS"
|
||||||
MODULE_NAME="cramfs"
|
MODULE_NAME="cramfs"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of freevxfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_VXFS_FS"
|
KERNEL_OPTION="CONFIG_VXFS_FS"
|
||||||
MODULE_NAME="freevxfs"
|
MODULE_NAME="freevxfs"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/tmp on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/tmp"
|
PARTITION="/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of jffs2 filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
||||||
MODULE_NAME="jffs2"
|
MODULE_NAME="jffs2"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of hfs filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFS_FS"
|
KERNEL_OPTION="CONFIG_HFS_FS"
|
||||||
MODULE_FILE="hfs"
|
MODULE_FILE="hfs"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of hfsplus filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
||||||
MODULE_FILE="hfsplus"
|
MODULE_FILE="hfsplus"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of squashfs filesytems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_SQUASHFS"
|
KERNEL_OPTION="CONFIG_SQUASHFS"
|
||||||
MODULE_FILE="squashfs"
|
MODULE_FILE="squashfs"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable mounting of udf filesystems."
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_UDF_FS"
|
KERNEL_OPTION="CONFIG_UDF_FS"
|
||||||
MODULE_FILE="udf"
|
MODULE_FILE="udf"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable automounting of devices."
|
||||||
|
|
||||||
SERVICE_NAME="autofs"
|
SERVICE_NAME="autofs"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="/tmp partition with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/tmp"
|
PARTITION="/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="/tmp partition with nosuid option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/tmp"
|
PARTITION="/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/tmp partition with noexec option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/tmp"
|
PARTITION="/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/var on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var"
|
PARTITION="/var"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/var/tmp on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/tmp"
|
PARTITION="/var/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="/var/tmp partition with nodev option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/tmp"
|
PARTITION="/var/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="/var/tmp partition with nosuid option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/tmp"
|
PARTITION="/var/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/var/tmp partition with noexec option."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/tmp"
|
PARTITION="/var/tmp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/var/log on separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/log"
|
PARTITION="/var/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=4
|
HARDENING_LEVEL=4
|
||||||
|
DESCRIPTION="/var/log/audit on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/var/log/audit"
|
PARTITION="/var/log/audit"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="/home on a separate partition."
|
||||||
|
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/home"
|
PARTITION="/home"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="User and group root owner of grub bootloader config."
|
||||||
|
|
||||||
# Assertion : Grub Based.
|
# Assertion : Grub Based.
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=1
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Permissions for root only on grub bootloader config."
|
||||||
|
|
||||||
# Assertion : Grub Based.
|
# Assertion : Grub Based.
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Setting bootloader password to secure boot parameters."
|
||||||
|
|
||||||
FILE='/boot/grub/grub.cfg'
|
FILE='/boot/grub/grub.cfg'
|
||||||
USER_PATTERN="^set superusers"
|
USER_PATTERN="^set superusers"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Root password for single user mode."
|
||||||
|
|
||||||
FILE="/etc/shadow"
|
FILE="/etc/shadow"
|
||||||
PATTERN="^root:[*\!]:"
|
PATTERN="^root:[*\!]:"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,19 +12,36 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Restrict core dumps."
|
||||||
|
|
||||||
LIMIT_FILE='/etc/security/limits.conf'
|
LIMIT_FILE='/etc/security/limits.conf'
|
||||||
|
LIMIT_DIR='/etc/security/limits.d'
|
||||||
LIMIT_PATTERN='^\*[[:space:]]*hard[[:space:]]*core[[:space:]]*0$'
|
LIMIT_PATTERN='^\*[[:space:]]*hard[[:space:]]*core[[:space:]]*0$'
|
||||||
SYSCTL_PARAM='fs.suid_dumpable'
|
SYSCTL_PARAM='fs.suid_dumpable'
|
||||||
SYSCTL_EXP_RESULT=0
|
SYSCTL_EXP_RESULT=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_pattern_exist_in_file $LIMIT_FILE $LIMIT_PATTERN
|
SEARCH_RES=0
|
||||||
|
LIMIT_FILES=""
|
||||||
|
if $SUDO_CMD [ -d $LIMIT_DIR ]; then
|
||||||
|
for file in $($SUDO_CMD ls $LIMIT_DIR/*.conf 2>/dev/null); do
|
||||||
|
LIMIT_FILES="$LIMIT_FILES $LIMIT_DIR/$file"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
debug "Files to search $LIMIT_FILE $LIMIT_FILES"
|
||||||
|
for file in $LIMIT_FILE $LIMIT_FILES; do
|
||||||
|
does_pattern_exist_in_file $file $LIMIT_PATTERN
|
||||||
if [ $FNRET != 0 ]; then
|
if [ $FNRET != 0 ]; then
|
||||||
crit "$LIMIT_PATTERN not present in $LIMIT_FILE"
|
debug "$LIMIT_PATTERN not present in $file"
|
||||||
else
|
else
|
||||||
ok "$LIMIT_PATTERN present in $LIMIT_FILE"
|
ok "$LIMIT_PATTERN present in $file"
|
||||||
|
SEARCH_RES=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $SEARCH_RES = 0 ]; then
|
||||||
|
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
|
||||||
|
61
bin/hardening/4.2.3_install_syslog-ng.sh
Executable file
61
bin/hardening/4.2.3_install_syslog-ng.sh
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 4.2.3 Ensure Syslog-ng is installed (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Install syslog-ng to manage logs"
|
||||||
|
|
||||||
|
PACKAGE='syslog-ng'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
is_pkg_installed $PACKAGE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$PACKAGE is not installed!"
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is installed"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
is_pkg_installed $PACKAGE
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "$PACKAGE is installed"
|
||||||
|
else
|
||||||
|
crit "$PACKAGE is absent, installing it"
|
||||||
|
apt_install $PACKAGE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
. /etc/default/cis-hardening
|
||||||
|
fi
|
||||||
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
|
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
|
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
||||||
|
. $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
|
64
bin/hardening/4.2.4_logs_permissions.sh
Executable file
64
bin/hardening/4.2.4_logs_permissions.sh
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 4.2.4 Ensure permissions on all logfiles are configured (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Check permissions on logs (other has no permissions on any files and group does not have write or execute permissions on any file)"
|
||||||
|
|
||||||
|
DIR='/var/log'
|
||||||
|
PERMISSIONS='640'
|
||||||
|
OPTIONS=(-type f)
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "Logs in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
crit "Some logs in $DIR permissions were not set to $PERMISSIONS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "Logs in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
info "fixing $DIR logs permissions to $PERMISSIONS"
|
||||||
|
find $DIR -type f -exec chmod 0$PERMISSIONS {} \;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
. /etc/default/cis-hardening
|
||||||
|
fi
|
||||||
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
|
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
|
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
||||||
|
. $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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Enable NoExecute/ExecuteDisable to prevent buffer overflow attacks."
|
||||||
|
|
||||||
PATTERN='NX[[:space:]]\(Execute[[:space:]]Disable\)[[:space:]]protection:[[:space:]]active'
|
PATTERN='NX[[:space:]]\(Execute[[:space:]]Disable\)[[:space:]]protection:[[:space:]]active'
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ PATTERN='NX[[:space:]]\(Execute[[:space:]]Disable\)[[:space:]]protection:[[:spac
|
|||||||
nx_supported_and_enabled() {
|
nx_supported_and_enabled() {
|
||||||
if grep -q ' nx ' /proc/cpuinfo; then
|
if grep -q ' nx ' /proc/cpuinfo; then
|
||||||
# NX supported, but if noexec=off specified, it's not enabled
|
# NX supported, but if noexec=off specified, it's not enabled
|
||||||
if grep -qi 'noexec=off' /proc/cmdline; then
|
if $SUDO_CMD grep -qi 'noexec=off' /proc/cmdline; then
|
||||||
FNRET=1 # supported but disabled
|
FNRET=1 # supported but disabled
|
||||||
else
|
else
|
||||||
FNRET=0 # supported and enabled
|
FNRET=0 # supported and enabled
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Enable Randomized Virtual Memory Region Placement to prevent memory page exploits."
|
||||||
|
|
||||||
SYSCTL_PARAM='kernel.randomize_va_space'
|
SYSCTL_PARAM='kernel.randomize_va_space'
|
||||||
SYSCTL_EXP_RESULT=2
|
SYSCTL_EXP_RESULT=2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Disable prelink to prevent libraries compromission."
|
||||||
|
|
||||||
PACKAGE='prelink'
|
PACKAGE='prelink'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Activate AppArmor to enforce permissions control."
|
||||||
|
|
||||||
PACKAGE='apparmor'
|
PACKAGE='apparmor'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
|
||||||
|
|
||||||
PACKAGE='nis'
|
PACKAGE='nis'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure rsh server is not enabled. Recommended alternative : sshd (openssh-server)."
|
||||||
|
|
||||||
# Based on aptitude search '~Prsh-server'
|
# Based on aptitude search '~Prsh-server'
|
||||||
PACKAGES='rsh-server rsh-redone-server heimdal-servers'
|
PACKAGES='rsh-server rsh-redone-server heimdal-servers'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure rsh client is not installed, Recommended alternative : ssh."
|
||||||
|
|
||||||
# Based on aptitude search '~Prsh-client', exluding ssh-client OFC
|
# Based on aptitude search '~Prsh-client', exluding ssh-client OFC
|
||||||
PACKAGES='rsh-client rsh-redone-client heimdal-clients'
|
PACKAGES='rsh-client rsh-redone-client heimdal-clients'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure talk server is not enabled."
|
||||||
|
|
||||||
PACKAGES='inetutils-talkd talkd'
|
PACKAGES='inetutils-talkd talkd'
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure talk client is not installed."
|
||||||
|
|
||||||
PACKAGES='talk inetutils-talk'
|
PACKAGES='talk inetutils-talk'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure telnet server is not enabled. Recommended alternative : sshd (OpenSSH-server)."
|
||||||
|
|
||||||
# Based on aptitude search '~Ptelnet-server'
|
# Based on aptitude search '~Ptelnet-server'
|
||||||
PACKAGES='telnetd inetutils-telnetd telnetd-ssl krb5-telnetd heimdal-servers'
|
PACKAGES='telnetd inetutils-telnetd telnetd-ssl krb5-telnetd heimdal-servers'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure tftp-server is not enabled."
|
||||||
|
|
||||||
PACKAGES='tftpd tftpd-hpa atftpd'
|
PACKAGES='tftpd tftpd-hpa atftpd'
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Ensure xinetd is not enabled."
|
||||||
|
|
||||||
PACKAGES='openbsd-inetd xinetd rlinetd'
|
PACKAGES='openbsd-inetd xinetd rlinetd'
|
||||||
|
|
||||||
|
106
bin/hardening/5.2.17_sshd_login_grace_time.sh
Executable file
106
bin/hardening/5.2.17_sshd_login_grace_time.sh
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 5.2.17 Ensure SSH LoginGraceTime is set to one minute or less (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Set Login Grace Time for user login."
|
||||||
|
|
||||||
|
PACKAGE='openssh-server'
|
||||||
|
FILE='/etc/ssh/sshd_config'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
OPTIONS="LoginGraceTime=$SSHD_LOGIN_GRACE_TIME"
|
||||||
|
is_pkg_installed $PACKAGE
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$PACKAGE is not installed!"
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is installed"
|
||||||
|
for SSH_OPTION in $OPTIONS; do
|
||||||
|
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
||||||
|
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
||||||
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "$PATTERN is present in $FILE"
|
||||||
|
else
|
||||||
|
crit "$PATTERN is not present in $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
is_pkg_installed $PACKAGE
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "$PACKAGE is installed"
|
||||||
|
else
|
||||||
|
crit "$PACKAGE is absent, installing it"
|
||||||
|
apt_install $PACKAGE
|
||||||
|
fi
|
||||||
|
for SSH_OPTION in $OPTIONS; do
|
||||||
|
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
||||||
|
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
||||||
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "$PATTERN is present in $FILE"
|
||||||
|
else
|
||||||
|
warn "$PATTERN is not present in $FILE, adding it"
|
||||||
|
does_pattern_exist_in_file $FILE "^$SSH_PARAM"
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
add_end_of_file $FILE "$SSH_PARAM $SSH_VALUE"
|
||||||
|
else
|
||||||
|
info "Parameter $SSH_PARAM is present but with the wrong value -- Fixing"
|
||||||
|
replace_in_file $FILE "^$SSH_PARAM[[:space:]]*.*" "$SSH_PARAM $SSH_VALUE"
|
||||||
|
fi
|
||||||
|
/etc/init.d/ssh reload
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will create the config file for this check with default values
|
||||||
|
create_config() {
|
||||||
|
cat <<EOF
|
||||||
|
status=audit
|
||||||
|
# In seconds, value of LoginGraceTime
|
||||||
|
# Settles sshd login grace time
|
||||||
|
SSHD_LOGIN_GRACE_TIME=60
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
if [ -z $SSHD_LOGIN_GRACE_TIME ]; then
|
||||||
|
crit "SSHD_LOGIN_GRACE_TIME is not set, please edit configuration file"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
. /etc/default/cis-hardening
|
||||||
|
fi
|
||||||
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
|
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
|
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
||||||
|
. $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
|
88
bin/hardening/5.2.2_ssh_host_private_keys_perm_ownership.sh
Executable file
88
bin/hardening/5.2.2_ssh_host_private_keys_perm_ownership.sh
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 5.2.2 Ensure permissions on SSH private host key files are configured (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Checking permissions and ownership to root 600 for ssh private keys. "
|
||||||
|
|
||||||
|
DIR='/etc/ssh'
|
||||||
|
PERMISSIONS='600'
|
||||||
|
USER='root'
|
||||||
|
GROUP='root'
|
||||||
|
OPTIONS=(-xdev -type f -name "ssh_host_*_key")
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
have_files_in_dir_correct_ownership $DIR $USER $GROUP OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct ownership"
|
||||||
|
else
|
||||||
|
crit "Some $DIR SSH public keys ownership were not set to $USER:$GROUP"
|
||||||
|
fi
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
crit "Some $DIR SSH public keys permissions were not set to $PERMISSIONS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
|
||||||
|
have_files_in_dir_correct_ownership $DIR $USER $GROUP OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct ownership"
|
||||||
|
else
|
||||||
|
warn "fixing $DIR SSH public keys ownership to $USER:$GROUP"
|
||||||
|
find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chown root:root {} \;
|
||||||
|
fi
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
info "fixing $DIR SSH public keys permissions to $PERMISSIONS"
|
||||||
|
find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chmod 0600 {} \;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
does_user_exist $USER
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$USER does not exist"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
does_group_exist $GROUP
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$GROUP does not exist"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
. /etc/default/cis-hardening
|
||||||
|
fi
|
||||||
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
|
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
|
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
||||||
|
. $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
|
88
bin/hardening/5.2.3_ssh_host_public_keys_perm_ownership.sh
Executable file
88
bin/hardening/5.2.3_ssh_host_public_keys_perm_ownership.sh
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 5.2.3 Ensure permissions on SSH public host key files are configured (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
HARDENING_LEVEL=1
|
||||||
|
DESCRIPTION="Checking permissions and ownership to root 644 for ssh public keys. "
|
||||||
|
|
||||||
|
DIR='/etc/ssh'
|
||||||
|
PERMISSIONS='644'
|
||||||
|
USER='root'
|
||||||
|
GROUP='root'
|
||||||
|
OPTIONS=(-xdev -type f -name "ssh_host_*_key.pub")
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit () {
|
||||||
|
have_files_in_dir_correct_ownership $DIR $USER $GROUP OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct ownership"
|
||||||
|
else
|
||||||
|
crit "Some $DIR SSH public keys ownership were not set to $USER:$GROUP"
|
||||||
|
fi
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
crit "Some $DIR SSH public keys permissions were not set to $PERMISSIONS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply () {
|
||||||
|
|
||||||
|
have_files_in_dir_correct_ownership $DIR $USER $GROUP OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct ownership"
|
||||||
|
else
|
||||||
|
warn "fixing $DIR SSH public keys ownership to $USER:$GROUP"
|
||||||
|
find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chown root:root {} \;
|
||||||
|
fi
|
||||||
|
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
|
||||||
|
if [ $FNRET = 0 ]; then
|
||||||
|
ok "SSH public keys in $DIR have correct permissions"
|
||||||
|
else
|
||||||
|
info "fixing $DIR SSH public keys permissions to $PERMISSIONS"
|
||||||
|
find /etc/ssh -xdev -type f -name 'ssh_host_*_key.pub' -exec chmod 0644 {} \;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
does_user_exist $USER
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$USER does not exist"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
does_group_exist $GROUP
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
|
crit "$GROUP does not exist"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Source Root Dir Parameter
|
||||||
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
|
. /etc/default/cis-hardening
|
||||||
|
fi
|
||||||
|
if [ -z "$CIS_ROOT_DIR" ]; then
|
||||||
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
|
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
|
if [ -r $CIS_ROOT_DIR/lib/main.sh ]; then
|
||||||
|
. $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,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure chargen debugging network service is not enabled."
|
||||||
|
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
PATTERN='^chargen'
|
PATTERN='^chargen'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure daytime debugging network service is not enabled."
|
||||||
|
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
PATTERN='^daytime'
|
PATTERN='^daytime'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure echo debugging network service is not enabled."
|
||||||
|
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
PATTERN='^echo'
|
PATTERN='^echo'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure discard debugging network service is not enabled."
|
||||||
|
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
PATTERN='^discard'
|
PATTERN='^discard'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
DESCRIPTION="Ensure time debugging network service is not enabled."
|
||||||
|
|
||||||
FILE='/etc/inetd.conf'
|
FILE='/etc/inetd.conf'
|
||||||
PATTERN='^time'
|
PATTERN='^time'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# CIS Debian 7/8 Hardening
|
# CIS Debian Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -12,6 +12,7 @@ set -e # One error, it's over
|
|||||||
set -u # One variable unset, it's over
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
DESCRIPTION="Ensure HTTP server is not enabled."
|
||||||
HARDENING_EXCEPTION=http
|
HARDENING_EXCEPTION=http
|
||||||
|
|
||||||
# Based on aptitude search '~Phttpd'
|
# Based on aptitude search '~Phttpd'
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user