前言
最近很倒楣,兩三台客戶的主機莫名其妙被駭掉了,輕一點的是上層單位發信通告,
重一點的,還有網路刑事警察寄來的公文,當然,還聽過FBI發出的警告。
說實在的,系統帳號的密碼就算設得很複雜,防火牆規則看起來也挺嚴密的,駭客
總是有辦法侵入,高明的也就算了,因為實在太強了,但是如果變成人家練功的對象,
就會給它很肚爛了。
裝完nessus,不代表主機就不會被駭了,但至少,身為系統管理員,深度了解作業
系統的潛在問題,卻是刻不容緩的,不是嗎?
Nessus計畫已研發多年,集眾人之力提供各作業平台一個強而有利的弱點掃描引擎:
Nessus is the world's most popular open-source vulnerability scanner used
in over 75,000 organizations world-wide. Many of the world's largest
organizations are realizing significant cost savings by using Nessus to
audit business-critical enterprise devices and applications.
The "Nessus" Project was started by Renaud Deraison in 1998 to provide to
the internet community a free, powerful, up-to-date and easy to use remote
security scanner. Nessus is currently rated among the top products of its
type throughout the security industry and is endorsed by professional
information security organizations such as the SANS Institute. It is
estimated that the Nessus scanner is used by 75,000 organizations world-wide.
很多英文介紹,重點只有一個:
趕快把它裝起來!基本需要的檔案:
nessus-libraries-x.x.tar.gz
libnasl-x.x.tar.gz
nessus-core.x.x.tar.gz
nessus-plugins.x.x.tar.gz
以上檔案請自行到官方網站抓取:
http://www.nessus.org/download/index.php依序安裝,不然會有錯誤。
一、基本安裝步驟(文字模式下的掃描-不使用圖形介面的工具)
1. nessus-libraries [root@www] ./configure --prefix=/usr
[root@www] make && make install
我是比較懶啦,把預設安裝目錄指定成--prefix=/usr,就可以省掉其他參數設定,所以,如果你只有輸入./configure,沒有指定prefix,目錄會變成/usr/local/lib,所以要改一下/etc/ld.so.conf,把/usr/local/lib加到最後一行,然後執行:
[root@www] ldconfig
2. libnasl [root@www] ./configure --prefix=/usr
[root@www] make && make install
如果用預設安裝,目錄會變成/usr/local/lib,因此加上這個參數設定:
[root@www] export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib)
如果想每次登入都會生效,就把這行加到.bash_profile裡面
3. nessus-core [root@www] ./configure --prefix=/usr --disable-gtk
[root@www] make && make install
4. nessus-plugins [root@www] ./configure --prefix=/usr
[root@www] make;make install
這樣就全部裝好啦!
二、安裝之後的設定 1. 首先新增一個nessus專用的憑證: [root@www ]# nessus-mkcert
/usr/var/nessus/CA created
/usr/com/nessus/CA created
-------------------------------------------------------------------------------
Creation of the Nessus SSL Certificate
-------------------------------------------------------------------------------
This script will now ask you the relevant information to create the SSL
certificate of Nessus. Note that this information will *NOT* be sent to
anybody (everything stays local), but anyone with the ability to connect to your
Nessus daemon will be able to retrieve this information.
在這邊輸入相關資料
CA certificate life time in days [1460]:---------------------預設
Server certificate life time in days [365]:------------------預設
Your country (two letter code) [FR]: TW----------------------隨你
Your state or province name [none]: TAIWAN-------------------隨你
Your location (e.g. town) [Paris]: TAICHUNG------------------隨你
Your organization [Nessus Users United]: ROICAT--------------隨你
輸入完畢,程式會恭喜你一下:
-------------------------------------------------------------------------------
Creation of the Nessus SSL Certificate
-------------------------------------------------------------------------------
Congratulations. Your server certificate was properly created.
/usr/etc/nessus/nessusd.conf updated
The following files were created :
. Certification authority :
Certificate = /usr/com/nessus/CA/cacert.pem
Private key = /usr/var/nessus/CA/cakey.pem
. Nessus Server :
Certificate = /usr/com/nessus/CA/servercert.pem
Private key = /usr/var/nessus/CA/serverkey.pem
Press [ENTER] to exit
2. 再來新增一個可登入nessus的帳號: [root@www ]# nessus-adduser
Addition of a new nessusd user
------------------------------
Login : renaud -------------------------------帳號名稱
Authentication (pass/cert) [pass] : pass------選擇使用密碼認證
Password : secret-----------------------------,總共要輸入兩遍,別忘了~
User rules
----------
nessusd has a rules system which allows you to restrict the hosts
that renaud2 has the right to test. For instance, you may want
him to be able to scan his own host only.
Please see the nessus-adduser ( 8 ) man page for the rules syntax
Enter the rules for this user, and hit ctrl-D once you are done :
(the user can have an empty rules set)
這個時候可以輸入你要的限制規則,如果不想設定,只要按ctrl-D就行了。
底下三行是範例:
deny 10.163.156.1
accept 10.163.156.0/24
default deny
Login : renaud
Password : secret
DN :
Rules :
deny 10.163.156.1
accept 10.163.156.0/24
default deny
問你以上資料對不對,對的話,輸入y然後 [enter] 就好啦~
Is that ok (y/n) ? [y] y
這次就沒有恭喜你了:
user added.
3. 啟動nessus server 很簡單,只要你安裝的時候都有指定/usr那個目錄的話,只要輸入:
[root@www ]# nessusd -D
啟動之後,檢查一下有沒有正常啟動:
[root@www ]# netstat -ant | grep 1241
有這行就表示你成功啟動nessus伺服器了:
tcp 0 0 0.0.0.0:1241 0.0.0.0:* LISTEN
你可以不要用這個port,參考一下說明檔,把port改到別的地方。
4. 開刀啦! 不要一開始就去掃描別人的主機,不然可能會被當作駭客。
先建立一個文字檔,裡頭包含你要掃描的ip或ip範圍,如:
建立一個檔案:
/root/ip-list
內容如下:
127.0.0.1
192.168.1.0/24
然後呢,因為會跑很久,如果你用putty等軟體,建議你先執行一下
[root@www ]# screen
如果有版權宣告,按一下[ENTER]就會回到terminal底下,注意你的
視窗左上角會變成:
[screen 0: bash] root@www:~
接著輸入:
[root@www ]# nessus -q -V -T html_graph localhost 1241 tony \
yourpassword ip-list nessus-report.html
開始掃描之後,你就可以先離開啦:
先按ctrl + a
然後按一下 d
正常的話,你就會回到原本的那個Terminal底下,如果不放心的話,輸入:
[root@www ]# screen -ls
There is a screen on:
3308.pts-0.www (Detached)
1 Socket in /tmp/screens/S-root.
想回去剛剛分離的Terminal,那就輸入:
[root@www ]# screen -r
5. 解讀nessus產生的報告: 把掃描完的檔案拉回你的電腦,用瀏覽器打開,就可以清楚的看到弱點偵測的報告嚕~
趕快依照裡面的建議,把系統的漏洞修補起來。
三、安裝圖形化支援的nessus常用Linux作業系統的人,好像都不太愛裝x-window,其實,用nessus的圖形介面
也蠻方便的說,對於沒有windows的人來說,用不著裝一整套的XFree86,只是,
安裝過程給它很麻煩就是了。
1. 抓檔案:wget
ftp://rpmfind.net/linux/fedora/core/updates/1/i386/XFree86-libs-data-4.3.0-55.i386.rpmwget
ftp://rpmfind.net/linux/fedora/core/updates/1/i386/XFree86-libs-4.3.0-55.i386.rpmwget
ftp://rpmfind.net/linux/fedora/core/updates/1/i386/XFree86-devel-4.3.0-55.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/fontconfig-devel-2.2.3-5.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/freetype-devel-2.1.9-1.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/pango-devel-1.6.0-7.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/atk-devel-1.8.0-2.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/glib2-devel-2.4.7-1.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/glib2-2.4.7-1.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/gtk2-2.4.13-9.i386.rpmwget
http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/core/3/i386/os/Fedora/RPMS/gtk2-devel-2.4.13-9.i386.rpm上面是有順序性的,所以,如果你的系統當初安裝時就沒有這些套件的話,請依序安裝。
當然,你可以直接把wget改成rpm -Uvh,這樣就省了一個步驟,只是如果出現套件相依問題時,
就比較麻煩了。
XFree86的三個套件不是最新的,如果你的系統已經存在xwindow,請不要蓋掉你原本的套件,
試著反序安裝回去,比如說,先抓gtk2-devel-2.4.13-9.i386.rpm回來安裝,然後按照
RPM的指示,再去找相關的套件回來用。
例如:
[root@www nessus]# rpm -ivh gtk2-devel-2.4.13-9.i386.rpm
warning: gtk2-devel-2.4.13-9.i386.rpm: V3 DSA signature: NOKEY, key ID 4f2a6fd2
error: Failed dependencies:
XFree86-devel is needed by gtk2-devel-2.4.13-9.i386
atk-devel >= 1.6.0-1 is needed by gtk2-devel-2.4.13-9.i386
glib2-devel >= 2.4.0-1 is needed by gtk2-devel-2.4.13-9.i386
pango-devel >= 1.4.0-1 is needed by gtk2-devel-2.4.13-9.i386
那你就可以按照它顯示出來的套件全裝好,再裝gtk2-devel-2.4.13-9.i386
所有檔案,可以到http://rpmfind.org/找找看,或到義守大學http://ftp.isu.edu.tw/找。
2. 重新編譯一次nessus-core [root@www nessus]# ./configure --prefix=/usr --enable-gtk --with-x
[root@www nessus]# make&&make install
3. 啟動nessus server [root@www nessus]# nessusd -D
4. 啟動用戶端: 4-1 直接在x-windows下執行:
開一個終端顯示,然後輸入:
[root@www nessus]# nessus &
正常的話,就會跳出一個登入的畫面,然後只要輸入正確帳號密碼,即可登入。
4-2 把畫面丟到windows作業系統:
你需要安裝xwin32,可以到這邊下載:
http://www.starnet.com/ 註冊之後,你會收到一封下載通知,然後按照指示下載就好了,因為是試用版,
所以每次只有30分鐘的使用時間,時間到了,就要重新啟動。
安裝好之後,只要點兩下把它啟動就好了,不用特別設定。
4-3 進入nessus server
使用putty或相關的ssh軟體,telnet應該也可以吧?好久不用telnet了:
[root@www nessus]# export DISPLAY=你的windows的IP:0.0
如:
[root@www nessus]# export DISPLAY=210.95.8.88:0.0
接著,還是一樣,輸入:
[root@www nessus]# nessus &
等一下下,如果你是透過Internet的話,時間會比較久,然後,
一樣的登入畫面就會出現啦~
四、結論常常遇到莫名其妙的入侵事件,也不知道自己的作業系統夠不夠牢固,藉著nessus
就至少可以清楚的知道自己的主機有哪些尚未修補起來的漏洞,好比說,今天我才
知道,原來libtiff那個看起來不起眼的套件,竟然也暗藏殺機啊~
所以囉~沒事就跑跑nessus,檢查一下自己的主機,定時做更新,做好平常的防護,
把主機被駭客入侵的危險性降到最低。
預防重於重灌啊!