Skip to content

Commit b27fe4e

Browse files
committed
Initial Commit
1 parent fabf2f8 commit b27fe4e

File tree

220 files changed

+5951
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+5951
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/*.retry
2+
**/*.swp
3+
**/*.vagrant
4+
**/*.pyc
5+
**/*.output
6+
tests/tmp
7+
tests/roles
8+
.idea

ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
roles_path = ../

defaults/main.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Standards: 0.11
2+
---
3+
4+
###############################################
5+
# Values which modify the behaviour of the role
6+
###############################################
7+
8+
cis_apply_level_1_profile: true # Whether Level 1 of the benchmark should be applied
9+
cis_apply_level_2_profile: true # Whether Level 2 of the benchmark should be applied
10+
11+
cis_level_1_exclusions: [] # A list of Level 1 recommendations to exclude (i.e. ['1.1.1.1'])
12+
cis_level_2_exclusions: [] # A list of Level 2 recommendations to exclude
13+
14+
# Whether to fail when remediation items are found for recommendations which can't be automatically fixed.
15+
# If false, a debug message will be generated instead, with the preface *** ACTION REQUIRED ***..
16+
fail_on_manual_remediation_actions: false # True or false.
17+
18+
###############################################
19+
# Check specific values which can be overridden
20+
###############################################
21+
22+
# 1.3.1
23+
cis_aide_database_filename: "/var/lib/aide/aide.db.gz"
24+
cis_aide_src_database_filename: "/var/lib/aide/aide.db.new.gz"
25+
26+
# 1.3.2
27+
cis_aide_cron_user: "root"
28+
cis_aide_cron_job: "/usr/sbin/aide --check"
29+
cis_aide_cron_minute: 0
30+
cis_aide_cron_hour: 5
31+
cis_aide_cron_dow: "*" # Day of week
32+
cis_aide_cron_dom: "*" # Day of month
33+
cis_aide_cron_month: "*"
34+
35+
# 1.7.1.2
36+
cis_local_login_warning_banner: "Authorized uses only. All activity may be monitored and reported.\n"
37+
# 1.7.1.3
38+
cis_remote_login_warning_banner: "Authorized uses only. All activity may be monitored and reported.\n"
39+
40+
# 2.1.1.1
41+
# You should only enable either ntp or chrony, but not both.
42+
cis_enable_ntp: true # Set to true if ntp should be enabled/configured.
43+
cis_enable_chrony: false # Set to true if chrony should be enabled/configured.
44+
45+
# 3.3.2
46+
cis_hosts_allow_all_ips: "127.0.0.1"
47+
48+
# 4.2.3
49+
# You should only enable either rsyslog or syslog-ng, but not both.
50+
cis_enable_rsyslog: true # Set to true if rsyslog should be enabled/configured.
51+
cis_enable_syslog_ng: false # Set to true if syslog_ng should be enabled/configured.
52+
53+
# 4.2.1.4
54+
cis_rsyslog_remote_loghost_address: "loghost.example.com" # Can be a hostname or IP address. If no forwarding should occur, exclude this check.
55+
56+
# 4.2.1.5
57+
cis_rsyslog_accept_remote_messages: false # Set to true if the host should accept remote syslog messages.
58+
59+
# 4.2.2.3
60+
cis_syslog_ng_file_perms: "0640"
61+
62+
# 5.2.7
63+
cis_sshd_max_auth_tries: 4
64+
65+
# 5.2.13
66+
cis_sshd_ciphers: "chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com"
67+
68+
# 5.2.14
69+
cis_sshd_macs: "hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512"
70+
71+
# 5.2.15
72+
cis_sshd_kexs: "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256"
73+
74+
# 5.2.16
75+
cis_sshd_client_alive_interval: 300
76+
cis_sshd_client_alive_count_max: 0
77+
78+
# 5.2.17
79+
cis_sshd_login_grace_time: 60
80+
81+
# 5.2.18
82+
cis_sshd_allow_users: "" # A comma-delimited list of users to allow ssh access to
83+
cis_sshd_allow_groups: "" # A comma-delimited list of groups ot allow ssh access to
84+
cis_sshd_deny_users: "" # A comma-delimited list of users to deny ssh access for
85+
cis_sshd_deny_groups: "" # A comma-delimited list of groups to deny ssh access for
86+
87+
# 5.2.19
88+
cis_sshd_banner: "/etc/issue.net"
89+
90+
# 5.3.1
91+
cis_pwquality_minlen: "14" # Minimum number of characters required for passwords
92+
cis_pwquality_dcredit: "-1" # At least one digit must be provided
93+
cis_pwquality_ucredit: "-1" # At least one uppercase character must be provided
94+
cis_pwquality_ocredit: "-1" # At least one special character must be provided
95+
cis_pwquality_lcredit: "-1" # At least one lowercase character must be provided
96+
97+
# 5.4.1
98+
cis_pass_max_days: 90
99+
cis_pass_min_days: 7
100+
cis_pass_warn_age: 7
101+
cis_pass_inactive_lock: 30
102+
103+
# 5.4.2
104+
cis_skip_lock_users:
105+
- root
106+
- halt
107+
- shutdown
108+
- sync
109+
110+
# 5.4.4
111+
cis_umask_default: "027"
112+
cis_umask_shell_files:
113+
- /etc/bashrc
114+
- /etc/profile
115+
116+
# 5.5
117+
cis_wheel_group_members: "root"

facts/all_mounts.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/python
2+
3+
##
4+
# all_mounts.fact
5+
# This is a custom fact that will gather all
6+
# mounts into a fact, ansible_mounts will only
7+
# get mounts that are tied to a physical device
8+
# that will leave out many mounts
9+
##
10+
11+
import os
12+
import json
13+
14+
##
15+
# get_file_content
16+
# gets the content of a file
17+
# path - the path to the file
18+
# default - the default return
19+
# strip - strip out whitespace
20+
##
21+
def get_file_content(path, default=None, strip=True):
22+
data = default
23+
if os.path.exists(path) and os.access(path, os.R_OK):
24+
try:
25+
try:
26+
datafile = open(path)
27+
data = datafile.read()
28+
if strip:
29+
data = data.strip()
30+
if len(data) == 0:
31+
data = default
32+
finally:
33+
datafile.close()
34+
except:
35+
pass
36+
return data
37+
38+
##
39+
# get_mtab_entries
40+
# gets the mtab entries to use
41+
##
42+
def get_mtab_entries():
43+
44+
mtab_file = '/etc/mtab'
45+
if not os.path.exists(mtab_file):
46+
mtab_file = '/proc/mounts'
47+
48+
mtab = get_file_content(mtab_file, '')
49+
mtab_entries = []
50+
for line in mtab.splitlines():
51+
fields = line.split()
52+
if len(fields) < 4:
53+
continue
54+
mtab_entries.append(fields)
55+
return mtab_entries
56+
57+
## Main ##
58+
59+
mtab_entries = get_mtab_entries()
60+
61+
mounts = []
62+
63+
for fields in mtab_entries:
64+
device, mount, fstype, options = fields[0], fields[1], fields[2], fields[3]
65+
66+
mount_info = {
67+
'mount': mount,
68+
'device': device,
69+
'fstype': fstype,
70+
'options': options
71+
}
72+
73+
mounts.append(mount_info)
74+
75+
print json.dumps(mounts)

files/audit_1.6.1.6.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
out=$(ps -eZ | egrep "initrc" | egrep -vw "tr|ps|egrep|bash|awk" | tr ':' ' ' | awk '{
4+
print $NF }')
5+
if [[ $out ]]; then
6+
echo "Investigate the unconfined daemons found during the audit action"
7+
echo $out
8+
fi

files/audit_6.2.10.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
for dir in `cat /etc/passwd | egrep -v '^(root|sync|halt|shutdown):' | awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
4+
for file in $dir/.[A-Za-z0-9]*; do
5+
if [ ! -h "$file" -a -f "$file" ]; then
6+
fileperm=`ls -ld $file | cut -f1 -d" "`
7+
8+
if [ `echo $fileperm | cut -c6 ` != "-" ]; then
9+
echo "Group Write permission set on file $file"
10+
fi
11+
if [ `echo $fileperm | cut -c9 ` != "-" ]; then
12+
echo "Other Write permission set on file $file"
13+
fi
14+
fi
15+
done
16+
done

files/audit_6.2.11.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
for dir in `cat /etc/passwd |\
4+
awk -F: '{ print $6 }'`; do
5+
if [ ! -h "$dir/.forward" -a -f "$dir/.forward" ]; then
6+
echo ".forward file $dir/.forward exists"
7+
fi
8+
done

files/audit_6.2.12.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
for dir in `cat /etc/passwd |\
4+
awk -F: '{ print $6 }'`; do
5+
if [ ! -h "$dir/.netrc" -a -f "$dir/.netrc" ]; then
6+
echo ".netrc file $dir/.netrc exists"
7+
fi
8+
done

files/audit_6.2.13.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
for dir in `cat /etc/passwd | egrep -v '(root|sync|halt|shutdown)' | awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
4+
for file in $dir/.netrc; do
5+
if [ ! -h "$file" -a -f "$file" ]; then
6+
fileperm=`ls -ld $file | cut -f1 -d" "`
7+
if [ `echo $fileperm | cut -c5 ` != "-" ]; then
8+
echo "Group Read set on $file"
9+
fi
10+
if [ `echo $fileperm | cut -c6 ` != "-" ]; then
11+
echo "Group Write set on $file"
12+
fi
13+
if [ `echo $fileperm | cut -c7 ` != "-" ]; then
14+
echo "Group Execute set on $file"
15+
fi
16+
if [ `echo $fileperm | cut -c8 ` != "-" ]; then
17+
echo "Other Read set on $file"
18+
fi
19+
if [ `echo $fileperm | cut -c9 ` != "-" ]; then
20+
echo "Other Write set on $file"
21+
fi
22+
if [ `echo $fileperm | cut -c10 ` != "-" ]; then
23+
echo "Other Execute set on $file"
24+
fi
25+
fi
26+
done
27+
done

files/audit_6.2.14.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
for dir in `cat /etc/passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
4+
for file in $dir/.rhosts; do
5+
if [ ! -h "$file" -a -f "$file" ]; then
6+
echo ".rhosts file in $dir"
7+
fi
8+
done
9+
done

0 commit comments

Comments
 (0)