[转帖]常见Unix安全设置方案(2)--Solaris 系列_VMware, Unix及操作系统讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  VMware, Unix及操作系统讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 3355 | 回复: 0   主题: [转帖]常见Unix安全设置方案(2)--Solaris 系列        下一篇 
liulin_2
注册用户
等级:少校
经验:1143
发帖:85
精华:5
注册:2012-12-10
状态:离线
发送短消息息给liulin_2 加好友    发送短消息息给liulin_2 发消息
发表于: IP:您无权察看 2012-12-10 16:53:19 | [全部帖] [楼主帖] 楼主

3.1.6 系统日志
创建所有重要的日志文件的硬拷贝
保证在“/var/log”目录下的不同日志文件的完整性是保证系统安全所要考虑的非常重要的
一个方面。如果我们在服务器上已经加上了很多安全措施,黑客还是能够成功入侵,那么日
志文件就是我们最后的防范措施。因此,很有必要考虑一下用什么方法才能保证日志文件的
完整性。如果服务器上或网络中的其它服务器上已经安装了打印机,就可以把重要的日志文
件打印出来。这要求有一个可以连续打印的打印机,并用syslog把所有重要的日志文件传到
/dev/lp0”(打印设备)。黑客可以改变服务器上的文件、程序,等等,但是,把重要的日
志文件打印出来之后,他就无能为力了。
例如,记录下服务器上所有的telnet、mail、引导信息和ssh连接,并打印到连接在这台服务
器上的打印机。需要在“/etc/syslog.conf”文件中加入一行。编辑syslog.conf文件(vi /
etc/syslog.conf),在文件末尾加入下面这一行:

authpriv.*;mail.*;local7.*;auth.*;daemon.info /dev/lp0


mail”是接收日志文件的计算机主机名。如果有人试图黑你的计算机并且威胁把所有重要
的系统日志文件都删掉,你就不用怕了,因为你已经打印出来或者在别的地方还有一个拷贝
。这样就可以根据这些日志文件分析出黑客在什么地方,然后出理这次入侵事件。

authpriv.*;mail.*;local7.*;auth.*;daemon.info@mail


3.1.7 Solaris ndd命令
ndd命令能容易的在不重新配置系统内核和重起系统的情况下,修改核心和TCP/IP的设备的一
些参数。使用如下命令可看到相应的帮助。

[root@ /]> ndd /dev/arp ?
? (read only)
arp_cache_report (read only)
arp_debug (read and write)
arp_cleanup_interval (read and write)
[root@ /]> ndd /dev/icmp ?
? (read only)
icmp_wroff_extra (read and write)
icmp_def_ttl (read and write)
icmp_bsd_compat (read and write)
icmp_xmit_hiwat (read and write)
icmp_xmit_lowat (read and write)
icmp_recv_hiwat (read and write)
icmp_max_buf (read and write)
icmp_status (read only)
[root@ /]> ndd /dev/ip ?
? (read only)
ip_forwarding (read and write)
ip_respond_to_address_mask_broadcast(read and write)
ip_respond_to_echo_broadcast (read and write)
ip_respond_to_timestamp (read and write)
ip_respond_to_timestamp_broadcast(read and write)
ip_send_redirects (read and write)
ip_forward_directed_broadcasts(read and write)
ip_debug (read and write)
ip_mrtdebug (read and write)
ip_ire_cleanup_interval (read and write)
ip_ire_flush_interval (read and write)
ip_ire_redirect_interval (read and write)
ip_def_ttl (read and write)
ip_forward_src_routed (read and write)
ip_wroff_extra (read and write)
ip_ire_pathmtu_interval (read and write)
ip_icmp_return_data_bytes (read and write)
ip_send_source_quench (read and write)
ip_path_mtu_discovery (read and write)
ip_ignore_delete_time (read and write)
ip_ignore_redirect (read and write)
ip_output_queue (read and write)
ip_broadcast_ttl (read and write)
ip_icmp_err_interval (read and write)
ip_reass_queue_bytes (read and write)
ip_strict_dst_multihoming (read and write)
ip_addrs_per_if (read and write)
ip_ill_status (read only)
ip_ipif_status (read only)
ip_ire_status (read only)
ip_ipc_status (read only)
ip_rput_pullups (read and write)
ip_enable_group_ifs (read and write)
[root@ /]> ndd /dev/tcp ?
? (read only)
tcp_close_wait_interval (read and write)
tcp_conn_req_max_q (read and write)
tcp_conn_req_max_q0 (read and write)
tcp_conn_req_min (read and write)
tcp_conn_grace_period (read and write)
tcp_cwnd_max (read and write)
tcp_debug (read and write)
tcp_smallest_nonpriv_port (read and write)
tcp_ip_abort_cinterval (read and write)
tcp_ip_abort_linterval (read and write)
tcp_ip_abort_interval (read and write)
tcp_ip_notify_cinterval (read and write)
tcp_ip_notify_interval (read and write)
tcp_ip_ttl (read and write)
tcp_keepalive_interval (read and write)
tcp_maxpsz_multiplier (read and write)
tcp_mss_def (read and write)
tcp_mss_max (read and write)
tcp_mss_min (read and write)
tcp_naglim_def (read and write)
tcp_rexmit_interval_initial (read and write)
tcp_rexmit_interval_max (read and write)
tcp_rexmit_interval_min (read and write)
tcp_wroff_xtra (read and write)
tcp_deferred_ack_interval (read and write)
tcp_snd_lowat_fraction (read and write)
tcp_sth_rcv_hiwat (read and write)
tcp_sth_rcv_lowat (read and write)
tcp_dupack_fast_retransmit (read and write)
tcp_ignore_path_mtu (read and write)
tcp_rcv_push_wait (read and write)
tcp_smallest_anon_port (read and write)
tcp_largest_anon_port (read and write)
tcp_xmit_hiwat (read and write)
tcp_xmit_lowat (read and write)
tcp_recv_hiwat (read and write)
tcp_recv_hiwat_minmss (read and write)
tcp_fin_wait_2_flush_interval (read and write)
tcp_co_min (read and write)
tcp_max_buf (read and write)
tcp_zero_win_probesize (read and write)
tcp_strong_iss (read and write)
tcp_rtt_updates (read and write)
tcp_wscale_always (read and write)
tcp_tstamp_always (read and write)
tcp_tstamp_if_wscale (read and write)
tcp_rexmit_interval_extra (read and write)
tcp_deferred_acks_max (read and write)
tcp_slow_start_after_idle (read and write)
tcp_slow_start_initial (read and write)
tcp_co_timer_interval (read and write)
tcp_extra_priv_ports (read only)
tcp_extra_priv_ports_a
dd (write only)
tcp_extra_priv_ports_del (write only)
tcp_status (read only)
tcp_bind_hash (read only)
tcp_listen_hash (read only)
tcp_conn_hash (read only)
tcp_queue_hash (read only)
tcp_host_param (read and write)
tcp_1948_phrase (write only)


显示当前值

#ndd /dev/arp arp_debug 0


0: 代表特性禁止

ndd -set /dev/arp arp_debug 1


1: 代表特性允许
由于这些参数一般是经过优化过的,而且一旦改变失误,可能导致系统的不正常工作。所以
sun不提供文档供人随意调节。
3.1.8 系统补丁
跟所有的复杂系统一样,SUN有它的漏洞,其中的一些从性质上来说是相当严重的。SUN公司
有向它的客户甚至是没有技术支持的客户提供补丁的优良传统。这些补丁或者以集合包或者
以单个补丁的形式存在的。不幸的是,要完全修补你的系统,既需要大的补丁集合包,又需
要单个的补丁。然而我们将介绍一种把补丁包和单个补丁结合起来使用的方法。
patchadd -p 或 showrev -p命令来察看补丁在系统里的安装情况,在你想保护的主机以及
大众都可以访问的主机上,你应该到SUN公司的主页上去查找相关的补丁包来安装,并且应该
常常查看最新的补丁发布情况。
补丁步骤:
1) 变成 root
2) 键入 umask 022来设置你的许可模式--给系统打补丁不仅要求所有的补丁被"nobody"用
户可读,而且包括补丁之前的所有目录(不要问为什么,反正是一般这么干的)。
3) 创建一个叫“patch“的目录,并进入它,我一般是这样做的:

mkdir /var/tmp/patch
cd /var/tmp/patch


在你建“patch“目录的文件系统中要保证有足够的磁盘空间(提示:你可以试着键入:df
-k来看看文件系统上可用的磁盘空间,不要用/tmp!
4) 用ftp连接sunsolve站ftp sunsolve.sun.com
你的登录用户名是“anonymous“,口令是你的电子邮件地址。
5) 转到二进制模式,键入: bin
关闭提示,键入: prompt
你不需要为下载每个补丁回答是,我需要下那个补丁。
6) 补丁位于sunsolve站的/pub/patches目录,所以键入: cd /pub/patches
7) 得到对应于你操作系统版本的PatchReport文件,你可以用以下命令列出那些文:

ls *.PatchReport


例如:

-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
ftp> ls *.PatchReport
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
Solaris1.1.1.PatchReport
Solaris1.1.2.PatchReport
Solaris1.1.PatchReport
Solaris2.3.PatchReport
Solaris2.4.PatchReport
Solaris2.4_x86.PatchReport
Solaris2.5.1.PatchReport
Solaris2.5.1_x86.PatchReport
Solaris2.5.PatchReport
Solaris2.5_x86.PatchReport
Solaris2.6.PatchReport
Solaris2.6_x86.PatchReport
Solaris7.PatchReport
Solaris7_x86.PatchReport
226 Transfer complete.
remote: *.PatchReport
360 bytes received in 0.0044 seconds (79.16 Kbytes/s)
-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-


x86和sparc文件有不同的补丁报告文件,sparc版本的是那些没有“x86“字样的。
8) 得到一份补丁报告文件,比如:get Solaris2.6.PatchReport
9) 得到一份对应于你系统版本的推荐补丁集合包和它的README文件,可以用如���命令列出推
荐的文件:ls *Recommended*
输出可能是这样的:

-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
ftp> ls *Recommended*
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
2.3_Recommended.README
2.3_Recommended.tar.Z
2.4_Recommended.README
2.4_Recommended.tar.Z
2.4_x86_Recommended.README
2.4_x86_Recommended.tar.Z
2.5.1_Recommended.README
2.5.1_Recommended.tar.Z
2.5.1_x86_Recommended.README
2.5.1_x86_Recommended.tar.Z
2.5_Recommended.README
2.5_Recommended.tar.Z
2.5_x86_Recommended.README
2.5_x86_Recommended.tar.Z
2.6_Recommended.README
2.6_Recommended.tar.Z
2.6_x86_Recommended.README
2.6_x86_Recommended.tar.Z
7_Recommended.README
7_Recommended.zip
7_x86_Recommended.README
7_x86_Recommended.zip
-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-


你可以用mget命令把推荐文件和readme都拿下来,比如:

mget 7_x86_Recommended*


这可能要等上一会儿。
10) 在下载推荐文件的时候,你可以打开补丁报告文件看看,里面会有关于安全修补的一节
可能是这样的:

-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
Solaris 2.5.1 Patches Containing Security Fixes:
------------------------------------------------
103594-19 SunOS 5.5.1: sendmail fixes
103603-10 SunOS 5.5.1: ftp, in.ftpd, in.rexecd and in.rshd patch
103627-11 SunOS 5.5.1: Linker patch
103630-14 SunOS 5.5.1: ip ifconfig arp udp icmp patch
106689-01 * SunOS 5.5.1: /usr/sbin/in.uucpd patch
106905-01 * SunOS 5.5.1: apropos/catman/man/whatis patch
103566-43 OpenWindows 3.5.1: Xsun patch
106411-06 * OpenWindows 3.5.1: xdm patch
(& c.)
-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-


*“标记的补丁没有包括在推荐补丁集合包里,我们要把它们包括进来。
11) 当推荐补丁集合包下载完后,你需要下载补丁报告中所标记的单个补丁,最快的方法是
mget,这样用: mget 106689* 106905* 106411*
重要:你可能想用一个mget命令得到所有的补丁,但mget的参数的个数是有限制的!而且,
我并没有指定版本号,这不仅仅是为了少输入字符和得到相关的README文件,也是因为在补
丁报告发布过程中,版本号可能是会变化的。
12) 下载完所有的东西后,键入:quit来结束ftp会话。
13) 到现在,你已经下载了补丁集合包和单个补丁,因为继续下去打单个的补丁包太费体力
,我们将先把补丁包和单个补丁合并起来。
首先解压补丁包:
如果你用的是Solaris 2.6或更早的,

uncompress 2*Recommended.tar.Z
tar -xvf 2*Recommended.tar


如果用的是Solaris 7,

unzip 7*Recommended.zip


其次,把所有的单个补丁移到你的建立的Recommended目录:

mv 1* *Recommende d


然后,进到保存有全部补丁的Recommended目录:

cd *Recommended


14) 现在我们可以把所有单个的补丁加到patch_order文件中,在这个文件中列出了所有将被
install_cluster脚本安装的补丁,你可以手工把它们加进去(提示:这是错误的选择)或者
UNIX的命���工具来帮你做这件事。
如果你是Solaris 7,用下面的命令:

ls *.zip   cut -d"." -f1 >> patch_order


如果是Solaris 2.6或以前的:

ls *.tar.Z   cut -d"." -f1 >> patch_order


15) 现在是解压所有单个补丁包的时候了,因为它们还是压缩格式的。
如果你用Solaris 7,你可以用unzip一次解压一个文件:

unzip 108723.zip


讨厌的是,你不能用“unzip *.zip“,因为unzip不能这样工作,为了避免多次地输入unzi
p,你可以用下面的UNIX命令让unzip为你解压所有的东西:

ls *.zip   xargs -n1 unzip


如果用的是Solaris 2.6或更低的,键入:

uncompress *.tar.Z


现在你必须用tar分离出单个的补丁,你可以用以下命令一次处理一个文件:

tar -xvf 108723.tar


讨厌的是,你不能用“tar -xvf *.tar“,因为tar不能这样工作,为了避免多次地
输入tar,你可以用下面的UNIX命令让tar为你分离所有的东西:

ls *.zip   xargs -n1 tar -xvf


16) 到现在所有的补丁都准备好了,关闭计算机:

/usr/sbin/shutdown -y -g0 -i0


启到到单用户模式,对sparc: boot -s
x86, 启动时, 键入:b -s
系统引导后,在提示符后输入root口令后,键入:mountall
mount所有的文件系统。
然后输入:

cd /var/tmp/patch/*Recommended


进到保存所有补丁的目录,现在你可以键入以下命令来安装“所有”的补丁了:

./install_cluster


跟着提示做就行了。如果这是个Solaris 2.5.1或是个Solaris 2.6的系统,可以走
开搞杯咖啡喝喝,因为要花点时间的。不要太担心补丁安装过程中的错误,很多时候出现错
误是因为你没有安装一个特定的软件或已经打了某个补丁。
打完补丁后,关机重启,输入:

/usr/sbin/shutdown -y -g0 -i6


3.1.9 高级指南
3.1.9.1如何防止在堆栈中执行代码?
入侵者常常使用的一种利用系统漏洞的方式是堆栈溢出,他们在堆栈里巧妙地插入一段代码
,利用它们的溢出来执行,以获得对系统的某种权限。
要让你的系统在堆栈缓冲溢出攻击中更不易受侵害,你可以在/etc/system里加上如下语句:

set noexec_user_stack=1
set noexec_user_stack_log =1


第一句可以防止在堆栈中执行插入的代码,第二句则是在入侵者想运行exploit的时候会做记
录,一旦重启机器,这些改变就会生效。如果这不是一个你可以关闭的系统,那么你用adb
改变一个运行中的系统的参数也是可能的。
当然会有些合法使用可执行堆栈的程序在你做出如上改变后而不能正常运行。所幸的是这样
的程序的并不多,我们所知的就只有GNU ada 编译器。




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论