|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!关于企业IT体系建立宁静性成绩在任什么时候候都不会成为一个过期的话题,企业在构建合适本人营业需求的IT体系之初和全部IT体系性命周期内,体系的宁静运转都是一项十分主要的事情,而作为体系运维职员更有义务为包管体系的宁静、不乱的运转事必躬亲。
So本博文供应了关于Linux体系宁静加固的详细完成剧本及基线反省标准,以供主机保护职员参考进修。
个中以下剧本次要完成的功效包含:
*加固项包含:暗码长度、session超不时间、删除不必的帐号和组、限定root用户间接telnet或rlogin、ssh
*反省是不是存在除root以外UID为0的用户、确保root用户的体系路径中不包括父目次,在非需要的情形下,不该包括组权限为777的目次
*反省操纵体系Linux用户umask设置、反省主要目次和文件的权限、克制除root以外的用户su操纵、查找体系中任何人都有写权限的目次
*查找体系中没有属主的文件、查找体系中的埋没文件、判别日记与审计是不是合规、登录超时设置、禁用不用要的办事
*linux宁静加固合用于redhat、centos5.8至6.2
详细内容以下,请分离本身营业需求举行体系级加固:
#1、---------------------------------------------------------------------
echo"删除不必的帐号和组"
echo"deleteunusedusersandgrups"
foriinlpsyncshutdownhaltnewsuucpoperatorgamesgopher
do
echo"willdeleteuser$i"
userdel$i
echo"user$ihavedelete"
done
foriinlpsyncshutdownhaltnewsuucpoperatorgamesgopher
do
echo"willdeletegroup$i"
groupdel$i
echo"group$ihavedelete"
done
date=`date+%F`
#2、-----------------------------------------------
#section1暗码请求暗码长度年夜于8,口令90天过时/etc/login.defs
#-----------------------------------------------
#---------------------------------------------------------------------
echo"cp/etc/login.defsto/etc/login.defs.bak_%date"
echo"#-------------------------------------"
cp/etc/login.defs/etc/login.defs.bak_$date
#echo"反省暗码的设置"
echo"Checktheconfigureforuserspassword."
echo"#-------------------------------------"
foriinPASS_MAX_DAYSPASS_MIN_LENPASS_MIN_DAYSPASS_WARN_AGE
do
cat/etc/login.defs|grep$i|grep-v#
done
#setpasswordminlength8
echo"#-------------------------------------"
echo"Setuserspasswordminlengthis8"
sed-i/PASS_MIN_LEN/s/5/8/g/etc/login.defs
echo"#-------------------------------------"
#setpasswordmaxday90
#echo"setpasswordexpired90day"
#sed-i/PASS_MAX_DAYS/s/99999/90/g/etc/login.defs
#3、---------------------------------------------------------------------
echo"#反省是不是存在空口令"
echo"Checkiftherehaveuserwithoutpassword!"
echo"#-------------------------------------"
awk-F:($2==""){print$1}/etc/shadow
#4、-----------------------------------------------
#section2限定root用户间接telnet或rlogin,ssh有效
######倡议在/etc/securetty文件中设置:CONSOLE=/dev/tty01
#---------------------------------------------------------------------
#帐号与口令-反省是不是存在除root以外UID为0的用户
#echo"#反省体系中是不是存在别的id为0的用户"
echo"Checkifthesystemhaveotherusersidis0"
echo"#-------------------------------------"
mesg=`awk-F:($3==0){print$1}/etc/passwd|grep-vroot`
if[-z$mesg]
then
echo"Theredonthaveotheruseruid=0"
else
echo
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo"$mesguid=0"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi
#5、---------------------------------------------------------------------
echo"#确保root用户的体系路径中不包括父目次,在非需要的情形下,不该包括组权限为777的目次"
echo"checkthePathsetforroot,makesurethepathforrootdonthavefatherdirectoryand777rights"
echo"#-------------------------------------"
echo$PATH|egrep(^|:)(.|:|$)
find`echo$PATH|tr:`-typed(-perm-002-o-perm-020)-ls
#6、---------------------------------------------------------------------
echo"#反省操纵体系Linux近程毗连"
echo"Checkifsystemhaveremoteconnectionseting"
echo"#-------------------------------------"
find/-name.netrc
find/-name.rhosts
echo"反省操纵体系Linux用户umask设置"
echo"Checkthesystemusersumasksetting"
echo"#-------------------------------------"
foriin/etc/profile/etc/csh.login/etc/csh.cshrc/etc/bashrc
do
grep-Humask$i|grep-v"#"
done
###################设置umask为027
#7、---------------------------------------------------------------------
#echo"#反省主要目次和文件的权限"
##echo"Checktheimportantfilesanddirectoryrights"
echo"#-------------------------------------"
foriin/etc/etc/rc.d/init.d/tmp/etc/inetd.conf/etc/passwd/etc/shadow/etc/group/etc/security/etc/services/etc/rc*.d
do
ls-ld$i
done
echo-n"Pleasecheckiftheoutputisok?yesorno:"
readi
case$iin
y|yes)
break
;;
n|no)
echo"Pleaserechecktheoutput!"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
continue
;;
*)
echo"pleaseinputyesorno"
;;
esac
#8、---------------------------------------------------------------------
#echo"#设置rc.d下剧本的权限"
echo"Configurethescriptsright(750)inrc.ddirectory"
echo"#-------------------------------------"
chmod-R750/etc/rc.d/init.d/*
chmod755/bin/su改了以后只能rootsu,没有了s位其余用户没法乐成su
chmod664/var/log/wtmp
#chattr+a/var/log/messages
#9、---------------------------------------------------------------------
echo"#查找体系中存在的SUID和SGID步伐"
echo"FindthefileshavesuidorSgid"
echo"#-------------------------------------"
forPARTin`grep-v^#/etc/fstab|awk($6!="0"){print$2}`;do
find$PART(-perm-04000-o-perm-02000)-typef-xdev-print|xargsls-ld
done
echo-n"Pleasecheckiftheoutputisok?yesorno:"
readi
case$iin
y|yes)
break
;;
n|no)
echo"Pleaserechecktheoutput!"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
continue
;;
*)
echo"pleaseinputyesorno"
;;
esac
#10、---------------------------------------------------------------------
echo"#查找体系中任何人都有写权限的目次"
echo"Findthedirectoryeveryonehavethewriteright"
echo"#-------------------------------------"
forPARTin`awk($3=="ext2"||$3=="ext3")
{print$2}/etc/fstab`;do
find$PART-xdev-typed(-perm-0002-a!-perm-1000)-print|xargsls-ld
done
echo-n"Pleasecheckiftheoutputisok?yesorno:"
readi
case$iin
y|yes)
break
;;
n|no)
echo"Pleaserechecktheoutput!"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
continue
;;
*)
echo"pleaseinputyesorno"
;;
esac
#11、---------------------------------------------------------------------
#echo"#查找体系中任何人都有写权限的文件"
echo"Findthefileseveryonehavewriteright"
echo"#-------------------------------------"
forPARTin`grep-v^#/etc/fstab|awk($6!="0"){print$2}`;do
find$PART-xdev-typef(-perm-0002-a!-perm-1000)-print|xargsls-ld
done
echo-n"Pleasecheckiftheoutputisok?yesorno:"
readi
case$iin
y|yes)
break
;;
n|no)
echo"Pleaserechecktheoutput!"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
continue
;;
*)
echo"pleaseinputyesorno"
;;
esac
#12、---------------------------------------------------------------------
echo"#查找体系中没有属主的文件"
echo"Findnoownerornogroupfilesinsystem"
echo"#-------------------------------------"
forPARTin`grep-v^#/etc/fstab|grep-vswap|awk($6!="0"){print$2}`;do
find$PART-nouser-o-nogroup|grep-v"vmware"|grep-v"dev"|xargsls-ld
done
echo-n"Pleasecheckiftheoutputisok?yesorno:"
readi
case$iin
y|yes)
break
;;
n|no)
echo"Pleaserechecktheoutput!"
echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
continue
;;
*)
echo"pleaseinputyesorno"
;;
esac
#13、---------------------------------------------------------------------
###echo"#查找体系中的埋没文件"
##echo"Findthehidingfileinsystem"
##echo"#-------------------------------------"
###linux实行报错扫除/dev”目次下的那些文件
####find/-name("..*"-o"…*"-o".xx"-o".mail")-print-xdev
###find/-name"…*"-print-xdev|cat-v
##find/(-name".*"-o-name"…*"-o-name".xx"-o-name".mail")-xdev
##echo-n"Ifyouhavecheckalltheoutputfilesifcorrectyesorno?:"
##readi
##case$iin
##y|yes)
##break
##;;
##n|no)
##echo"Pleaserechecktheoutput!"
##echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
##continue
##;; |
|