歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> Unix基礎知識 >> Solaris基本安全配置一

Solaris基本安全配置一

日期:2017/3/3 15:24:45   编辑:Unix基礎知識

一個SUN系統就象和NT系統一樣,容易受到來自internet的各種可惡的攻擊。幸運的是,不象NT,你可以用以下三個簡單的手段把SUN變的相對安全些,它們是:

1)防止堆棧溢出

2)關閉不用的服務

3)給系統打補丁

#1 防止堆棧溢出

至少90%以上的安全問題都是來自所謂的“堆棧溢出”。攻擊者通過給一個以root身份運行的程序提供比它所預期的輸入多得多的東西,使被攻擊程序無法處理而改變執行

流程去執行攻擊者指定的代碼。

Solaris 2.6和Solaris 7都具備把用戶堆棧設成不可執行的能力,以使這種攻擊不能得逞。要使能這個特點:

0)變成root

1)對/etc/system文件做個拷貝

cp /etc/system /etc/system.BACKUP

2)用你最鐘愛的編輯器編輯/etc/system文件

3)到文件的最後,插入以下幾行:

set noexec_user_stack=1

set noexec_user_stack_log=1

4)保存文件,退出編輯器

一旦重啟機器,這些改變就會生效。如果這不是一個你可以關閉的系統,那麼你用adb來改變一個運行中的系統的參數也是可能的,但這不是我個人樂意去干的事。

當然會有些合法使用可執行堆棧的程序在你做出如上改變後而不能正常運行。所幸的是這樣的程序的並不多,我所知的就只有GNU ada 編譯器。

#2 在inetd.conf中關閉用不著的服務

有許多用不著的服務自動的處於使能狀態。它們中可能存在的漏洞將使攻擊者甚至不需要一個賬戶就能控制你的機器。關閉這些不需要的服務來保護你的系統,你可

以用如下方法來關閉:

0)變成root

1)對inetd的配置文件/etc/inetd.conf做個拷貝

cp /etc/inetd.conf /etc/inetd.conf.BACKUP

2)編輯/etc/inetd.conf文件

未被激活的服務是在前面被“#“符號注釋掉的,舉個例子,你的部份inetd.conf可能是這樣的:

# Tnamed serves the obsolete IEN-116 name server protocol.

#

name dgram udp wait root /usr/sbin/in.tnamed in.tnamed

不需要這個服務,因為你們中的99.999%不會用到這個“已經被廢棄的IEN-116名字服務協議“,把這個注釋掉以後,這行看起來會象是:

# Tnamed serves the obsolete IEN-116 name server protocol.

#

#name dgram udp wait root /usr/sbin/in.tnamed in.tnamed

^

|

看到這個新的“#” 符號了吧

我建議注釋掉幾乎所有的服務,只留下:

ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd

telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd

time stream tcp nowait root internal

time dgram udp wait root internal

echo stream tcp nowait root internal

echo dgram udp wait root internal

discard stream tcp nowait root internal

discard dgram udp wait root internal

daytime stream tcp nowait root internal

daytime dgram udp wait root internal

rstatd/2-4 tli rpc/datagram_v wait root /usr/lib/netsvc/rstat/rpc.rstatd rpc.rstatd

fs stream tcp wait nobody /usr/openwin/lib/fs.auto fs

100083/1 tli rpc/tcp wait root /usr/dt/bin/rpc.ttdbserverd rpc.ttdbserverd

在只需要不多圖形操作的服務器或是要保證相當的安全,你也許應該關掉字體服務fs,也可以關掉系統性能監視器rstatd和tooltalk服務器ttdbserverd。事實上在確實需要安全的機器上你甚至應該注釋掉telnet和ftp。

你可以用grep找出機器能過inetd所提供的服務:

grep -v "^#" /etc/inetd.conf

這將返回/etc/inetd.conf中所有沒被注釋掉的行。

3)在/etc/inetd.conf中做出改變之後,找到inetd進程的id號,用kill向它發送HUP信號來刷新它。一定要確保kill了inetd進程後,它還在運行,例如:

root@multics: ps -ef | grep inetd

root 196 1 0 15:32:14 ? 0:00 /usr/sbin/inetd -s

root@multics: kill -HUP 196

root@multics: ps -ef | grep inetd

root 196 1 0 15:32:14 ? 0:00 /usr/sbin/inetd -s

#3 給系統打補丁

跟所有的復雜系統一樣,SUN有它的漏洞,其中的一些從性質上來說是相當嚴重的。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“字樣的。

Copyright © Linux教程網 All Rights Reserved