-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_lib.sh
314 lines (304 loc) · 18.5 KB
/
functions_lib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/bin/sh
host_configuration() {
check_L1 "1" "Initial Setup"
check_L2 "1_1" "Filesystem Configuration"
check_L2 "1_1_1" "Disable unused filesystems"
check_L2 "1_1_1_1" "Filesystems disabled"
check_1_1_1_x 1 "cramfs"
check_1_1_1_x 2 "freevxfs"
check_1_1_1_x 3 "jffs2"
check_1_1_1_x 4 "hfs"
check_1_1_1_x 5 "hfsplus"
check_1_1_1_x 6 "squashfs"
check_1_1_1_x 7 "udf"
check_1_1_1_x 8 "vfat"
make_check "1_1_2" "Ensure separate partition exists for /tmp"
make_check "1_1_3" "Ensure nodev option set on /tmp Partition"
make_check "1_1_4" "Ensure nosuid option set on /tmp Partition"
make_check "1_1_5" "Ensure noexec option set on /tmp Partition"
make_check "1_1_6" "Ensure separate partition exists for /var"
make_check "1_1_7" "Ensure separate partition exists for /var/tmp"
make_check "1_1_8" "Ensure nodev option set on /var/tmp Partition"
make_check "1_1_9" "Ensure nosuid option set on /var/tmp Partition"
make_check "1_1_10" "Ensure noexec option set on /var/tmp Partition"
make_check "1_1_11" "Ensure separate partition exists for /var/log"
make_check "1_1_12" "Ensure separate partition exists for /var/log/audit"
make_check "1_1_13" "Ensure separate partition exists for /home"
make_check "1_1_14" "Ensure nodev option set on /home Partition"
make_check "1_1_15" "Ensure nosdev option set on /dev/shm Partition"
make_check "1_1_16" "Ensure nosuid option set on /dev/shm Partition"
make_check "1_1_17" "Ensure noexec option set on /dev/shm Partition"
check_L2 "1_1_18" "Ensure nodev option set on removable media partitions (Not Scored)"
check_L2 "1_1_19" "Ensure nosuid option set on removable media partitions (Not Scored)"
check_L2 "1_1_20" "Ensure noexec option set on removable media partitions (Not Scored)"
make_check "1_1_21" "Ensure sticky bit is set on all world-writable directories"
make_check "1_1_22" "Disable Automountine"
check_L2 "1_2" "Configure Software Updates"
check_L2 "1_2_1" "Ensure package manager repositories are configured (Not Scored)"
make_check "1_2_2" "Ensure gpgcheck is globally activated"
make_check "1_2_3" "Verifying global activation of gpgcheck"
check_L2 "1_2_4" "Ensure Red Hat Subscription Manager connection is configured (Not Scored)"
make_check "1_2_5" "Ensure that the rhnsd Daemon*"
check_L2 "1_3" "Filesystem Integrity Checking"
make_check "1_3_1" "Ensure AIDE is installed (Scored)"
make_check "1_3_2" "Ensure filesystem integrity is regularly checked (Scored)"
check_L2 "1_4" "Secure Boot Settings"
make_check "1_4_1" "Ensure permissions on bootloader config are configured"
make_check "1.4.2" "Ensure bootloader password is set (Scored)"
make_check "1_4_3" "Ensure authentication required for single user mode (Scored)"
make_check "1_5" "Additional Process Hardening"
make_check "1_5_1" "Ensure core dumps are restricted"
make_check "1_5_2" "Ensure XD/NX support is enabled"
make_check "1_5_3" "Ensure address space layout randomization (ASLR) is enabled"
make_check "1_5_4" "Ensure prelink is disabled"
make_check "1_6" "Mandatory Access Control"
make_check "1_6_1" "Configure SELinux"
make_check "1_6_1_1" "Ensure SELinux is not disabled in bootloader configuration"
make_check "1_6_1_2" "Ensure the SELinux state is enforcing"
make_check "1_6_1_3" "Ensure SELinux policy is configured"
make_check "1_6_1_4" "Ensure SETroubleshoot is not installed"
make_check "1_6_1_5" "Ensure the MCS Translation Service (mcstrans) is not installed"
make_check "1_6_1_6" "Ensure no unconfined daemons exist"
make_check "1_6_2" "Ensure SELinux is installed"
check_L2 "1_7" "Warning Banners"
make_check "1_7_1" "Command Line Warning Banner"
make_check "1_7_1_1" "Ensure message of the day is configured properly"
make_check "1_7_1_2" "Ensure local login warning banner is configured properly"
make_check "1_7_1_3" "Ensure remote login warning banner is configured properly"
make_check "1_7_1_4" "Ensure permissions on /etc/motd are configured"
make_check "1_7_1_5" "Ensure permissions on /etc/issue are configured"
make_check "1_7_1_6" "Ensure permissions on /etc/issue.net are configured"
make_check "1_7_2" "Ensure GDM login banner is configured"
make_check "1_8" "Ensure updates, patches, and additional security software are installe"
check_end
}
service_configuration() {
check_L1 "2" "Services"
check_L2 "2_1" "Configuration of inetd Services"
make_check "2_1_1" "Ensure chargen services are not enabled"
make_check "2_1_2" "Ensure daytime services are not enabled "
make_check "2_1_3" "Ensure discard services are not enabled"
make_check "2_1_4" "Ensure echo services are not enabled"
make_check "2_1_5" "Ensure time services are not enabled (Scored)"
make_check "2_1_6" "Ensure tftp server is not enabled (Scored)"
make_check "2_1_7" "Ensure xinetd is not enabled (Scored)"
check_2_2 "2_2" "Special Purpose Services"
make_check "2_2_1" "Time Synchronization"
make_check "2_2_1_2" "Ensure ntp is configured (Scored)"
make_check "2_2_1_3" "Ensure chrony is configured (Scored)"
make_check "2_2_2" "Ensure X Window System is not installed (Scored)"
make_check "2_2_3" "Ensure Avahi Server is not enabled (Scored)"
make_check "2_2_4" "Ensure CUPS is not enabled (Scored)"
make_check "2_2_5" "Ensure DHCP Server is not enabled (Scored)"
make_check "2_2_6" "Ensure LDAP server is not enabled (Scored)"
make_check "2_2_7" "Ensure NFS and RPC are not enabled (Scored)"
make_check "2_2_8" "Ensure DNS Server is not enabled (Scored)"
make_check "2_2_9" "Ensure FTP Server is not enabled (Scored)"
make_check "2_2_10" "Ensure HTTP server is not enabled (Scored)"
make_check "2_2_11" "Ensure IMAP and POP3 server is not enabled (Scored)"
make_check "2_2_12" "Ensure Samba is not enabled (Scored)"
make_check "2_2_13" "Ensure HTTP Proxy Server is not enabled (Scored)"
make_check "2_2_14" "Ensure SNMP Server is not enabled (Scored)"
make_check "2_2_15" "Ensure mail transfer agent is configured for local-only mode"
make_check "2_2_16" "Ensure NIS Server is not enabled (Scored)"
make_check "2_2_17" "Ensure rsh server is not enabled (Scored)"
make_check "2_2_18" "Ensure talk server is not enabled (Scored)"
make_check "2_2_19" "Ensure telnet server is not enabled (Scored)"
make_check "2_2_20" "Ensure tftp server is not enabled (Scored)"
make_check "2_2_21" "Ensure rsync service is not enabled (Scored)"
check_L2 "2_3" "Service Clients"
make_check "2_3_1" "Ensure NIS Client is not installed (Scored)"
make_check "2_3_2" "Ensure rsh client is not installed (Scored)"
make_check "2_3_3" "Ensure talk client is not installed (Scored)"
make_check "2_3_4" "Ensure telnet client is not installed (Scored)"
make_check "2_3_5" "Ensure LDAP client is not installed (Scored)"
check_end
}
network_filtering() {
check_L1 "3" "Network Configuration"
check_L2 "3_1" "Network Parameters (Host Only)"
make_check "3_1_1" "Ensure IP forwarding is disabled (Scored)"
make_check "3_1_2" "Ensure packet redirect sending is disabled (Scored)"
check_L2 "3_2" "Network Parameters (Host and Router)"
make_check "3_2_1" "Ensure source routed packets are not accepted"
make_check "3_2_2" "Ensure ICMP redirects are not accepted (Scored)"
make_check "3_2_3" "Ensure secure ICMP redirects are not accepted (Scored)"
make_check "3_2_4" "Ensure suspicious packets are logged (Scored)"
make_check "3_2_5" "Ensure broadcast ICMP requests are ignored (Scored)"
make_check "3_2_6" "Ensure bogus ICMP responses are ignored (Scored)"
make_check "3_2_7" "Ensure Reverse Path Filtering is enabled (Scored)"
make_check "3_2_8" "Ensure TCP SYN Cookies is enabled (Scored)"
check_L2 "3_3" "IPv6 configuration"
make_check "3_3_1" "Ensure IPv6 router advertisements are not accepted (Not Scored)"
make_check "3_3_2" "Ensure IPv6 redirects are not accepted (Not Scored)"
make_check "3_3_3" "Ensure IPv6 is disabled (Not Scored)"
check_L2 "3_4" "TCP Wrappers"
make_check "3_4_1" "Ensure TCP Wrappers is installed (Scored)"
make_check "3_4_2" "Ensure /etc/hosts.allow is configured (Scored)"
make_check "3_4_3" "Ensure /etc/hosts.deny is configured (Scored)"
make_check "3_4_4" "Ensure permissions on /etc/hosts.allow are configured (Scored)"
make_check "3_4_5" "Ensure permissions on /etc/hosts.deny are configured (Scored)"
check_L2 "3_5" "Uncommon Network Protocols"
make_check "3_5_1" "Ensure DCCP is disabled (Not Scored)"
make_check "3_5_2" "Ensure SCTP is disabled (Not Scored)"
make_check "3_5_3" "Ensure RDS is disabled (Not Scored)"
make_check "3_5_4" "Ensure TIPC is disabled (Not Scored)"
check_L2 "3_6" "Firewall Configuration"
make_check "3_6_1" "Ensure iptables is installed (Scored)"
make_check "3_6_2" "Ensure default deny firewall policy (Scored)"
make_check "3_6_3" "Ensure loopback traffic is configured (Scored)"
make_check "3_6_4" "Ensure outbound and established connections are configured (Not Scored"
make_check "3_6_5" "Ensure firewall rules exist for all open ports (Scored)"
make_check "3_7" "Ensure wireless interfaces are disabled (Not Scored)"
check_end
}
logging_and_auditing() {
check_L1 "4" "Logging and Auditing"
check_L2 "4_1" "Configure System Accounting (auditd)"
check_L2 "4_1_1" "Configure Data Retention"
make_check "4_1_1_1" "Ensure audit log storage size is configured (Not Scored)"
make_check "4_1_1_2" "Ensure system is disabled when audit logs are full (Scored)"
make_check "4_1_1_3" "Ensure audit logs are not automatically deleted (Scored)"
make_check "4_1_2" "Ensure auditd service is enabled (Scored)"
make_check "4_1_3" "Ensure auditing for processes that start prior to auditd is enabled"
make_check "4_1_4" "Ensure events that modify date and time information are collected (Scored)"
make_check "4_1_5" "Ensure events that modify user/group information are collected"
make_check "4_1_6" "Ensure events that modify the system's network environment are collected (Scored)"
make_check "4_1_7" "Ensure events that modify the system's Mandatory Access Controls are collected (Scored)"
make_check "4_1_8" "Ensure login and logout events are collected (Scored)"
make_check "4_1_9" "Ensure session initiation information is collected (Scored)"
make_check "4_1_10" "Ensure discretionary access control permission modification events are collected (Scored)"
make_check "4_1_11" "Ensure unsuccessful unauthorized file access attempts are collected (Scored)"
make_check "4_1_12" "Ensure use of privileged commands is collected (Scored)"
make_check "4_1_13" "Ensure successful file system mounts are collected (Scored)"
make_check "4_1_14" "Ensure file deletion events by users are collected (Scored)"
make_check "4_1_15" "Ensure changes to system administration scope (sudoers) is collected (Scored)"
make_check "4_1_16" "Ensure system administrator actions (sudolog) are collected (Scored)"
make_check "4_1_17" "Ensure kernel module loading and unloading is collected (Scored)"
make_check "4_1_18" "Ensure the audit configuration is immutable (Scored)"
check_L2 "4_2" "Configure Logging"
check_L2 "4_2_1" "Configure rsyslog"
make_check "4_2_1_1" "Ensure rsyslog Service is enabled (Scored)"
make_check "4_2_1_2" "Ensure logging is configured (Not Scored)"
make_check "4_2_1_3" "Ensure rsyslog default file permissions configured (Scored)"
make_check "4_2_1_4" "Ensure rsyslog is configured to send logs to a remote log host (Scored)"
make_check "4_2_1_5" "Ensure remote rsyslog messages are only accepted on designated log hosts. (Not Scored)"
check_L2 "4_2_2" "Configure syslog-ng"
make_check "4_2_2_2" "Ensure logging is configured (Not Scored)"
make_check "4_2_2_3" "Ensure syslog-ng default file permissions configured (Scored)"
make_check "4_2_2_4" "Ensure syslog-ng is configured to send logs to a remote log host (Not Scored)"
make_check "4_2_2_5" "Ensure remote syslog-ng messages are only accepted on designated log hosts (Not Scored)"
make_check "4_2_3" "Ensure rsyslog or syslog-ng is installed (Scored)"
make_check "4_2_4" "Ensure permissions on all logfiles are configured (Scored)"
make_check "4_3" "Ensure logrotate is configured (Not Scored)"
check_end
}
Access_Authentic_Authorize() {
check_L1 "5" "Access, Authentication and Authorization"
check_L2 "5_1" "Configure cron"
make_check "5_1_2" "Ensure permissions on /etc/crontab are configured (Scored)"
make_check "5_1_3" "Ensure permissions on /etc/cron.hourly are configured (Scored)"
make_check "5_1_4" "Ensure permissions on /etc/cron.daily are configured (Scored)"
make_check "5_1_5" "Ensure permissions on /etc/cron.weekly are configured (Scored)"
make_check "5_1_6" "Ensure permissions on /etc/cron.monthly are configured (Scored)"
make_check "5_1_7" "Ensure permissions on /etc/cron.d are configured (Scored)"
make_check "5_1_8" "Ensure at/cron is restricted to authorized users (Scored)"
check_L2 "5_2" "SSH Server Configuration"
make_check "5_2_1" "Ensure permissions on /etc/ssh/sshd_config are configured (Scored)"
make_check "5_2_2" "Ensure SSH Protocol is set to 2 (Scored)"
make_check "5_2_3" "Ensure SSH LogLevel is set to INFO (Scored)"
make_check "5_2_4" "Ensure SSH X11 forwarding is disabled (Scored)"
make_check "5_2_5" "Ensure SSH MaxAuthTries is set to 4 or less (Scored)"
make_check "5_2_6" "Ensure SSH IgnoreRhosts is enabled (Scored)"
make_check "5_2_7" "Ensure SSH HostbasedAuthentication is disabled (Scored)"
make_check "5_2_8" "Ensure SSH root login is disabled (Scored)"
make_check "5_2_9" "Ensure SSH PermitEmptyPasswords is disabled (Scored)"
make_check "5_2_10" "Ensure SSH PermitUserEnvironment is disabled (Scored)"
make_check "5_2_11" "Ensure only approved MAC algorithms are used (Scored)"
make_check "5_2_12" "Ensure SSH Idle Timeout Interval is configured (Scored)"
make_check "5_2_13" "Ensure SSH LoginGraceTime is set to one minute or less (Scored)"
make_check "5_2_14" "Ensure SSH access is limited (Scored)"
make_check "5_2_15" "Ensure SSH warning banner is configured (Scored)"
check_L2 "5_3" "Configure PAM"
make_check "5_3_1" "Ensure password creation requirements are configured (Scored)"
make_check "5_3_2" "Ensure lockout for failed password attempts is configured (Scored)"
make_check "5_3_3" "Ensure password reuse is limited (Scored)"
make_check "5_3_4" "Ensure password hashing algorithm is SHA-512 (Scored)"
check_L2 "5_4" "User Accounts and Environment"
check_L2 "5_4_1" "Set Shadow Password Suite Parameters"
make_check "5_4_1_1" "Ensure password expiration is 365 days or less (Scored)"
make_check "5_4_1_2" "Ensure minimum days between password changes is 7 or more (Scored)"
make_check "5_4_1_3" "Ensure password expiration warning days is 7 or more (Scored)"
make_check "5_4_1_4" "Ensure inactive password lock is 30 days or less (Scored)"
make_check "5_4_1_5" "Ensure all users last password change date is in the past (Scored)"
make_check "5_4_2" "Ensure system accounts are non-login (Scored)"
make_check "5_4_3" "Ensure default group for the root account is GID 0 (Scored)"
make_check "5_4_4" "Ensure default user umask is 027 or more restrictive (Scored)"
make_check "5_4_5" "Ensure default user shell timeout is 900 seconds or less (Scored)"
check_L2 "5_5" "Ensure root login is restricted to system console (Not Scored)"
make_check "5_6" "Ensure access to the su command is restricted (Scored)"
check_end
}
system_maintenance() {
check_L1 "6" "System Maintenance"
check_L2 "6_1" "System File Permissions"
make_check "6_1_1" "Audit system file permissions (Not Scored)"
make_check "6_1_2" "Ensure permissions on /etc/passwd are configured (Scored)"
make_check "6_1_3" "Ensure permissions on /etc/shadow are configured (Scored)"
make_check "6_1_4" "Ensure permissions on /etc/group are configured (Scored)"
make_check "6_1_5" "Ensure permissions on /etc/gshadow are configured (Scored)"
make_check "6_1_6" "Ensure permissions on /etc/passwd- are configured (Scored)"
make_check "6_1_7" "Ensure permissions on /etc/shadow- are configured (Scored)"
make_check "6_1_8" "Ensure permissions on /etc/group- are configured (Scored)"
make_check "6_1_9" "Ensure permissions on /etc/gshadow- are configured (Scored)"
make_check "6_1_10" "Ensure no world writable files exist (Scored)"
make_check "6_1_11" "Ensure no unowned files or directories exist (Scored)"
make_check "6_1_12" "Ensure no ungrouped files or directories exist (Scored)"
make_check "6_1_13" "Audit SUID executables (Not Scored)"
make_check "6_1_14" "Audit SGID executables (Not Scored)"
check_L2 "6_2" "User and Group Settings"
make_check "6_2_2" "Ensure no legacy \"+\" entries exist in /etc/passwd (Scored)"
make_check "6_2_1" "Ensure password fields are not empty (Scored)"
make_check "6_2_3" "Ensure no legacy \"+\" entries exist in /etc/shadow (Scored)"
make_check "6_2_4" "Ensure no legacy \"+\" entries exist in /etc/group (Scored)"
make_check "6_2_5" "Ensure root is the only UID 0 account (Scored)"
make_check "6_2_6" "Ensure root PATH Integrity (Scored)"
make_check "6_2_7" "Ensure all users' home directories exist (Scored)"
make_check "6_2_8" "Ensure users' home directories permissions are 750 or more"
make_check "6_2_9" "Ensure users own their home directories (Scored)"
make_check "6_2_10" "Ensure users' dot files are not group or world writable (Scored)"
make_check "6_2_11" "Ensure no users have .forward files (Scored)"
make_check "6_2_12" "Ensure no users have .netrc files (Scored)"
make_check "6_2_13" "Ensure users' .netrc Files are not group or world accessible (Scored)"
make_check "6_2_14" "Ensure no users have .rhosts files (Scored)"
make_check "6_2_15" "Ensure all groups in /etc/passwd exist in /etc/group (Scored)"
make_check "6_2_16" "Ensure no duplicate UIDs exist (Scored)"
make_check "6_2_17" "Ensure no duplicate GIDs exist (Scored)"
make_check "6_2_18" "Ensure no duplicate user names exist (Scored)"
make_check "6_2_19" "Ensure no duplicate group names exist (Scored)"
check_end
}
community_checks() {
check_c
check_c_1
check_c_2
check_end
}
# CIS
cis() {
host_configuration
service_configuration
network_filtering
logging_and_auditing
Access_Authentic_Authorize
system_maintenance
}
# Community contributed
community() {
community_checks
}
# All
all() {
cis
#community
}