一些零碎的加固知识点
1、history安全
文件中保存了500条使用过的命令,
(1)、/etc/profile文件中的"HISTFILESIZE"的".bash_history"文件中可以保存的旧命令条数。
(2)、避免删除.bash_history,防止入侵者清除或删除它最后执行的命令或者重定向到/dev/null
chattr +a .bash_history
chattr +i .bash_history
ps: 用户每次登录所做的任何操作并不会直接存储到.bash_history文件中,而是保存在一个变量中,只有当用户退出登录以后,这个变量才会被写入到.bash_history文件中。
2、mysql history安全
用户登录数据库后执行的sql命令也会被mysql记录在用户目录的.mysql_history文件里。
所以在shell登录及备份的时候不要在-p后直接加密码,而是在提示后在输入数据库密码。
另外下面这两个文件我们也应该不让他记录我们的操作。
cp .bash_history .bash_historybak cp .mysql_history mysql_historybak rm .bash_history .mysql_history ln -s /dev/null .bash_history ln -s /dev/null .mysql_history
3、chmod危险文件
chmod 700 /bin/ping chmod 700 /usr/bin/finger chmod 700 /usr/bin/who chmod 700 /usr/bin/w chmod 700 /usr/bin/locate chmod 700 /usr/bin/whereis chmod 700 /sbin/ifconfig chmod 700 /usr/bin/pico chmod 700 /usr/bin/vi chmod 700 /usr/bin/vim chmod 700 /usr/bin/make chmod 700 /bin/netstat chmod 700 /usr/bin/tail ...
4、最后10分钟使用的文件
find /etc -cmin -10 # 使用find查找10分钟以内创建的文件
5、隐藏服务器系统信息
缺省情况下,登录linux服务器时,它会告诉你linux发行版的名称、版本、内核版本、服务器的名称。
为了不让这些默认的信息泄露出来,我们要删除/etc/issue和/etc/issue.net这两个文件,或者把这2个文件改名,效果是一样的。
mv /etc/issue /etc/issuebak
mv /etc/issue.net /etc/issue.netbak
6、服务器禁止ping
cp /etc/rc.d/rc.local /etc/rc.d/rc.localbak vi /etc/rc.d/rc.local # 在文件末尾添加 echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all # 参数0表示允许,1表示禁止
7、防止DOS攻击
对系统所有的用户设置资源限制可以防止Dos类型攻击。如最大进程数和内存使用数量等。
在/etc/security/limits.conf中添加
* hard core 0
* hard rss 5000
* hard nproc
然后必须编辑/etc/pam.d/login
session required/lib/security/pam_limits.so
上面的命令禁止core files "core 0"
限制进程数为"nproc 50"
限制内存使用为5M "rss 5000"
浙公网安备 33010602011771号