Compare commits

...

84 Commits
v1.1-1 ... v1.3

Author SHA1 Message Date
20dacdf6c7 CHORE: change in version numbering 2019-08-28 14:59:51 +02:00
19ee1cabf8 Update changelog 2019-08-28 12:35:58 +02:00
5a1a70bbd3 FIX(test/10.2): backup and restore /etc/passwd after test 2019-08-28 12:30:13 +02:00
a4969e6ba6 IMP(99.3.1): improve check with disabled passwords 2019-08-28 11:49:01 +02:00
96f3b74334 FIX(10.2): improve test to check multiple login shells
fix IFS bug
add test
2019-08-28 11:47:49 +02:00
89cf484cb9 fix(99.4): do not stderr iptables warning on buster 2019-08-14 10:36:25 +02:00
13783423c2 changelog: update changelog
Conflicts:
	debian/changelog
2019-04-04 16:27:17 +02:00
b2f7460977 changelog: update to 1.2-4 2019-04-04 16:27:17 +02:00
71f97062d7 FIX(99.1): remove dot in files to search
Apply shellcheck recommendations
2019-04-04 12:18:15 +02:00
1ec77dbb56 FIX(13.15): fix code that did not show duplicated group
Add tests
Apply shellcheck recommendations
2019-03-28 17:51:02 +01:00
8f87d75293 FIX(99.5.4): fix regex to allow other authkey options than "from" 2019-03-15 18:17:48 +01:00
41e3402b10 FIX(batch): sed \n to space in batch echo 2019-03-19 10:38:41 +01:00
02673826a0 FIX(8.2.x): fix grep and find in audit scripts 2019-03-18 16:19:05 +01:00
d5d5a39109 FIX(nbsp): remove nbsp for missing file 2019-03-12 10:08:28 +01:00
1bac756dcb FIX(nbsp): remove non breakable spaces that caused Puppet to warn 2019-03-12 09:58:35 +01:00
75f6cce7f5 Debian release 1.2-3 2019-03-06 08:33:18 +01:00
be1ad3e581 IMP(99.5.4): add conf to check only listed users 2019-03-05 10:49:45 +01:00
b4b7524156 Update changelog 2019-03-01 14:41:28 +01:00
455e58899d FIX(8.2.4): script crashed when touching a logfile in subdir of /var/log
Treating filename to check if it is in a /var/log subdirectory and
creates needed subdirectories
2019-03-01 13:08:07 +01:00
9ada868f43 IMP(8.2.4): add exceptions in check and apply
Apply shellcheck recommendations
2019-03-01 12:12:42 +01:00
4bddd8ee8b IMP(8.2.5): follow symlinks in find 2019-03-01 10:00:35 +01:00
81dc308677 FIX(8.3.2): add $SUDO_CMD to find 2019-02-28 17:52:47 +01:00
db4dc4d598 FIX(8.2.5): grep: x is a directory 2019-02-28 16:41:41 +01:00
a9af957f7a Debian release 1.2-2 2019-02-28 13:03:09 +01:00
0a6f8bdba6 FEAT(2.6.x): retrieve actual partition in case if bind mount 2019-02-28 10:14:00 +01:00
d05ffaf9d5 CHORE: replace == with = that is bash syntax 2019-02-26 15:23:23 +01:00
41ccd5655a CHORE(test 8.2.5): removed useless cleanup line 2019-02-26 15:19:05 +01:00
e46a85dc6c FIX(9.3.2): dismiss test for initial after e7d9977
LogLevel not consistent at install time between debian versions
Easier to dismiss this check's result at the first step
2019-02-26 15:16:06 +01:00
1caf0f489a FIX(12.1x): fix tests exception for mail after da6acb0b
Installing syslog-ng in Dockerfile added some suid/sgid binaries that
needed to be treated as exception in test scenarii
2019-02-26 15:08:21 +01:00
de7dfe5956 CHORE(2.1x): use "readlink -e" instead of custom func
Removed get_partition_from_symlink()
2019-02-26 15:06:51 +01:00
8031c388c6 IMP(9.3.2): Comply with Debian9 guide: verbose ssh loglevel 2019-02-25 15:16:02 +01:00
7b8e359590 IMP(13.13): improve exception detection 2019-02-25 10:33:15 +01:00
f7f2f614aa IMP(9.3.2): Add custom configuration management
Add create_config to allow user to customize their conf

Improve tests
Apply shellcheck recommendations
2019-02-22 15:40:01 +01:00
605a768fe1 IMP(13.13): Add exceptions for home directories not owned by owner
Fill tests

Apply shellcheck recommendations
2019-02-22 15:22:58 +01:00
80a1146af7 IMP(8.2.5): find multiline pattern in files (syslog)
Add func to find pattern in file that spreads over multiple lines
The func will remove commented lines (that begin with '#')
and consider the file as one long line.
Thus, this is not possible to look for pattern at beginning of line
with this func ('^' and '$')

Improved pattern in 8.2.5

Add syslog-ng to installed dependencies in Dockerfiles

Fixed multifile arguments when looking for pattern that got broken
in d2bbf754 due to "nocase" and _does_pattern_exist_in_file wrapper
Please note that you can only look for pattern in ONE FILE at once
Fixed 8.2.5 and 8.3.2 with for loop on files and 'FOUND' flag
You now need to specify each and every file to look for or embed a
'find' command as follow :
`FILES="$SYSLOG_BASEDIR/syslog-ng.conf $(find $SYSLOG_BASEDIR/conf.d/)"`

Improved test files
Applied shellcheck recommendations
2019-02-22 12:39:41 +01:00
7408216957 IMP(2.1x): Retrieve actual partition when symlink
Add function to retrieve actual partition from symlink in lib/utils.sh
Using this func in all 3 audit scripts

Improved tests to test this func

Apply shellcheck recommendations
Trim trailing spaces
2019-02-22 12:22:14 +01:00
217895dfe6 FIX(tests): change sed to audit in test skeleton after 81f9348 2019-02-21 18:07:21 +01:00
bc5809f92e FIX CONFIG_AUDIT test 2019-02-21 11:15:48 +01:00
22d223fece changelog: Update to 1.2-2 2019-02-19 15:40:27 +01:00
ac76942ca7 CHORE(tests): cleanup test files 2019-02-18 18:08:19 +01:00
cf42666833 FIX(tests): change sed in conf file disabled->audit following d6172ad
In test cases, changed in sed command "disabled" to "audit" to enable
apply part, following this commit
d6172ad Change default status disabled -> audit when no conf file

 5f28036 - Change default status to audit for file with custom
  `create_config` (Charles Herlin Thu Feb 14 14:33:21 2019 +0100)
2019-02-15 17:42:17 +01:00
6cbe8f572f CHORE(tests): Cleanup test files 2019-02-18 18:10:22 +01:00
982301d395 FIX(tests): improve test cases and cleanup 2019-02-18 17:25:04 +01:00
d18f5edfba FIX(99.2): add missing $SUDO_CMD 2019-02-15 16:56:54 +01:00
6ede832685 FIX(sudoers): add missing test 2019-02-15 16:45:03 +01:00
0c17da012f FIX(test): catch return values when retval differs to avoid runtime error 2019-02-15 16:27:54 +01:00
6afed4eedb Add test stub for all audit checks, to tests root/sudo consistency 2019-02-14 18:10:46 +01:00
bad32f8078 Rename dismiss_test to skip_tests since test won't even run in this case 2019-02-14 17:52:45 +01:00
47a818b832 dismiss_count will still report failed root/sudo consistency failure
Add comment to dismiss_tests
2019-02-14 17:44:13 +01:00
fc88194eca properly purge remaining config files on purge 2019-02-14 14:22:55 +01:00
2b2a91a564 Change default status to audit for file with custom create_config 2019-02-14 14:33:21 +01:00
5c313c8f31 Change default status disabled -> audit when no conf file 2019-02-06 15:26:41 +01:00
11305a0980 FIX package name in example-cron.d-entry 2019-02-14 12:21:17 +01:00
1586dae0c5 Improve user management in test cases 2019-02-14 11:15:51 +01:00
1281860401 IMP: enhance scripts that check duplicate UID
Add exception handling in 13.14_check_duplicate_uid
Clarifies output message and explicitly displays found exceptions
Add tests
Apply shellcheck recommendation

modified:   bin/hardening/13.14_check_duplicate_uid.sh
modified:   bin/hardening/13.5_find_0_uid_non_root_account.sh
new file:   tests/hardening/13.14_check_duplicate_uid.sh
new file:   tests/hardening/13.5_find_0_uid_non_root_account.sh
2019-02-13 16:07:06 +01:00
09ae131de9 FIX: usage if no RUN_MODE, fix only that used to run too many checks
If no RUN_MODE passed as arguments, display usage and exits

Fix --only option to run only specific check
Found bug that used to run 2.2 and 2.24 when launching --only 2.24
2019-02-13 17:11:28 +01:00
1dd630e65b changelog: Update to 1.2-1 (go cds go) 2019-02-12 11:41:05 +01:00
810fee4c8f Migrate generic checks from secaudit to cis-hardening
new file:   99.3.1_acc_shadow_sha512.sh
new file:   99.3.2_acc_sudoers_no_all.sh
new file:   99.4_net_fw_default_policy_drop.sh
new file:   99.5.1_ssh_auth_pubk_only.sh
new file:   99.5.2.1_ssh_cry_kex.sh
new file:   99.5.2.2_ssh_cry_mac.sh
new file:   99.5.2.3_ssh_cry_rekey.sh
new file:   99.5.3_ssh_disable_features.sh
new file:   99.5.4_ssh_keys_from.sh
new file:   99.5.5_ssh_strict_modes.sh
new file:   99.5.6_ssh_sys_accept_env.sh
new file:   99.5.7_ssh_sys_no_legacy.sh
new file:   99.5.8_ssh_sys_sandbox.sh
new file:   99.5.9_ssh_log_level.sh

Fix descriptions in comment section for 99.* secaudit checks

Remove duplicated legacy services that are already taken care of by vanilla cis

Enable custom configuration of checks in config-file, no more hard coded conf
Add test to disable check if debian version is too old
Add excused IPs while checking "from" field of authorized_keys
Escaping dots in IPs
Manage Kex for different debian versions
Add tests for generic checks and add apply for ssh config
Apply shellcheck recommendations on audit/hardening scripts
Update script to check for allowed IPs only, remove bastion related
Fill `apply` func for ssh config related scripts
Add and update tests scenarii

Disable shellcheck test for external source 1091

As of today, the entire project is not shellcheck compliant, I prefer
disabling the test that warns about not finding external source (that
arent compliant). I will enable it again when the project library will
be shellchecked
https://github.com/koalaman/shellcheck/wiki/SC1091

Refactor password policy check with one check by feature

Previous file will now only look for bad passwords in /etc/shadow
I added two checks that look for the compliant configuration lines in
conf files /etc/logins.defs and /etc/pam.d/common-passwords

FIX: merge chained sed and fix regex

FIX: update regex to capture more output
FIX: fix pattern to ignore commented lines, add apply

Also add tests to ensure that commented lines are not detected as valid
configuration

CHORE: cleanup test situation with file and users removal
IMP: add case insensitive option when looking for patterns in files
CHORE: removed duplicated line in test file
2017-12-20 15:14:30 +01:00
ba93159a00 Add crontab 2019-02-08 10:35:35 +01:00
d014405e1f FIX: add becho to send batch output to syslog too
becho stands for batch echo
formats the log line for syslog

Also logs audit summary into syslog (in batch mode only)
2019-02-06 17:25:16 +01:00
6cea326921 Update debian 7/8/9 in help files and remove in generic scripts 2019-02-06 15:19:14 +01:00
58cb064919 IMP: sort find result by name and version to ease reading 2019-02-01 09:42:12 +01:00
3ff3bb209f FIX: remove "exernal-sources" option when running shellcheck
This option caused some checks to be ignored
2019-01-30 16:00:45 +01:00
507eadc3cb Add shellcheck recommendation 2019-01-30 12:38:39 +01:00
aa3983c6d0 FIX: add way of completely skipping test that bugged with jessie
Tests are stored in a bash indexed array.
Bash on debian8 does not support arrays declaration and if there was no
registered tests, the array variable was seen as undefined.
With this way of completely dismissing the test suite, the problem is
fixed
2019-01-30 11:06:49 +01:00
2dd753e5e7 Fix typo in test skeleton and add shellcheck comment 2019-01-25 14:16:47 +01:00
bf3bfc2a91 FIX: bug crashing for undeclared variable when consitency
checks failed
2019-01-25 10:33:38 +01:00
a1a4295dcf IMP: tests readability and runtime error handling
Change describe display to add underline in order to make it more
noticeable in a stream of logs
Add a `fatal` message when catching a runtime error (until
`$totalerrors` has not been modified yet)
2019-01-24 15:53:09 +01:00
e8ae07c2e8 IMP: new tag in file to tell that the script should pass shellcheck
The `# run-shellchek` tag must be placed in the first 10 lines of the
file
2019-01-24 11:11:08 +01:00
13c88c7da2 FIX: tests return value that was always 255
Return values tells the number of failed tests up to 254
255 being the return value for runtime errors
2019-01-23 12:54:33 +01:00
9ba0361be0 FIX: quotes in find command, misinterpreted shellcheck advice 2019-01-23 16:55:48 +01:00
71b70a2b8c FEAT: Add sudo_wrapper to catch unauthorized sudo commands
As for now, if a sudo command was not allowed, check might sometimes
pass, resulting compliant state even if it actually is not.
Sudo wrapper first checks wether command is allowed before running it,
otherwise issues a crit message, setting check as not compliant

Fix script to make sudo_wrapper work, split "find" lines
Fix quotes in $@ and $* when running sudo command

Fixed quotes and curly braces with shellcheck report
2018-03-16 12:06:56 +01:00
176fb96fa4 FEAT: automate shellcheck test with docker
IMP: search for all .sh files to shellcheck
If no file is passed as argument, shellchek will be run on all
.sh files

Fix dockerfile location and expand full shellcheck options
2019-01-17 12:39:15 +01:00
c51a8ee9b8 FIX: sed that was too greedy
Used to sed 's!/usr/bin/su!!' /usr/bin/sudo leaving only "do"
that lead to misinterpreting result

Change algorithm to avoid partial sed in the result list
Now the not compliant list is built out of the find results
instead of items being removed from them.
Allow better control of grep inside this list.

Chore: apply shellcheck recommendations
2019-01-02 13:02:02 +01:00
e72c7aae15 Add missing /usr/bin/su 2019-01-03 11:21:51 +01:00
8e6618eedf FIX: add /usr/bin/* path for suid/guid allowed binaries
Debian is still migrating /bin to /usr/bin so I added both path to the
allowed ones

 * mount
 * umount
 * ping
 * ping6
 * unix_chkpwd
2019-01-02 17:03:29 +01:00
67df4da781 Adding batch mode to output just one line of text (no colors) in order to be parsed by computer tools
Adding DESCRIPTION field in tests and [INFO] DESCRIPTION in main
Update README with --batch mode info
Add --batch mode in hardening.sh

Change summary to make it oneliner when batch mode
AUDIT_SUMMARY PASSED_CHECKS:95 RUN_CHECKS:191 TOTAL_CHECKS_AVAIL:191 CONFORMITY_PERCENTAGE:49.74
2017-10-31 17:44:15 +01:00
8a7f9ddad5 Change from CIS reco and only warn (no crit) if logfile does not exist 2018-03-22 18:17:17 +01:00
863adc9c84 IMP(test): Add feature to run functional tests in docker instance
Add usecase in basename
Add test files for checks with find command
Always show logs
FIX: run void script to generate config and avoid sed failure
Update README with functional test description
Add skeleton for functional test
Add argument to launch only specific test suite
Add support for debian8 and compulsory mention of debian version at
launch
Improve README
Simplify test file syntax to avoid copy/paste mistake
Add script that runs tests on all debian targets
Improve run_all_target script with nowait and nodel options
Add dockerfile for Buster pre-version
Chore: Use getopt for options and reviewed code by shellcheck
Add trap to ensure cleanup on exit/interrupt
Remove quotes that lead to `less` misinterpretation of the filenames
Set `local` for variables inside `test_audit` func
Move functional assertion functions to dedicated file
Add cleanup for logs and containers
Improve cleanup, and now exits
Apply shellcheck recommendations
FIX: allow script to be run from anywhere (dirname $0)

 Changes to be committed:
	modified:   README.md
	new file:   src/skel.test
	new file:   tests/docker/Dockerfile.debian10_20181226
	new file:   tests/docker/Dockerfile.debian8
	new file:   tests/docker/Dockerfile.debian9
	new file:   tests/docker_build_and_run_tests.sh
	new file:   tests/hardening/12.10_find_suid_files.sh
	new file:   tests/hardening/12.11_find_sgid_files.sh
	new file:   tests/hardening/12.7_find_world_writable_file.sh
	new file:   tests/hardening/12.8_find_unowned_files.sh
	new file:   tests/hardening/12.9_find_ungrouped_files.sh
	new file:   tests/hardening/2.17_sticky_bit_world_writable_folder.sh
	new file:   tests/launch_tests.sh
	new file:   tests/lib.sh
	new file:   tests/run_all_targets.sh
2018-12-24 14:12:59 +01:00
4fc79c133f Improve --only option to perform only specified test and no other lookalike test number
Before modification "--only 8.2.1" performed tests 8.2.1 and 2.1
2018-03-15 12:03:10 +01:00
7077554bca Redirect stderr to avoid printing "no such file" error 2018-03-19 18:06:47 +01:00
76abf8da36 resolve #SOC-30 Also check /etc/security/limits.d/ for core dump limit 2018-02-12 15:37:12 +01:00
51f589923d Fix SOC-28, add test if file exist, if not issue error 2018-02-09 13:49:38 +01:00
b1f85d3f99 Add sudo management in main and utils
* perform readonly checks as a regular user
    * sudo -n is used for checks requiring root privileges
    * increase accountability by providing log of individual access to sensitive files
2017-11-09 15:45:42 +01:00
440 changed files with 6078 additions and 475 deletions

View File

@ -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.
```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
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
**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
$ ./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

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
# Authors : Thibault Dewailly, OVH <thibault.dewailly@corp.ovh.com>
#
@ -22,6 +22,8 @@ AUDIT_ALL=0
AUDIT_ALL_ENABLE_PASSED=0
ALLOW_SERVICE_LIST=0
SET_HARDENING_LEVEL=0
SUDO_MODE=''
BATCH_MODE=''
usage() {
cat << EOF
@ -83,6 +85,18 @@ OPTIONS:
The test number is the numbered prefix of the script,
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
exit 0
}
@ -124,6 +138,13 @@ while [[ $# > 0 ]]; do
TEST_LIST[${#TEST_LIST[@]}]="$2"
shift
;;
--sudo)
SUDO_MODE='--sudo'
;;
--batch)
BATCH_MODE='--batch'
LOGLEVEL=ok
;;
-h|--help)
usage
;;
@ -134,6 +155,11 @@ while [[ $# > 0 ]]; do
shift
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
if [ -r /etc/default/cis-hardening ]; then
. /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/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" = 1 ] ; then
declare -a HARDENING_EXCEPTIONS_LIST
@ -188,23 +216,23 @@ 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 ?
SCRIPT_PREFIX=$(grep -Eo '^[0-9.]+' <<< "$(basename $SCRIPT)")
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
continue
fi
fi
info "Treating $SCRIPT"
if [ $AUDIT = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit"
$SCRIPT --audit
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE $BATCH_MODE"
$SCRIPT --audit $SUDO_MODE $BATCH_MODE
elif [ $AUDIT_ALL = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all"
$SCRIPT --audit-all
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
elif [ $AUDIT_ALL_ENABLE_PASSED = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all"
$SCRIPT --audit-all
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE" $BATCH_MODE
$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE
elif [ $APPLY = 1 ]; then
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT"
$SCRIPT
@ -222,7 +250,7 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
sed -i -re 's/^status=.+/status=enabled/' $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg
info "Status set to enabled in $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg"
fi
;;
;;
1)
debug "$SCRIPT failed"
FAILED_CHECKS=$((FAILED_CHECKS+1))
@ -234,19 +262,32 @@ for SCRIPT in $(ls $CIS_ROOT_DIR/bin/hardening/*.sh -v); do
esac
TOTAL_CHECKS=$((TOTAL_CHECKS+1))
done
TOTAL_TREATED_CHECKS=$((TOTAL_CHECKS-DISABLED_CHECKS))
printf "%40s\n" "################### SUMMARY ###################"
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s %.2f %%\n" "Enabled Checks Percentage :" "$( echo "($TOTAL_TREATED_CHECKS/$TOTAL_CHECKS) * 100" | bc -l)"
if [ $TOTAL_TREATED_CHECKS != 0 ]; then
printf "%30s %.2f %%\n" "Conformity Percentage :" "$( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l)"
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 "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0
printf "%40s\n" "################### SUMMARY ###################"
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
printf "%30s %s\n" "Total Runned Checks :" "$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS"
printf "%30s %.2f %%\n" "Enabled Checks Percentage :" "$( echo "($TOTAL_TREATED_CHECKS/$TOTAL_CHECKS) * 100" | bc -l)"
if [ $TOTAL_TREATED_CHECKS != 0 ]; then
printf "%30s %.2f %%\n" "Conformity Percentage :" "$( echo "($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100" | bc -l)"
else
printf "%30s %s %%\n" "Conformity Percentage :" "N.A" # No check runned, avoid division by 0
fi
fi

View File

@ -1,7 +1,7 @@
#!/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
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
audit () {

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Set password expiration days."
PACKAGE='login'
OPTIONS='PASS_MAX_DAYS=90'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Set password change minimum number of days."
PACKAGE='login'
OPTIONS='PASS_MIN_DAYS=7'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Set password expiration warning days."
PACKAGE='login'
OPTIONS='PASS_WARN_AGE=7'

View File

@ -1,7 +1,7 @@
#!/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
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'
RESULT=''
ACCEPTED_SHELLS_GREP=''
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Checking if admin accounts have a login shell different than $SHELL"
RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 && $7!="/usr/sbin/nologin" && $7!="/bin/false") {print}')
shells_to_grep_helper
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'
for LINE in $RESULT; do
debug "line : $LINE"
@ -35,8 +40,9 @@ audit () {
debug "$ACCOUNT not found in exceptions"
fi
done
IFS=$IFS_BAK
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"
else
ok "All admin accounts deactivated"
@ -45,7 +51,8 @@ audit () {
# This function will be called if the script status is on enabled mode
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'
for LINE in $RESULT; do
debug "line : $LINE"
@ -60,22 +67,29 @@ apply () {
debug "$ACCOUNT not found in exceptions"
fi
done
IFS=$IFS_BAK
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"
for USER in $( echo "$RESULT" | cut -d: -f 1 ); do
info "Setting $SHELL as $USER login shell"
usermod -s $SHELL $USER
info "Setting $SHELL_TO_APPLY as $USER login shell"
usermod -s "$SHELL_TO_APPLY" "$USER"
done
else
ok "All admin accounts deactivated, nothing to apply"
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
create_config() {
cat <<EOF
status=disabled
status=audit
# Put here your exceptions concerning admin accounts shells separated by spaces
EXCEPTIONS=""
EOF

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Set default group for root account to 0."
USER='root'
EXPECTED_GID='0'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Set default mask for users to 077."
USER='root'
PATTERN='umask 077'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Lock inactive user accounts."
# This function will be called if the script status is on enabled / audit mode
audit () {

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Checking root ownership and 644 permissions on banner files : /etc/motd|issue|issue.net ."
PERMISSIONS='644'
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
audit () {
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
if [ $FNRET = 0 ]; then
ok "$FILE has correct ownership"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Remove OS information from Login Warning Banners."
FILES='/etc/motd /etc/issue /etc/issue.net'
PATTERN='(\\v|\\r|\\m|\\s)'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Set graphical warning banner."
# This function will be called if the script status is on enabled / audit mode
audit () {

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,21 +11,27 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
DESCRIPTION="Find SUID system executables."
# This function will be called if the script status is on enabled / audit mode
audit () {
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)
for BINARY in $RESULT; do
if grep -q $BINARY <<< "$EXCEPTIONS"; then
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }' )
# shellcheck disable=2086
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -4000 -print)
BAD_BINARIES=""
for BINARY in $FOUND_BINARIES; do
if grep -qw "$BINARY" <<< "$EXCEPTIONS"; then
debug "$BINARY is confirmed as an exception"
RESULT=$(sed "s!$BINARY!!" <<< $RESULT)
else
BAD_BINARIES="$BAD_BINARIES $BINARY"
fi
done
if [ ! -z "$RESULT" ]; then
if [ ! -z "$BAD_BINARIES" ]; then
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"
else
ok "No unknown suid files found"
@ -40,9 +46,9 @@ apply () {
# This function will create the config file for this check with default values
create_config() {
cat <<EOF
status=disabled
status=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
}
@ -63,8 +69,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,21 +11,27 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
DESCRIPTION="Find SGID system executables."
# This function will be called if the script status is on enabled / audit mode
audit () {
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)
for BINARY in $RESULT; do
if grep -q $BINARY <<< "$EXCEPTIONS"; then
FS_NAMES=$(df --local -P | awk '{ if (NR!=1) print $6 }' )
# shellcheck disable=2086
FOUND_BINARIES=$( $SUDO_CMD find $FS_NAMES -xdev -type f -perm -2000 -print)
BAD_BINARIES=""
for BINARY in $FOUND_BINARIES; do
if grep -qw "$BINARY" <<< "$EXCEPTIONS"; then
debug "$BINARY is confirmed as an exception"
RESULT=$(sed "s!$BINARY!!" <<< $RESULT)
else
BAD_BINARIES="$BAD_BINARIES $BINARY"
fi
done
if [ ! -z "$RESULT" ]; then
if [ ! -z "$BAD_BINARIES" ]; then
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"
else
ok "No unknown sgid files found"
@ -40,9 +46,9 @@ apply () {
# This function will create the config file for this check with default values
create_config() {
cat <<EOF
status=disabled
status=audit
# 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
}
@ -64,8 +70,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/passwd to 644."
FILE='/etc/passwd'
PERMISSIONS='644'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/shadow to 640."
FILE='/etc/shadow'
PERMISSIONS='640'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check permissions on /etc/group to 644."
FILE='/etc/group'
PERMISSIONS='644'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on /etc/passwd."
FILE='/etc/passwd'
USER='root'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on etc/shadow."
FILE='/etc/shadow'
USER='root'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Check user/group to root on /etc/group."
FILE='/etc/group'
USER='root'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Find world writable files."
# This function will be called if the script status is on enabled / audit mode
audit () {
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
crit "Some world writable files are present"
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -12,13 +12,15 @@ set -e # One error, it's over
set -u # One variable unset, it's over
HARDENING_LEVEL=2
DESCRIPTION="Find un-owned files and directories."
USER='root'
# This function will be called if the script status is on enabled / audit mode
audit () {
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'} )
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nouser -print 2>/dev/null)
if [ ! -z "$RESULT" ]; then
crit "Some unowned files are present"
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -12,13 +12,15 @@ set -e # One error, it's over
set -u # One variable unset, it's over
HARDENING_LEVEL=2
DESCRIPTION="Find un-grouped files and directories."
GROUP='root'
# This function will be called if the script status is on enabled / audit mode
audit () {
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'} )
RESULT=$( $SUDO_CMD find $FS_NAMES -xdev -nogroup -print 2>/dev/null)
if [ ! -z "$RESULT" ]; then
crit "Some ungrouped files are present"
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="No user's .rhosts file."
ERRORS=0
FILENAME=".rhosts"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="There is no group in /etc/passwd that is not in /etc/group."
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Users are assigned valid home directories."
ERRORS=0

View File

@ -1,7 +1,8 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,45 +12,68 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="Check user home directory ownership."
EXCEPTIONS=""
ERRORS=0
# This function will be called if the script status is on enabled / audit mode
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
debug "Working on $LINE"
USER=$(awk -F: {'print $1'} <<< $LINE)
USERID=$(awk -F: {'print $2'} <<< $LINE)
DIR=$(awk -F: {'print $3'} <<< $LINE)
if [ $USERID -ge 500 -a -d "$DIR" -a $USER != "nfsnobody" ]; then
USER=$(awk -F: '{print $1}' <<< "$LINE")
USERID=$(awk -F: '{print $2}' <<< "$LINE")
DIR=$(awk -F: '{print $3}' <<< "$LINE")
if [ "$USERID" -ge 500 ] && [ -d "$DIR" ] && [ "$USER" != "nfsnobody" ]; then
OWNER=$(stat -L -c "%U" "$DIR")
if [ "$OWNER" != "$USER" ]; then
crit "The home directory ($DIR) of user $USER is owned by $OWNER."
ERRORS=$((ERRORS+1))
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."
ERRORS=$((ERRORS+1))
fi
fi
fi
done
if [ $ERRORS = 0 ]; then
ok "All home directories have correct ownership"
fi
fi
}
# This function will be called if the script status is on enabled mode
apply () {
cat /etc/passwd | awk -F: '{ print $1 " " $3 " " $6 }' | while read USER USERID DIR; do
if [ $USERID -ge 500 -a -d "$DIR" -a $USER != "nfsnobody" ]; then
awk -F: '{ print $1 " " $3 " " $6 }' /etc/passwd | while read -r USER USERID DIR; do
if [ "$USERID" -ge 500 ] && [ -d "$DIR" ] && [ "$USER" != "nfsnobody" ]; then
OWNER=$(stat -L -c "%U" "$DIR")
if [ "$OWNER" != "$USER" ]; then
warn "The home directory ($DIR) of user $USER is owned by $OWNER."
chown $USER $DIR
chown "$USER" "$DIR"
fi
fi
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
check_config() {
:
@ -66,8 +90,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,27 +11,38 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="Checking for duplicate UIDs."
EXCEPTIONS=""
ERRORS=0
# This function will be called if the script status is on enabled / audit mode
audit () {
RESULT=$(cat /etc/passwd | cut -f3 -d":" | sort -n | uniq -c | awk {'print $1":"$2'} )
for LINE in $RESULT; do
RESULT=$(cut -f3 -d":" < /etc/passwd | sort -n | uniq -c | awk '{print $1":"$2}' )
FOUND_EXCEPTIONS=""
for LINE in $RESULT; do
debug "Working on line $LINE"
OCC_NUMBER=$(awk -F: {'print $1'} <<< $LINE)
USERID=$(awk -F: {'print $2'} <<< $LINE)
if [ $OCC_NUMBER -gt 1 ]; then
USERS=$(awk -F: '($3 == n) { print $1 }' n=$USERID /etc/passwd | xargs)
ERRORS=$((ERRORS+1))
crit "Duplicate UID ($USERID): ${USERS}"
OCC_NUMBER=$(awk -F: '{print $1}' <<< "$LINE")
USERID=$(awk -F: '{print $2}' <<< "$LINE")
if [ "$OCC_NUMBER" -gt 1 ]; then
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))
crit "Duplicate UID $ID_NAMES"
fi
fi
done
done
if [ $ERRORS = 0 ]; then
ok "No duplicate UIDs"
fi
ok "No duplicate UIDs${FOUND_EXCEPTIONS:+ apart from configured exceptions:}${FOUND_EXCEPTIONS}"
fi
}
# This function will be called if the script status is on enabled mode
@ -39,9 +50,20 @@ apply () {
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
check_config() {
:
if [ -z "$EXCEPTIONS" ]; then
EXCEPTIONS="@"
fi
}
# Source Root Dir Parameter
@ -55,8 +77,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,27 +11,30 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="There is no duplicate GIDs."
ERRORS=0
# This function will be called if the script status is on enabled / audit mode
audit () {
RESULT=$(cat /etc/group | cut -f3 -d":" | sort -n | uniq -c | awk {'print $1":"$2'} )
for LINE in $RESULT; do
RESULT=$(cut -f3 -d":" /etc/group | sort -n | uniq -c | awk '{print $1":"$2}' )
for LINE in $RESULT; do
debug "Working on line $LINE"
OCC_NUMBER=$(awk -F: {'print $1'} <<< $LINE)
GROUPID=$(awk -F: {'print $2'} <<< $LINE)
if [ $OCC_NUMBER -gt 1 ]; then
USERS=$(awk -F: '($3 == n) { print $1 }' n=$GROUPID /etc/passwd | xargs)
OCC_NUMBER=$(awk -F: '{print $1}' <<< "$LINE")
GROUPID=$(awk -F: '{print $2}' <<< "$LINE")
if [ "$OCC_NUMBER" -gt 1 ]; then
GROUP=$(awk -F: '($3 == n) { print $1 }' n="$GROUPID" /etc/group | xargs)
ERRORS=$((ERRORS+1))
crit "Duplicate GID ($GROUPID): ${USERS}"
crit "Duplicate GID ($GROUPID): ${GROUP}"
fi
done
done
if [ $ERRORS = 0 ]; then
ok "No duplicate GIDs"
fi
fi
}
# This function will be called if the script status is on enabled mode
@ -55,8 +58,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="There is no duplicate usernames."
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="There is no duplicate group names."
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="There is no user .netrc files."
ERRORS=0
FILENAME='.netrc'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="There is no user .forward files."
ERRORS=0
FILENAME='.forward'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Ensure password fields are not empty in /etc/shadow."
FILE='/etc/shadow'
# This function will be called if the script status is on enabled / audit mode
audit () {
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
crit "Some accounts have an empty password"
crit $RESULT

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="There is no user in shadow group (that can read /etc/shadow file)."
ERRORS=0
FILEGROUP='/etc/group'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/password file."
FILE='/etc/passwd'
RESULT=''

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/shadow file."
FILE='/etc/shadow'
RESULT=''
@ -19,7 +20,7 @@ RESULT=''
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Checking if accounts have a legacy password entry"
if grep '^+:' $FILE -q; then
if $SUDO_CMD grep '^+:' $FILE -q; then
RESULT=$(grep '^+:' $FILE)
crit "Some accounts have a legacy password entry"
crit $RESULT

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Verify no legacy + entries exist in /etc/group file."
FILE='/etc/group'
RESULT=''

View File

@ -1,7 +1,7 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,7 +11,11 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="Verify root is the only UID 0 account."
EXCEPTIONS=""
FILE='/etc/passwd'
RESULT=''
@ -19,23 +23,24 @@ RESULT=''
# This function will be called if the script status is on enabled / audit mode
audit () {
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
debug "Account : $ACCOUNT"
debug "Exceptions : $EXCEPTIONS"
debug "echo \"$EXCEPTIONS\" | grep -q $ACCOUNT"
if echo "$EXCEPTIONS" | grep -q $ACCOUNT; then
debug "echo \"$EXCEPTIONS\" | grep -qw $ACCOUNT"
if echo "$EXCEPTIONS" | grep -qw "$ACCOUNT"; then
debug "$ACCOUNT is confirmed as an exception"
RESULT=$(sed "s!$ACCOUNT!!" <<< "$RESULT")
FOUND_EXCEPTIONS="$FOUND_EXCEPTIONS $ACCOUNT"
else
debug "$ACCOUNT not found in exceptions"
fi
done
if [ ! -z "$RESULT" ]; then
crit "Some accounts have uid 0"
crit $RESULT
crit "Some accounts have uid 0: $(tr '\n' ' ' <<< "$RESULT")"
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
}
@ -47,8 +52,8 @@ apply () {
# This function will create the config file for this check with default values
create_config() {
cat <<EOF
status=disabled
# Put here valid accounts with uid 0 separated by spaces
status=audit
# Put here valid accounts with uid 0 separated by spaces
EXCEPTIONS=""
EOF
}
@ -71,8 +76,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure root path integrity."
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Check permissions on user home directories."
ERRORS=0
@ -91,7 +92,7 @@ apply () {
# This function will create the config file for this check with default values
create_config() {
cat <<EOF
status=disabled
status=audit
# Put here user home directories exceptions, separated by spaces
EXCEPTIONS=""
EOF

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Check user dot file permissions."
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Check user permissions on .netrc file."
PERMISSIONS="600"
ERRORS=0

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="/home partition with nodev option."
# Quick factoring as many script use the same logic
PARTITION="/home"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="nodev option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="noexec option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="nosuid option for removable media partitions."
# Fair warning, it only checks /media.* like partition in fstab, it's not exhaustive

View File

@ -1,7 +1,8 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,7 +12,10 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="/run/shm with nodev option."
# Quick factoring as many script use the same logic
PARTITION="/run/shm"
@ -20,6 +24,7 @@ OPTION="nodev"
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Verifying that $PARTITION is a partition"
PARTITION=$(readlink -e "$PARTITION")
FNRET=0
is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then
@ -36,11 +41,11 @@ audit () {
has_mounted_option $PARTITION $OPTION
if [ $FNRET -gt 0 ]; then
warn "$PARTITION is not mounted with $OPTION at runtime"
FNRET=3
FNRET=3
else
ok "$PARTITION mounted with $OPTION"
fi
fi
fi
fi
}
@ -58,7 +63,7 @@ apply () {
elif [ $FNRET = 3 ]; then
info "Remounting $PARTITION from fstab"
remount_partition $PARTITION
fi
fi
}
# This function will check config parameters required
@ -78,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,8 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,7 +12,10 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=2
# shellcheck disable=2034
DESCRIPTION="/run/shm with nosuid option."
# Quick factoring as many script use the same logic
PARTITION="/run/shm"
@ -20,6 +24,7 @@ OPTION="nosuid"
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Verifying that $PARTITION is a partition"
PARTITION=$(readlink -e "$PARTITION")
FNRET=0
is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then
@ -36,11 +41,11 @@ audit () {
has_mounted_option $PARTITION $OPTION
if [ $FNRET -gt 0 ]; then
warn "$PARTITION is not mounted with $OPTION at runtime"
FNRET=3
FNRET=3
else
ok "$PARTITION mounted with $OPTION"
fi
fi
fi
fi
}
@ -58,7 +63,7 @@ apply () {
elif [ $FNRET = 3 ]; then
info "Remounting $PARTITION from fstab"
remount_partition $PARTITION
fi
fi
}
# This function will check config parameters required
@ -78,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,8 @@
#!/bin/bash
# run-shellcheck
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -11,7 +12,10 @@
set -e # One error, it's over
set -u # One variable unset, it's over
# shellcheck disable=2034
HARDENING_LEVEL=3
# shellcheck disable=2034
DESCRIPTION="/run/shm with noexec option."
# Quick factoring as many script use the same logic
PARTITION="/run/shm"
@ -20,6 +24,7 @@ OPTION="noexec"
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Verifying that $PARTITION is a partition"
PARTITION=$(readlink -e "$PARTITION")
FNRET=0
is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then
@ -36,11 +41,11 @@ audit () {
has_mounted_option $PARTITION $OPTION
if [ $FNRET -gt 0 ]; then
warn "$PARTITION is not mounted with $OPTION at runtime"
FNRET=3
FNRET=3
else
ok "$PARTITION mounted with $OPTION"
fi
fi
fi
fi
}
@ -58,7 +63,7 @@ apply () {
elif [ $FNRET = 3 ]; then
info "Remounting $PARTITION from fstab"
remount_partition $PARTITION
fi
fi
}
# This function will check config parameters required
@ -78,8 +83,9 @@ if [ -z "$CIS_ROOT_DIR" ]; then
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
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
# shellcheck source=/opt/debian-cis/lib/main.sh
. "$CIS_ROOT_DIR"/lib/main.sh
else
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
exit 128

View File

@ -1,7 +1,7 @@
#!/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
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
audit () {
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
crit "Some world writable directories are not on sticky bit mode!"
FORMATTED_RESULT=$(sed "s/ /\n/g" <<< $RESULT | sort | uniq | tr '\n' ' ')

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of cramfs filesystems."
KERNEL_OPTION="CONFIG_CRAMFS"
MODULE_NAME="cramfs"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of freevxfs filesystems."
KERNEL_OPTION="CONFIG_VXFS_FS"
MODULE_NAME="freevxfs"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/tmp on a separate partition."
# Quick factoring as many script use the same logic
PARTITION="/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of jffs2 filesystems."
KERNEL_OPTION="CONFIG_JFFS2_FS"
MODULE_NAME="jffs2"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of hfs filesystems."
KERNEL_OPTION="CONFIG_HFS_FS"
MODULE_FILE="hfs"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of hfsplus filesystems."
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
MODULE_FILE="hfsplus"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of squashfs filesytems."
KERNEL_OPTION="CONFIG_SQUASHFS"
MODULE_FILE="squashfs"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable mounting of udf filesystems."
KERNEL_OPTION="CONFIG_UDF_FS"
MODULE_FILE="udf"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable automounting of devices."
SERVICE_NAME="autofs"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="/tmp partition with nodev option."
# Quick factoring as many script use the same logic
PARTITION="/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="/tmp partition with nosuid option."
# Quick factoring as many script use the same logic
PARTITION="/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/tmp partition with noexec option."
# Quick factoring as many script use the same logic
PARTITION="/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/var on a separate partition."
# Quick factoring as many script use the same logic
PARTITION="/var"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/var/tmp on a separate partition."
# Quick factoring as many script use the same logic
PARTITION="/var/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="/var/tmp partition with nodev option."
# Quick factoring as many script use the same logic
PARTITION="/var/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="/var/tmp partition with nosuid option."
# Quick factoring as many script use the same logic
PARTITION="/var/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/var/tmp partition with noexec option."
# Quick factoring as many script use the same logic
PARTITION="/var/tmp"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/var/log on separate partition."
# Quick factoring as many script use the same logic
PARTITION="/var/log"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=4
DESCRIPTION="/var/log/audit on a separate partition."
# Quick factoring as many script use the same logic
PARTITION="/var/log/audit"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="/home on a separate partition."
# Quick factoring as many script use the same logic
PARTITION="/home"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="User and group root owner of grub bootloader config."
# Assertion : Grub Based.

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=1
DESCRIPTION="Permissions for root only on grub bootloader config."
# Assertion : Grub Based.

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Setting bootloader password to secure boot parameters."
FILE='/boot/grub/grub.cfg'
USER_PATTERN="^set superusers"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Root password for single user mode."
FILE="/etc/shadow"
PATTERN="^root:[*\!]:"

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Restrict core dumps."
LIMIT_FILE='/etc/security/limits.conf'
LIMIT_DIR='/etc/security/limits.d'
LIMIT_PATTERN='^\*[[:space:]]*hard[[:space:]]*core[[:space:]]*0$'
SYSCTL_PARAM='fs.suid_dumpable'
SYSCTL_EXP_RESULT=0
# This function will be called if the script status is on enabled / audit mode
audit () {
does_pattern_exist_in_file $LIMIT_FILE $LIMIT_PATTERN
if [ $FNRET != 0 ]; then
crit "$LIMIT_PATTERN not present in $LIMIT_FILE"
else
ok "$LIMIT_PATTERN present in $LIMIT_FILE"
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
debug "$LIMIT_PATTERN not present in $file"
else
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
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
if [ $FNRET != 0 ]; then

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Enable NoExecute/ExecuteDisable to prevent buffer overflow attacks."
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() {
if grep -q ' nx ' /proc/cpuinfo; then
# 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
else
FNRET=0 # supported and enabled

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Enable Randomized Virtual Memory Region Placement to prevent memory page exploits."
SYSCTL_PARAM='kernel.randomize_va_space'
SYSCTL_EXP_RESULT=2

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Disable prelink to prevent libraries compromission."
PACKAGE='prelink'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Activate AppArmor to enforce permissions control."
PACKAGE='apparmor'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
PACKAGE='nis'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure rsh server is not enabled. Recommended alternative : sshd (openssh-server)."
# Based on aptitude search '~Prsh-server'
PACKAGES='rsh-server rsh-redone-server heimdal-servers'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure rsh client is not installed, Recommended alternative : ssh."
# Based on aptitude search '~Prsh-client', exluding ssh-client OFC
PACKAGES='rsh-client rsh-redone-client heimdal-clients'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure talk server is not enabled."
PACKAGES='inetutils-talkd talkd'
FILE='/etc/inetd.conf'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure talk client is not installed."
PACKAGES='talk inetutils-talk'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure telnet server is not enabled. Recommended alternative : sshd (OpenSSH-server)."
# Based on aptitude search '~Ptelnet-server'
PACKAGES='telnetd inetutils-telnetd telnetd-ssl krb5-telnetd heimdal-servers'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure tftp-server is not enabled."
PACKAGES='tftpd tftpd-hpa atftpd'
FILE='/etc/inetd.conf'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure xinetd is not enabled."
PACKAGES='openbsd-inetd xinetd rlinetd'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure chargen debugging network service is not enabled."
FILE='/etc/inetd.conf'
PATTERN='^chargen'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure daytime debugging network service is not enabled."
FILE='/etc/inetd.conf'
PATTERN='^daytime'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure echo debugging network service is not enabled."
FILE='/etc/inetd.conf'
PATTERN='^echo'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure discard debugging network service is not enabled."
FILE='/etc/inetd.conf'
PATTERN='^discard'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=2
DESCRIPTION="Ensure time debugging network service is not enabled."
FILE='/etc/inetd.conf'
PATTERN='^time'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure HTTP server is not enabled."
HARDENING_EXCEPTION=http
# Based on aptitude search '~Phttpd'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure IMAP and POP servers are not enabled."
HARDENING_EXCEPTION=mail
# Based on aptitude search '~Pimap-server' and aptitude search '~Ppop3-server'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure Samba is not enabled."
HARDENING_EXCEPTION=samba
PACKAGES='samba'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Ensure HTTP-proxy is not enabled."
HARDENING_EXCEPTION=http
PACKAGES='squid3 squid'

View File

@ -1,7 +1,7 @@
#!/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
HARDENING_LEVEL=3
DESCRIPTION="Enure SNMP server is not enabled."
HARDENING_EXCEPTION=snmp
PACKAGES='snmpd'

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# CIS Debian 7/8 Hardening
# CIS Debian Hardening
#
#
@ -12,12 +12,13 @@ set -e # One error, it's over
set -u # One variable unset, it's over
HARDENING_LEVEL=3
DESCRIPTION="Configure Mail Transfert Agent for Local-Only Mode."
HARDENING_EXCEPTION=mail
# This function will be called if the script status is on enabled / audit mode
audit () {
info "Checking netport ports opened"
RESULT=$(netstat -an | grep LIST | grep ":25[[:space:]]") || :
RESULT=$($SUDO_CMD netstat -an | grep LIST | grep ":25[[:space:]]") || :
RESULT=${RESULT:-}
debug "Result is $RESULT"
if [ -z "$RESULT" ]; then

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