File: //opt/BCLinux/bse/secure_check/c03_passComplex
#!/bin/sh
#=======================================================
InsertSection "check passwd minlen set"
count2=`grep -ir password /etc/pam.d/system-auth |grep minlen|grep -v "#"|wc -l`
if [ $count2 -ge 1 ];then
grep -ir password /etc/pam.d/system-auth |grep minlen |grep -v "#" | awk -F "minlen=" '{print $2}' | awk -F " " '{print $1}' |while read t_minlen
do
t_minlen=$(expr $t_minlen)
if [ -z $t_minlen ];then
Display --indent 2 --text "- Wrong Password minlen set... " --result WARNING --color RED
AddHP 0 1
elif [ -z `echo $t_minlen | sed 's/[0-9]//g'` ];then
if [ $t_minlen -le 7 ];then
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_01: $(loadtext TXT_WRN_C03_01)"
logtext "Suggestion: $(loadtext TXT_WRN_C03_01)"
Display --indent 2 --text "- Wrong Password MinLen set... " --result WARNING --color RED
AddHP 0 1
else
logtext "Has Password MinLen set, checking ok"
Display --indent 2 --text "- Has Password MinLen set... " --result OK --color GREEN
AddHP 1 1
fi
else
Display --indent 2 --text "- Wrong Password Minlen set... " --result WARNING --color RED
AddHP 0 1
fi
done
else
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_02: $(loadtext TXT_WRN_C03_02)"
logtext "Suggestion: $(loadtext TXT_SUG_03_01)"
Display --indent 2 --text "- No Password MinLen set... " --result WARNING --color RED
AddHP 0 1
fi
#=======================================================
InsertSection "check passwd ucredit set"
count3=`grep -ir password /etc/pam.d/system-auth | grep -w ucredit=-1 | grep -v "#" |wc -l`
if [ $count3 -ge 1 ];then
grep -ir password /etc/pam.d/system-auth |grep ucredit|grep -v "#" | awk -F "ucredit=" '{print $2}' | awk -F " " '{print $1}' |while read ucredit
do
if [ $ucredit -gt -1 ];then
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_03: $(loadtext TXT_WRN_C03_03)"
logtext "Suggestion: $(loadtext TXT_WRN_C03_02)"
Display --indent 2 --text "- Wrong Password ucredit set... " --result WARNING --color RED
AddHP 0 1
else
logtext "has passwd ucredit set, checking ok"
Display --indent 2 --text "- Has Password ucredit set... " --result OK --color GREEN
AddHP 1 1
fi
done
else
#tips="密码大写字母至少1个参数未设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_04: $(loadtext TXT_WRN_C03_04)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_02)"
Display --indent 2 --text "- No Password ucredit set... " --result WARNING --color RED
AddHP 0 1
fi
#=======================================================
InsertSection "check passwd lcredit set"
count4=`grep -ir password /etc/pam.d/system-auth | grep -w lcredit=-1 |grep -v "#" |wc -l`
if [ $count4 -ge 1 ];then
grep -ir password /etc/pam.d/system-auth | grep lcredit|grep -v "#" | awk -F "lcredit=" '{print $2}' | awk -F " " '{print $1}' |while read lcredit
do
if [ $lcredit -gt -1 ];then
#tips="密码小写字母至少1个参数未正确设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_05: $(loadtext TXT_WRN_C03_05)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_03)"
Display --indent 2 --text "- Wrong Password lcredit set... " --result WARNING --color RED
AddHP 0 1
else
logtext "has passwd lcredit set, checking ok"
Display --indent 2 --text "- Has Password lcredit set... " --result OK --color GREEN
AddHP 1 1
fi
done
else
#tips="密码小写字母至少1个参数未设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_06: $(loadtext TXT_WRN_C03_06)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_03)"
Display --indent 2 --text "- No Password lcredit set... " --result WARNING --color RED
AddHP 0 1
fi
#=======================================================
InsertSection "check passwd dcredit set"
count5=`grep -ir password /etc/pam.d/system-auth |grep -w dcredit=-1 |grep -v "#" |wc -l`
if [ $count5 -ge 1 ];then
grep -ir password /etc/pam.d/system-auth | grep dcredit |grep -v "#" | awk -F "dcredit=" '{print $2}' | awk -F " " '{print $1}' |while read dcredit
do
if [ $dcredit -gt -1 ];then
#tips="密码至少1个数字参数未正确设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_07: $(loadtext TXT_WRN_C03_07)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_04)"
Display --indent 2 --text "- Wrong Password dcredit set... " --result WARNING --color RED
AddHP 0 1
else
logtext "has passwd dcredit set, checking ok"
Display --indent 2 --text "- Has Password dcredit set... " --result OK --color GREEN
AddHP 1 1
fi
done
else
#tips="密码至少1个数字参数未设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_08: $(loadtext TXT_WRN_C03_08)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_04)"
Display --indent 2 --text "- No Password dcredit set... " --result WARNING --color RED
AddHP 0 1
fi
#=======================================================
InsertSection "check passwd ocredit set"
count6=`grep -ir password /etc/pam.d/system-auth |grep -w ocredit=-1 |grep -v "#" |wc -l`
if [ $count6 -ge 1 ];then
grep -ir password /etc/pam.d/system-auth |grep ocredit|grep -v "#" | awk -F "ocredit=" '{print $2}' | awk -F " " '{print $1}' |while read ocredit
do
if [ $ocredit -gt -1 ];then
#tips="密码至少1个特殊符号参数未正确设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_09: $(loadtext TXT_WRN_C03_09)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_05)"
Display --indent 2 --text "- Wrong Password ocredit set... " --result WARNING --color RED
AddHP 0 1
else
logtext "has passwd ocredit set, checking ok"
Display --indent 2 --text "- Has Password ocredit set... " --result OK --color GREEN
AddHP 1 1
fi
done
else
#tips="密码至少1个特殊符号参数未设置";
#echo "$S4:$tips"
echo "c03" >> $RESULT_FILE
echo "" >> $RESULT_FILE
logtext "WRN_C03_10: $(loadtext TXT_WRN_C03_10)"
logtext "Suggestion: $(loadtext TXT_SUG_C03_05)"
Display --indent 2 --text "- No Password ocredit set... " --result WARNING --color RED
AddHP 0 1
fi
#=======================================================
InsertSection "check passwd minclass set"
count7=`grep -ir password /etc/pam.d/system-auth |grep minclass|grep -v "#" |wc -l`
if [ $count7 -ge 1 ];then
egrep -ir "pwquality|pam_cracklib" /etc/pam.d/system-auth | sed -n "s/.*\(minclass=.*\) minlen.*/\1/p" | cut -d'=' -f2 |while read minclass
do
if [ -z $minclass ];then
Display --indent 2 --text "- Wrong Password minclass set... " --result WARNING --color RED
AddHP 0 1
elif [ -z `echo $minclass | sed 's/[0-9]//g'` ];then
if [ $minclass -lt 2 ];then
Display --indent 2 --text "- Wrong Password minclass set... " --result WARNING --color RED
AddHP 0 1
else
logtext "Has Password minclass set, checking ok"
Display --indent 2 --text "- Has Password minclass set... " --result OK --color GREEN
AddHP 1 1
fi
else
Display --indent 2 --text "- Wrong Password minclass set... " --result WARNING --color RED
AddHP 0 1
fi
done
else
Display --indent 2 --text "- No Password minclass set... " --result WARNING --color RED
AddHP 0 1
fi