|
| 1 | +# |
| 2 | +# Cookbook Name:: windows-hardening |
| 3 | +# Recipe:: account_status |
| 4 | +# |
| 5 | +# Copyright (c) 2019 The Authors, All Rights Reserved. |
| 6 | + |
| 7 | +return unless node['platform_family'] == 'windows' |
| 8 | + |
| 9 | +# Ensure \'Accounts: Administrator account status\' is set to \'Disabled\' |
| 10 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.1' |
| 11 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.1' |
| 12 | +# Ensure \'Accounts: Guest account status\' is set to \'Disabled\' |
| 13 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.3' |
| 14 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.3' |
| 15 | +node['account_status']['names'].each do |name| |
| 16 | + account_status "disable #{name} account" do |
| 17 | + account_name name |
| 18 | + value node['account_status']['active_yes_no'] |
| 19 | + action :set |
| 20 | + end |
| 21 | +end |
| 22 | + |
| 23 | +# Ensure \'Accounts: Block Microsoft accounts\' is set to \'Users can\'t add or log on with Microsoft accounts\' |
| 24 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.2' |
| 25 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.2' |
| 26 | +registry_key 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System' do |
| 27 | + values [{ |
| 28 | + name: 'NoConnectedUser', |
| 29 | + type: :dword, |
| 30 | + data: 3 |
| 31 | + }] |
| 32 | + action :create |
| 33 | + recursive true |
| 34 | +end |
| 35 | + |
| 36 | +# Ensure \'Accounts: Limit local account use of blank passwords to console logon only\' is set to \'Enabled\' |
| 37 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.4' |
| 38 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.4' |
| 39 | +registry_key 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa' do |
| 40 | + values [{ |
| 41 | + name: 'LimitBlankPasswordUse', |
| 42 | + type: :dword, |
| 43 | + data: 1 |
| 44 | + }] |
| 45 | + action :create |
| 46 | + recursive true |
| 47 | +end |
| 48 | + |
| 49 | +# Configure \'Accounts: Rename administrator account\' |
| 50 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.5' |
| 51 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.5' |
| 52 | +if node['rename_account']['admin_account'] == true |
| 53 | + rename_account "rename Administrator name to #{node['rename_account']['new_admin_name']} account" do |
| 54 | + original_name 'Administrator' |
| 55 | + new_name node['rename_account']['new_admin_name'] |
| 56 | + action :set |
| 57 | + end |
| 58 | +end |
| 59 | + |
| 60 | +# Configure \'Accounts: Rename guest account\' |
| 61 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.1.6' |
| 62 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.1.6' |
| 63 | +if node['rename_account']['guest_account'] == true |
| 64 | + rename_account "rename Guest name to #{node['rename_account']['new_guest_name']} account" do |
| 65 | + original_name 'Guest' |
| 66 | + new_name node['rename_account']['new_guest_name'] |
| 67 | + action :set |
| 68 | + end |
| 69 | +end |
| 70 | + |
| 71 | +# Ensure \'Audit: Force audit policy subcategory settings (Windows Vista or later) to override audit policy category settings\' is set to \'Enabled\' |
| 72 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.2.1' |
| 73 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.2.1' |
| 74 | +registry_key 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa' do |
| 75 | + values [{ |
| 76 | + name: 'SCENoApplyLegacyAuditPolicy', |
| 77 | + type: :dword, |
| 78 | + data: 1 |
| 79 | + }] |
| 80 | + action :create |
| 81 | + recursive true |
| 82 | +end |
| 83 | + |
| 84 | +# Ensure \'Audit: Shut down system immediately if unable to log security audits\' is set to \'Disabled\' |
| 85 | +# tag 'CIS Microsoft Windows Server 2012 R2 Benchmark v2.3.0 - 03-30-2018': '2.3.2.2' |
| 86 | +# tag 'CIS Microsoft Windows Server 2016 RTM (Release 1607) Benchmark v1.1.0 - 10-31-2018': '2.3.2.2' |
| 87 | +registry_key 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa' do |
| 88 | + values [{ |
| 89 | + name: 'CrashOnAuditFail', |
| 90 | + type: :dword, |
| 91 | + data: 0 |
| 92 | + }] |
| 93 | + action :create |
| 94 | + recursive true |
| 95 | +end |
0 commit comments