|
| 1 | +# harbian-audit with the UOS server deploy |
| 2 | + |
| 3 | +## Introduction |
| 4 | +This release only support UOS server V20. |
| 5 | + |
| 6 | +## Usage |
| 7 | + |
| 8 | +### Pre-Install |
| 9 | +``` |
| 10 | +# apt-get install -y bc net-tools pciutils network-manager |
| 11 | +``` |
| 12 | + |
| 13 | +### Start harbian-audit |
| 14 | +```console |
| 15 | +$ git clone https://github.com/hardenedlinux/harbian-audit.git && cd harbian-audit |
| 16 | +# cp etc/default.cfg /etc/default/cis-hardening |
| 17 | +# sed -i "s#CIS_ROOT_DIR=.*#CIS_ROOT_DIR='$(pwd)'#" /etc/default/cis-hardening |
| 18 | +# bin/hardening.sh --init |
| 19 | +# bin/hardening.sh --audit-all |
| 20 | +hardening [INFO] Treating /home/test/harbian-audit/bin/hardening/1.1_install_updates.sh |
| 21 | +1.1_install_updates [INFO] Working on 1.1_install_updates |
| 22 | +1.1_install_updates [INFO] Checking Configuration |
| 23 | +1.1_install_updates [INFO] Performing audit |
| 24 | +1.1_install_updates [INFO] Checking if apt needs an update |
| 25 | +1.1_install_updates [INFO] Fetching upgrades ... |
| 26 | +1.1_install_updates [ OK ] No upgrades available |
| 27 | +1.1_install_updates [ OK ] Check Passed |
| 28 | +[...] |
| 29 | +################### SUMMARY ################### |
| 30 | + Total Available Checks : 272 |
| 31 | + Total Runned Checks : 272 |
| 32 | + Total Passed Checks : [ 240/272 ] |
| 33 | + Total Failed Checks : [ 32/272 ] |
| 34 | + Enabled Checks Percentage : 100.00 % |
| 35 | + Conformity Percentage : 88.24 % |
| 36 | +# bin/hardening.sh --set-hardening-level 5 |
| 37 | +# sed -i 's/^status=.*/status=disabled/' etc/conf.d/7.4.4_hosts_deny.cfg |
| 38 | +# sed -i 's/^status=.*/status=disabled/' etc/conf.d/8.1.32_freeze_auditd_conf.cfg |
| 39 | +# sed -i 's/^status=.*/status=disabled/' etc/conf.d/8.4.1_install_aide.cfg |
| 40 | +# sed -i 's/^status=.*/status=disabled/' etc/conf.d/8.4.2_aide_cron.cfg |
| 41 | +# sed -i 's/^status=.*/status=disabled/' etc/conf.d/9.5_pam_restrict_su.cfg |
| 42 | +# bin/hardening.sh --apply |
| 43 | +hardening [INFO] Treating /home/test/harbian-audit/bin/hardening/1.1_install_updates.sh |
| 44 | +1.1_install_updates [INFO] Working on 1.1_install_updates |
| 45 | +1.1_install_updates [INFO] Checking Configuration |
| 46 | +1.1_install_updates [INFO] Performing audit |
| 47 | +1.1_install_updates [INFO] Checking if apt needs an update |
| 48 | +1.1_install_updates [INFO] Fetching upgrades ... |
| 49 | +1.1_install_updates [ OK ] No upgrades available |
| 50 | +1.1_install_updates [INFO] Applying Hardening |
| 51 | +1.1_install_updates [ OK ] No Upgrades to apply |
| 52 | +1.1_install_updates [ OK ] Check Passed |
| 53 | +[...] |
| 54 | +# sed -i 's/^status=.*/status=enabled/' etc/conf.d/8.1.32_freeze_auditd_conf.cfg |
| 55 | +# sed -i 's/^status=.*/status=enabled/' etc/conf.d/8.4.1_install_aide.cfg |
| 56 | +# sed -i 's/^status=.*/status=enabled/' etc/conf.d/8.4.2_aide_cron.cfg |
| 57 | +# ./bin/hardening.sh --apply --only 8.4.1 |
| 58 | +# ./bin/hardening.sh --apply --only 8.4.2 |
| 59 | +# ./bin/hardening.sh --apply --only 8.1.32 |
| 60 | +``` |
| 61 | + |
| 62 | +## After remediation (Very important) |
| 63 | +When exec --apply and set-hardening-level are set to 5 (the highest level), you need to do the following: |
| 64 | + |
| 65 | +1) When applying 9.5(Restrict Access to the su Command), you must use the root account to log in to the OS because ordinary users cannot perform subsequent operations. |
| 66 | +If you can only use ssh for remote login, you must use the su command when the normal user logs in. Then do the following: |
| 67 | +``` |
| 68 | +# sed -i '/^[^#].*pam_wheel.so.*/s/^/# &/' /etc/pam.d/su |
| 69 | +``` |
| 70 | +Temporarily comment out the line containing pam_wheel.so. After you have finished using the su command, please uncomment the line. |
| 71 | + |
| 72 | +2) When applying 7.4.4_hosts_deny.sh, the OS cannot be connected through the ssh service, so you need to set allow access host list on /etc/hosts.allow, example: |
| 73 | +``` |
| 74 | +# echo "ALL: 192.168.1. 192.168.5." >> /etc/hosts.allow |
| 75 | +``` |
| 76 | +This example only allows 192.168.1.[1-255] 192.168.5.[1-255] to access this system. Need to be configured according to your situation. |
| 77 | + |
| 78 | +3) Set capabilities for usual user, example(user name is test): |
| 79 | +``` |
| 80 | +# sed -i "/^root/a\test ALL=(ALL:ALL) ALL" /etc/sudoers |
| 81 | +``` |
| 82 | + |
| 83 | +4) Set basic firewall rules |
| 84 | +Set the corresponding firewall rules according to the applications used. HardenedLinux community for Debian GNU/Linux basic firewall rules: |
| 85 | + |
| 86 | +Iptabels format rules: |
| 87 | +[etc.iptables.rules.v4.sh](https://github.com/hardenedlinux/harbian-audit/blob/master/docs/configurations/etc.iptables.rules.v4.sh) |
| 88 | +to do the following: |
| 89 | +``` |
| 90 | +$ INTERFACENAME="your network interfacename(Example eth0)" |
| 91 | +# bash docs/configurations/etc.iptables.rules.v4.sh $INTERFACENAME |
| 92 | +
|
| 93 | +# iptables-save > /etc/iptables/rules.v4 |
| 94 | +# ip6tables-save > /etc/iptables/rules.v6 |
| 95 | +``` |
| 96 | + |
| 97 | +5) Config grub2 password protection |
| 98 | +[Config grub2 password protection](https://github.com/hardenedlinux/harbian-audit/blob/master/docs/configurations/manual-operation-docs/how_to_config_grub2_password_protection.mkd) |
| 99 | + |
| 100 | +## Special Note |
| 101 | +Some check items check a variety of situations and are interdependent, they must be applied (fix) multiple times, and the OS must be a reboot after each applies (fix). |
| 102 | + |
| 103 | +### Items that must be applied after the first application(reboot after is better) |
| 104 | +8.1.32 Because this item is set, the audit rules will not be added. |
| 105 | + |
| 106 | +### Items that must be applied after all application is ok |
| 107 | +8.4.1 |
| 108 | +8.4.2 |
| 109 | +These are all related to the aide. It is best to fix all the items after they have been fixed to fix the integrity of the database in the system. |
| 110 | + |
| 111 | +### Items that need to be fix twice |
| 112 | +8.1.1.2 |
| 113 | +8.1.1.3 |
| 114 | +8.1.12 |
| 115 | +4.5 |
| 116 | + |
| 117 | +## Document |
| 118 | + |
| 119 | +### Harbian-audit benchmark for Debian GNU/Linux 9 |
| 120 | +This document is a description of the additions to the sections not included in the [CIS reference documentation](https://benchmarks.cisecurity.org/downloads/show-single/index.cfm?file=debian8.100). Includes STIG reference documentation and additional checks recommended by the HardenedLinux community. |
| 121 | + |
| 122 | +[CIS Debian GNU/Linux 8 Benchmark v1.0.0](https://benchmarks.cisecurity.org/downloads/show-single/index.cfm?file=debian8.100) |
| 123 | +[CIS Debian GNU/Linux 9 Benchmark v1.0.0](https://benchmarks.cisecurity.org/downloads/show-single/index.cfm?file=debian8.100) |
| 124 | +[harbian audit Debian Linux 9 Benchmark](https://github.com/hardenedlinux/harbian-audit/blob/master/docs/harbian_audit_Debian_9_Benchmark_v0.1.mkd) |
| 125 | + |
| 126 | +## harbian-audit License |
| 127 | +GPL 3.0 |
| 128 | + |
| 129 | +## OVH Disclaimer |
| 130 | + |
| 131 | +This project is a set of tools. They are meant to help the system administrator |
| 132 | +built a secure environment. While we use it at OVH to harden our PCI-DSS compliant |
| 133 | +infrastructure, we can not guarantee that it will work for you. It will not |
| 134 | +magically secure any random host. |
| 135 | + |
| 136 | +Additionally, quoting the License: |
| 137 | + |
| 138 | +> THIS SOFTWARE IS PROVIDED BY OVH SAS AND CONTRIBUTORS ``AS IS'' AND ANY |
| 139 | +> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 140 | +> WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 141 | +> DISCLAIMED. IN NO EVENT SHALL OVH SAS AND CONTRIBUTORS BE LIABLE FOR ANY |
| 142 | +> DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 143 | +> (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 144 | +> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 145 | +> ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 146 | +> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 147 | +> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 148 | +
|
| 149 | +## OVH License |
| 150 | +3-Clause BSD |
| 151 | + |
| 152 | +## Reference |
| 153 | + |
| 154 | +- **Center for Internet Security**: [https://www.cisecurity.org](https://www.cisecurity.org) |
| 155 | +- **STIG V1R4**: [https://iasecontent.disa.mil/stigs/zip/U_Red_Hat_Enterprise_Linux_7_V1R4_STIG.zip](https://iasecontent.disa.mil/stigs/zip/U_Red_Hat_Enterprise_Linux_7_V1R4_STIG.zip) |
| 156 | +- **Firewall Rules**: [https://github.com/citypw/arsenal-4-sec-testing/blob/master/bt5_firewall/debian_fw](https://github.com/citypw/arsenal-4-sec-testing/blob/master/bt5_firewall/debian_fw) |
| 157 | +- **harbian-audit Readme**: [https://github.com/hardenedlinux/harbian-audit/blob/master/README.md](https://github.com/hardenedlinux/harbian-audit/blob/master/README.md) |
0 commit comments