mirror of
https://github.com/hardenedlinux/harbian-audit.git
synced 2025-07-30 09:06:01 +02:00
Modify audit and apply methods for redhat/CentOS to 10.1.2 10.1.3 10.1.4
This commit is contained in:
parent
490ee96c94
commit
0cf45160f4
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# harbian audit 7/8/9 Hardening
|
# harbian audit 7/8/9 or CentOS8 Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -14,45 +14,31 @@ set -u # One variable unset, it's over
|
|||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
|
||||||
PACKAGE='login'
|
|
||||||
OPTIONS='PASS_MIN_DAYS=7'
|
OPTIONS='PASS_MIN_DAYS=7'
|
||||||
FILE='/etc/login.defs'
|
FILE='/etc/login.defs'
|
||||||
SHA_FILE='/etc/shadow'
|
SHA_FILE='/etc/shadow'
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
is_pkg_installed $PACKAGE
|
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
||||||
if [ $FNRET != 0 ]; then
|
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
||||||
crit "$PACKAGE is not installed!"
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
else
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
ok "$PACKAGE is installed"
|
if [ $FNRET = 0 ]; then
|
||||||
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
ok "$PATTERN is present in $FILE"
|
||||||
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
else
|
||||||
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
crit "$PATTERN is not present in $FILE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
fi
|
||||||
if [ $FNRET = 0 ]; then
|
|
||||||
ok "$PATTERN is present in $FILE"
|
|
||||||
else
|
|
||||||
crit "$PATTERN is not present in $FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $(egrep ^[^:]+:[^\!*] $SHA_FILE | awk -F: '$4 < "'$SSH_VALUE'" {print $1}' | wc -l) -gt 0 ]; then
|
if [ $(egrep ^[^:]+:[^\!*] $SHA_FILE | awk -F: '$4 < "'$SSH_VALUE'" {print $1}' | wc -l) -gt 0 ]; then
|
||||||
crit "Have least user's mininum password lifttime is not equal or less than $SSH_VALUE day"
|
crit "Have least user's mininum password lifttime is not equal or less than $SSH_VALUE day"
|
||||||
else
|
else
|
||||||
ok "All user's mininum password lifttime is $SSH_VALUE day"
|
ok "All user's mininum password lifttime is $SSH_VALUE day"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply () {
|
apply () {
|
||||||
is_pkg_installed $PACKAGE
|
|
||||||
if [ $FNRET = 0 ]; then
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
else
|
|
||||||
crit "$PACKAGE is absent, installing it"
|
|
||||||
install_package $PACKAGE
|
|
||||||
fi
|
|
||||||
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
||||||
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
||||||
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# harbian audit 7/8/9 Hardening
|
# harbian audit 7/8/9 or CentOS8 Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -14,18 +14,12 @@ set -u # One variable unset, it's over
|
|||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
|
||||||
PACKAGE='login'
|
|
||||||
OPTIONS='PASS_WARN_AGE=7'
|
OPTIONS='PASS_WARN_AGE=7'
|
||||||
FILE='/etc/login.defs'
|
FILE='/etc/login.defs'
|
||||||
SHA_FILE='/etc/shadow'
|
SHA_FILE='/etc/shadow'
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
is_pkg_installed $PACKAGE
|
|
||||||
if [ $FNRET != 0 ]; then
|
|
||||||
crit "$PACKAGE is not installed!"
|
|
||||||
else
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
||||||
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
||||||
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
@ -40,18 +34,10 @@ audit () {
|
|||||||
else
|
else
|
||||||
ok "All user's maxinum password lifttime is equal or less than $SSH_VALUE day"
|
ok "All user's maxinum password lifttime is equal or less than $SSH_VALUE day"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply () {
|
apply () {
|
||||||
is_pkg_installed $PACKAGE
|
|
||||||
if [ $FNRET = 0 ]; then
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
else
|
|
||||||
crit "$PACKAGE is absent, installing it"
|
|
||||||
install_package $PACKAGE
|
|
||||||
fi
|
|
||||||
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
SSH_PARAM=$(echo $OPTIONS | cut -d= -f 1)
|
||||||
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
SSH_VALUE=$(echo $OPTIONS | cut -d= -f 2)
|
||||||
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# harbian audit 7/8/9 Hardening
|
# harbian audit 7/8/9 or CentOS8 Hardening
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -14,40 +14,26 @@ set -u # One variable unset, it's over
|
|||||||
|
|
||||||
HARDENING_LEVEL=3
|
HARDENING_LEVEL=3
|
||||||
|
|
||||||
PACKAGE='login'
|
|
||||||
OPTIONS='ENCRYPT_METHOD=SHA512'
|
OPTIONS='ENCRYPT_METHOD=SHA512'
|
||||||
FILE='/etc/login.defs'
|
FILE='/etc/login.defs'
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
is_pkg_installed $PACKAGE
|
for SSH_OPTION in $OPTIONS; do
|
||||||
if [ $FNRET != 0 ]; then
|
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
||||||
crit "$PACKAGE is not installed!"
|
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
||||||
else
|
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
||||||
ok "$PACKAGE is installed"
|
does_pattern_exist_in_file $FILE "$PATTERN"
|
||||||
for SSH_OPTION in $OPTIONS; do
|
if [ $FNRET = 0 ]; then
|
||||||
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
ok "$PATTERN is present in $FILE"
|
||||||
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
else
|
||||||
PATTERN="^$SSH_PARAM[[:space:]]*$SSH_VALUE"
|
crit "$PATTERN is not present in $FILE"
|
||||||
does_pattern_exist_in_file $FILE "$PATTERN"
|
fi
|
||||||
if [ $FNRET = 0 ]; then
|
done
|
||||||
ok "$PATTERN is present in $FILE"
|
|
||||||
else
|
|
||||||
crit "$PATTERN is not present in $FILE"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply () {
|
apply () {
|
||||||
is_pkg_installed $PACKAGE
|
|
||||||
if [ $FNRET = 0 ]; then
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
else
|
|
||||||
crit "$PACKAGE is absent, installing it"
|
|
||||||
install_package $PACKAGE
|
|
||||||
fi
|
|
||||||
for SSH_OPTION in $OPTIONS; do
|
for SSH_OPTION in $OPTIONS; do
|
||||||
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
SSH_PARAM=$(echo $SSH_OPTION | cut -d= -f 1)
|
||||||
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
SSH_VALUE=$(echo $SSH_OPTION | cut -d= -f 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user