手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网站运营>建站经验>列表

Linux的安全

来源:互联网 作者:west263.com 时间:2008-04-16
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

-rwxr-sr-x 1 root slocate 24744 Sep 20 10:29 /usr/bin/slocate
*-rws--x--x 1 root root 14024 Sep 9 01:01 /usr/bin/chfn
*-rws--x--x 1 root root 13768 Sep 9 01:01 /usr/bin/chsh
*-rws--x--x 1 root root 5576 Sep 9 01:01 /usr/bin/newgrp
*-rwxr-sr-x 1 root tty 8328 Sep 9 01:01 /usr/bin/write
-rwsr-xr-x 1 root root 21816 Sep 10 16:03 /usr/bin/crontab
*-rwsr-xr-x 1 root root 5896 Nov 23 21:59 /usr/sbin/usernetctl
*-rwsr-xr-x 1 root bin 16488 Jul 2 10:21 /usr/sbin/traceroute
-rwxr-sr-x 1 root utmp 6096 Sep 13 20:11 /usr/sbin/utempter
-rwsr-xr-x 1 root root 14124 Aug 17 22:31 /bin/su
*-rwsr-xr-x 1 root root 53620 Sep 13 20:26 /bin/mount
*-rwsr-xr-x 1 root root 26700 Sep 13 20:26 /bin/umount
*-rwsr-xr-x 1 root root 18228 Sep 10 16:04 /bin/ping
*-rwxr-sr-x 1 root root 3860 Nov 23 21:59 /sbin/netreport
-r-sr-xr-x 1 root root 26309 Oct 11 20:48 /sbin/pwdb_chkpwd
* 用下面的命令禁止上面选出来的SUID的程式:
[root@deep]# chmod a-s /usr/bin/chage
[root@deep]# chmod a-s /usr/bin/gpasswd
[root@deep]# chmod a-s /usr/bin/wall
[root@deep]# chmod a-s /usr/bin/chfn
[root@deep]# chmod a-s /usr/bin/chsh
[root@deep]# chmod a-s /usr/bin/newgrp
[root@deep]# chmod a-s /usr/bin/write
[root@deep]# chmod a-s /usr/sbin/usernetctl
[root@deep]# chmod a-s /usr/sbin/traceroute
[root@deep]# chmod a-s /bin/mount
[root@deep]# chmod a-s /bin/umount
[root@deep]# chmod a-s /bin/ping
[root@deep]# chmod a-s /sbin/netreport
假如您想知道这些程式到底有什么用,能够用man命令查看帮助。
例如:
[root@deep]# man netreport

35. 异常和隐含文档
在系统的每个地方都要查看一下有没有异常和隐含文档(点号是起始字符的,用“ls”命令看不到的文档),因为这些文档可能是隐藏的黑客工具或其他一些信息(口令破解程式、其他系统的口令文档,等等)。在UNIX下,一个常用的技术就是用一些特别的名,如:“...”、“.. ”(点点空格)或“..^G”(点点control-G),来隐含文档或目录。用“find”程式能够查找到这些隐含文档。
例如:
[root@deep]# find / -name ".. " -print -xdev
[root@deep]# find / -name ".*" -print -xdev | cat -v
同时也要注意象“.xx”和“.mail”这样的文档名的。(这些文档名看起来都很象正常的文档名)

36. 查找任何SUID/SGID位有效的文档
系统中SUID和SGID文档很有可能成为安全隐患,必须被严密监控。因为这些程式都给执行他的用户一些特权,所以要确保危险的SUID程式没有被安装。
黑客常常利用SUID程式,故意留下一个SUID的程式作为下次进入系统的后门。注意系统中任何的SUID和SGID的程式,并跟踪他们,这样您就能够尽早发现入侵者。
用下面的命令查找系统中任何的SUID和SGID程式:
[root@deep]# find / -type f ( -perm -04000 -o -perm -02000 ) -exec ls -lg {} ;
注意:参考《第九章 安全软件》中关于sXid的介绍,sXid能够为您每天自动的完成这项任务,并用email报告结果。

37. 查找任何人都有写权限的文档和目录
假如黑客获得并改变了一些系统文档,这些系统文档就会成为安全漏洞。任何人都有写权限的目录也同样有危险,因为黑客能够根据他们的需要自由地添加或删除文档。在正常情况下有些文档是可写的,包括一些“/dev”目录下的文档和符号连接。
在系统中定位任何人都有写权限的文档和目录用下面的命令:
[root@deep]# find / -type f ( -perm -2 -o -perm -20 ) -exec ls -lg {} ;
[root@deep]# find / -type d ( -perm -2 -o -perm -20 ) -exec ls -ldg {} ;
注意:象Tripware软件这样的文档和目录完整性的检查器能够扫描、管理和方便地发现被改变过的任何人都有写权限的文档。参考《第九章 安全软件》以获得关于Tripware的更多信息。

38. 查找没有主人的文档
发现没有主人的文档就意味着有黑客入侵您的系统了。不能允许没有主人的文档存在。假如在系统中发现了没有主人的文档或目录,先查看他的完整性,假如一切正常,给他一个主人。有时候卸载程式可能会出现一些没有主人的文档或目录,在这种情况下能够把这些文档和目录删除掉。
定位系统中没有主人的文档用下面的命令:
[root@deep]# find / -nouser -o -nogroup
注意:不用管“/dev”目录下的那些文档。

39. 查找“.rhosts”文档
查找“.rhosts”文档是日常管理工作的一部分,因为这些文档不允许在系统中存在。记住,黑客有可能只要有一个帐号就可能入侵整个网络。
能够用下面的命令定位系统中的“.rhosts”文档:
[root@deep]# find /home -name .rhosts
也能够用一个cron任务定期地查看、报告和删除$HOME/.rhosts文档。同时,也必须让用户知道您会经常地进行这种审核。
用root身份在“/etc/cron.daily”目录下,创建“find_rhosts_files”脚本文档(touch /etc/cron.daily/find_rhosts_files),并在脚本文档中加入下面几行:
#!/bin/sh
/usr/bin/find /home -name .rhosts | (cat <<EOF
This is an automated report of possible existent ".rhosts" files on the server
deep.openarch.com, generated by the find utility command.
New detected ".rhosts" files under the "/home" directory include:
EOF
cat
) | /bin/mail -s "Content of .rhosts file audit report" root
然后,让这个脚本可执行,把任何者和组配置成“root”:
[root@deep]# chmod 755 /etc/cron.daily/find_rhosts_files
[root@deep]# chown 0.0 /etc/cron.daily/find_rhosts_files
每一天都会有一份主题为“Content of .rhosts file audit report”的邮件发给“root”,报告新发现的“.rhosts”文档。

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!