零零社区|百姓的网上家园-互动交流平台!(0.0)=^_^=(00社区)

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz

使用Yassp工具包安装安全的Solaris系统 (三)

2013-4-5 11:23| 发布者: 123456000000| 查看: 19| 评论: 0

摘要: 7、补丁 系统在安装时会自动安装推荐补丁包,但是它并不包含所有的安全补丁。定期检查最新的补丁, 安装了最新安全补丁的系统要比没有安装的系统可靠的多。 补丁通常有标准补丁(Standardpatches)、推荐补丁(Recom ...
7、补丁 
系统在安装时会自动安装推荐补丁包,但是它并不包含所有的安全补丁。定期检查最新的补丁, 

安装了最新安全补丁的系统要比没有安装的系统可靠的多。 
补丁通常有标准补丁(Standard patches)、推荐补丁(Recommended patches)、安全补丁( 

Security patches)、2000年补丁(Y2K patches),patch clusters是以上补丁的集成包。单点 

补丁(Point patches)是针对特定问题的补丁。 

通过下列方法,了解已知的漏洞及相应的补丁程序: 
1. 订阅相关组织及公司(如CERT/First、SUN、Bugtraq)的邮件列表。 
2. 订阅有关漏洞及补丁的邮件列表,如Security Portal(Solaris Digest)、 

SecurityFocus(Sunr的部分)或者SANS。 
3. 定期使用工具,检查服务器上安装的补丁是否与Sun发布的最新补丁列表相一致。 
4. 一至两月检查一次Sun推荐的补丁包,需要注意的是安装推荐补丁包时,如果对内核打补丁可 

能会导致一些应用的不正常。 
5. 某些第三方的应用的补丁也需要加以关注。 

注:安装补丁可能会改动Yassp的配置,因此在安装完补丁重启系统后,要仔细检查是否启动了不 

需要的进程。 

针对补丁的工具 
* GetApplyPatch和CheckPatches是两个管理Solaris补丁的Bshell的脚本工具。 
1.CheckPatches使用showrev命令查看已经安装的补丁,并与Solaris的补丁报告相比较,列出需 

要安装的推荐及安全补丁。补丁报告SolarisX.PatchReport通常在当前目录下,也可以使用-f参 

数通过FTP下载最新的补丁报告 
>./CheckPatches -f 
2.GetApplyPatch:用来获得并安装最新的补丁,使用补丁号码作为执行脚本时的参数。运行时, 

会提示是否下载,显示补丁的README文件,安装补丁后,删除安装目录。使用'-b'参数以"batch 

mode"运行,则不做提示。 
>./GetApplyPatch 108875-07 
CheckPatches.cron是一个自动运行的脚本,并将结果mail给管理员。 
3.同时使用这两个脚本文件,获得需要的补丁并进行安装。 
>./CheckPatches | ./GetApplyPatch 
GetApplyPatch.cron可以用来自动执行,取得补丁并进行安装,但是关键任务的服务器上不推荐 

使用它。 
4.其它的特点: 
* 带有man帮助文件 
* 支持Solaris Intel及Sparc,通过测试 
* 可以设置ftp代理 
* CheckPatches可以忽略无需安装的补丁。比如,在Solaris8 x86系统中,运行CheckPatches后 

,提示需要下面的补丁: 
109897-03 SunOS 5.8_x86: USB patch 
109952-01 SunOS 5.8_x86: jserver buffer overflow 
110417-02 SunOS 5.8_x86: ATOK12 patch 
对于这些补丁,我们并不想安装。创建Solaris8_x86.PatchReport.Except,在文件中加入上面三 

行,在次运行CheckPatches脚本时会将它们忽略。 
* 也可以对CheckPatches的命令输出做过滤,如: 
./CheckPatches | egrep -v "109897|109952|110417" 
* Sunsolve提供的Patchdiag工具,与最新的Patchdiag.xref一起,可以检查系统缺少哪些补丁, 

然后下载并安装这些补丁。 
* 使用SecurityFocus的vulnerability calculator工具,运行下面的命令 
(http://securityfocus.com/focus/sun/form.html) 
>showrev -p |cut -f2 -d' ' | xargs 
将结果粘贴到窗囗中,然后选择操作系统。在得出结果的中选择与自己主机上的应用相关的内容 

进行修补。 
* FastPatch可以用来替代patchadd命令,它的执行速度更快。 
* Patchreport是另外一个用perl语言编写的非常全面的补丁检查工具。 

8、RPC 
在关键任务主机,避免使用RPC服务。RPC使用动态分配的端囗及非标准的存取控制方法。但是, 

确有一些应用需要使用RPC,如CDE、Open Windows、Disksuite及Legato Networker。 

如何提高Disksuite的安全性 
Disksuite是系统内置的工具,用来做磁盘镜象及设置RAID。它需要RPC的支持(在inetd中运行的 

rpc.metamhd和rpc.metad)。 
1. 尽量不运行Disksuite 
* 硬件RAID的好处在于不需要特殊的软件支持。这对于对安全性要求较高的系统十分有利。而且 

当出现问题时,你会发现Disksuite并不是太容易使用的。 
* 对于象是系统盘等,数据并不会频繁变动的系统盘,作镜像(cold mirroring)就足够了,使用 

脚本mirror_boot.sh可以完成此项工作。 
2. 运行Disksuite,但是停止RPC服务。停止inetd.conf中的'metad'服务会引起以下结果: 
* 'metatool'将不会工作,但是命令行工具还可以运行。为了应付系统盘的灾难性错误,最好了 

解这些命令行工具。 
* Disksets-系统间共享的metadevices将不能使用。 
3. 如果使用Disksuite和RPC,使用Wietse Venema的RPCBIND。 

* Solaris8系统自带的Sunscreen EFS Lite Firewall可以用来对rpc服务的存取进行限制。 
* ipfilter也可以用来做限制RPC服务访问的本地防火墙。 
* IPfilter可以在8以前的老版本的Solaris上运行,并且是免费的。 
* It's doesn't have an RPC state based engine though(so it can't filter on RPC 

PRogram names or allow RPC to specific destinations)。 
* But it can be used to allow all localhost RPC traffic(enough for some RPC 

applications such as Disksuite or CDE)and deny all remote traffice except,say,HTTP or 

whatever service is provided to remote hosts。 
* 使用Wietse Venema的rpcbind(包含在Yassp的tarball里),可以提供类似tcp wrapper的访问控 

制和日志记录。Rpcbind是一种“目录”服务用来定位某一种服务(通过RPC名或者RPC号)。因为 

它并不是连接服务的中介,因此它并不能真正为RPC程序提供访问控制。用端囗扫描器可以检测激 

活的RPC服务,除非内核被定制成过滤这些连接,否则并不能防止对服务的访问。 

9、日志、Cron、许可 
配置日志及pruning: 
* Syslog日志:Yassp使用修改过的/etc/syslog.conf配置,开启了更多的日志记录保存在 

/var/adm/messages中。同时也安装了一个可选的/etc/syslog.conf.server,是为loGhosts设计 

的并将不同的服务存在分开的log文件中。 
* Yassp关闭了root帐号cron中有关log的条目。添加了运行'daily'脚本。 





配置Syslog 
Syslog客户端:在/etc/hosts文件中指定log服务器。 
* 测试log服务器是否正常 
logger -p auth.warn "test of syslog",检查是否记录在log服务器里。 
* 在log服务器及本地同时记录日志,取消/etc/syslog.conf中的下一行注释: 
*.err;auth.info;kern.debug /var/adm/messages 
* 如果日志记录不能正常工作,可以参照syslog.conf中的例子及提示。 
Syslog服务器(loghost): 
* log服务器需要一块大的磁盘用来保存日志文件。 
* 在Solaris8系统中,Yassp将以"-t"参数启动syslog,因此它将不接受其它主机的记录日志的请 

求。如果想要设置集中的log服务器,需要在/etc/yassp.conf中设置SYSLOGFLAGS=""。 
* Yassp还安装了一个/etc/syslog.conf.server配置文件,是针对log服务器并将不同的服务产生 

的日志存于/var/log目录下不同的文件中。用它覆盖配置文件并重新启动syslog: 
mv /etc/syslog.conf /etc/syslog.conf.client 
cp /etc/syslog.conf.server /etc/syslog.conf 
kill -l `cat /etc/syslog.pid` 
* 使用rotate_log工具对日志进行管理和压缩,在root的cron中加入: 
##Prune syslog logs weekly,keeping the last 6 months or so: 
55 23 * * 6 /secure/rotate_log -n 40 alertlog 
55 23 * * 6 /secure/rotate_log -n 40 authlog 
55 23 * * 6 /secure/rotate_log -n 40 cronlog 
55 23 * * 6 /secure/rotate_log -n 40 daemonlog 
55 23 * * 6 /secure/rotate_log -n 40 kernlog 
55 23 * * 6 /secure/rotate_log -n 40 local0log 
55 23 * * 6 /secure/rotate_log -n 40 local2log 
55 23 * * 6 /secure/rotate_log -n 40 local5log 
55 23 * * 6 /secure/rotate_log -n 40 newslog 
55 23 * * 6 /secure/rotate_log -n 40 userlog 
55 23 * * 6 /secure/rotate_log -n 40 lprlog 
55 23 * * 6 /secure/rotate_log -n 40 maillogd 
在root的cron中加入每年清理日志文件的条目 
##Empty login/logout records at year end 
0 0 31 12 * /secure/wtrim.pl wtmp 20 
0 0 31 12 * /secure/wtrim.pl wtmpx 20 

#Solaris 2.x logs 
0 4 * * 6 /secure/totate_log -L /var/adm -n 30 loginlog 
0 4 * * 6 /secure/rotate_log -L /var/adm -n 30 sulog 
0 4 * * 6 /secure/rotate_log -L /var/adm -n 2 vold.log 
0 4 * * 6 /secure/rotate_cron 

其它的需要在root的cron设置条目: 
每天与可靠的时间源进行时间同步,使用rdate(NTP会更加精确,但会带来相应的风险) 
##Synchronise the time: 
0 * * * * /usr/bin/rdate YOURTIMEHOST >/dev/null 2>&1 
安装检查重要进程是否运行的脚本,monitor_processes.pl并在root的cron中加入: 
##Check that important processes are running during office hours: 
##[If you run 7x24,modify accordingly] 
0,30 8-19 * *1-5 /secure/monitor_processes.pl sshd httpd 

每次安装新的程序后,最好在文件中记录下来,如: 
cat >/etc/mods<15.10.00 james New install of Solaris8 and tools 
EOF 

10、限制SUID文件 
设置SUID位的文件,允许用户以文件所有者的权限执行此程序。常用来让普通用户执行只有root 

能运行的程序,但是存在缓存溢出的风险。 
* Solaris有很多“SUID root”的执行程序,每一个都会带来风险,因此尽可能多的停止SUID程 

序。 
* 阅读SUID的参考文件 

发现系统中的SUID文件 
使用find命令: 
find / -perm -u+s -ls 
find / -perm -g+s -ls 查找GUID程序 

如何处理SUID文件: 
* 直接删除 
* 关闭程序(chmod 000 FILENAME) 
* 移去SUID位(chmod ug-s FILENAME) 
* 对文件回以组限制(首先移去所有人的权限 chmod o-rwx),允许组访问(chgrp MYGROUP 

MYFILE)。 

哪些SUID文件需要回以限制 
* 在一些具有用户帐号的敏感服务器上或者关键的进程由非root用户运行,应尽可能地减少SUID 

文件。 
* 对于可靠性要求非常高的系统,建议除"pt_chmod","utmp_update"和"su"以外,其余全停。 
* Reg Quinton解释了每一个SolarisSUID程序,并给出配置建议。 
* 例子: 
* 象uucp这样的工具,基本无用,可以删除 
pkgrm SUNWbnuu 
chmod ug-s /usr/bin/cu /usr/bin/uu* /usr/lib/uucp/* 
* 另一个没有用处的工具包是kcms(Kodak Color Management System) 
pkgrm SUNWkcspf SUNWcspx SUNWkcspg SUNWkcsrt 
chmod ug-s /usr/openwin/bin/kcms* 
* 如果不使用打印机 
chmod ug-s /usr/lib/lp/bin/netpr /usr/sbin/lpmove /usr/bin/lp /usr/bin/lpset 

/usr/bin/lpstat /usr/bin/cancel /etc/lp/alerts/printer 
* 只允许root使用r命令 
chmod ug-s /usr/bin/rcp /usr/bin/rlogin /usr/bin/rsh 
* 只允许root对网络进行侦听及列出进程列表 
chmod ug-s /usr/sbin/snoop /usr/sbin/devinfo /bin/rdist /usr/bin/netstat 

/usr/local/bin/top /usr/sbin/traceroute /usr/local/bin/lsof /usr/bin/*/ps 

/usr/ucb/*/ps /usr/sbin/*/whodo /usr/bin/*/uptime /usr/bin/*/w 
* 只允许root做备份和恢复 
chmod ug-s /usr/lib/fs/ufs/ufsdump /ufs/ib/fs/ufs/ufsrestore 
* 假设不使用YP、NIS+ 
chmod ug-s /usr/bin/chkey 
* 只允许root使用cron和at 
chmod ug-s /usr/bin/at /usr/bin/atq /usr/bin/atrm /usr/bin/crontab 
* 只允许root管理系统 
chmod ug-s /usr/bin/admintool /usr/lib/fs/ufs/quota /usr/bin/tip /usr/bin/fdformat 

/usr/bin/eject /usr/bin/volcheck /usr/bin/volrmmount /usr/bin/rmformat 
* 不使用Openwindows和CDE 
chmod ug-s /usr/dt/bin/* /usr/openwin/*/* 
* Sendmail:不做email服务器的主机不需要sendmail设置SUID位 
chmod u-s /usr/lib/sendmail 
* 进行以上的操作后,以“最终用户”模式安装的Solaris8系统中,SUID文件列表如下: 
usr/lib/pt_chmod /usr/lib/utmp_update /usr/bin/login /usr/bin/newgrp /usr/bin/newtask 

/usr/bin/pfexec /usr/bin/su /usr/bin/passwd /usr/sbin/allocate /usr/sbin/mkdevalloc 

/usr/sbin/mkdevmaps /usr/sbin/ping /usr/sbin/sacadm /usr/sbin/deallocate 

/usr/sbin/list_devices /usr/sbin/pmconfig /opt/local/bin/ssh /usr/bin/yppasswd 

/usr/bin/nispasswd are also SUID, but they are links to /usr/bin/passwd. 
* 在package数据库中仍然保留有末被改变的SUID文件 
find / -perm -u+s -exec pkgchk -l -p {} \; |more 
* 列出所有的SUID文件及属于哪一个包 
find / -perm -u+s -exec pkgchk -l -p {} \; | more 

路过

雷人

握手

鲜花

鸡蛋

相关阅读

发表评论

最新评论

相关分类


Archiver|手机版|小黑屋|00社区

GMT+8, 2023-1-31 10:51 , Processed in 0.042723 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部