NESSUS

Page 1

資 訊工 業策進 會網路 工程 師養成 班第八 十一 期 LINUX LAB

NESSUS 弱點偵測系統 班 級: UC103 指導老師:林旺聰主任 彭學勤老師 楊宏文老師 學生:陳卉潔

1


 Topology

 何謂弱點? 弱點指的是在軟體程式開發時的一些有意或無意的程式設計錯誤,或系統管理者的一些不 當安裝設定軟體的方式,使得攻擊者可以在有安裝這些軟體的機器上,利用這些尚未修補的錯 誤來入侵,獲取到系統的機密資訊或是系統的權限。尤其是當軟體越裝越多,系統服務開啟的 越多,那麼被攻擊的可能性就越大。

 NESSUS 介紹 1.

Nessus 是一套免費、功能強大、更新迅速、支援即時更新且容易使用的安全性稽核 軟體。

2.

可針對指定的網域、主機,找出隱藏的弱點所在,讓系統管理者對系統主機進行錯誤 的更正或防護,以避免被入侵者攻擊。

3.

提供模擬真實的攻擊以測詴系統漏洞,回報找到的漏洞並提供解決方法。

nessus 可以依據其plugin 進行弱點的測詴及攻擊,並列出可能的問題,以及解決的建 議方法,詳細特點歸類如下:

2


1.

plug-in 的結構:每項安全掃描都是寫成在外部的 plug-in,用這種方法,你可以輕 易的增減你所需做的測詴,而不需要去修改 nessus 掃描引擎的程式碼, 目前已有的 plugin 可分為以下幾類: ‧

Backdoors:各種後門程式。

‧ ‧

CGI abuses:測詴常見的 CGI 問題。 Denial of Service:阻斷停止服務。

Finger abuses:測詴 finger 的問題。

‧ ‧

Firewalls:測詴防火牆的一些設定常有的疏失。 FTP:包括匿名使用者的權限、檔案權限、各種 ftp server 的漏洞。

‧ ‧

Gain a shell remotely:測詴某些服務可能造成遠端得到 shell 的問題。 Gain root remotely:測詴某些服務可能造成遠端得到 root 的權限。

General:一般性問題的 plugin。

‧ ‧

Misc:其他問題的 plugin。 NIS:測詴 NIS 的問題。

Port scanners:使用 nmap 對遠端機器進行ping、tcp connect scan、FTP

bounce scan、TCP SYN scan。 Remote file access:遠端檔案權限存取測詴。

RPC:遠端程序呼叫問題的 plugin。

SMTP problems:檢查常見 mail server 的問題,像是 sendmail 較舊版本遠 端得到shell,覆寫檔案,mail relay 等問題。

Useless services:檢查是否有一些並不一定需要,且容易造成系統可能的安全 問題,像是以明碼傳送的 telnt、rlogin、rsh 等等。

Windows:測詴windows 上檔案分享服務,認證服務等問題。

2.

NASL:為了讓撰寫安全掃描程式迅速簡易,因此設計了NASL ( Nessus AttackScripting Language ),使得不需修改 nessus 的掃描引擎核心程式即可達到 各種掃描需求。

3.

時常更新的弱點資料庫:nessus 的開發維護人員專注於檢查每天最新的安全漏洞,弱 點資料庫更新的時間原則是以天來計算。

4.

Client-server 架構:nessus 是由兩個部分組成,nessus server 和 nessus client, nessus server 部分負責攻擊,client 則是一個控制和觀看訊息的介面,你可以在不 同的系統跑 server 和 client,也就是可以在 PC 上稽核檢視整個網域主機的狀況, 而執行攻擊的則是一台在機房的大型主機,目前 server 部分只能在 POSIX 系統上執 行 ( Solaris、FreeBSD、GNU/Linux and others ),client 有 X11、JAVA 和 Win32 三種版本。

5.

可以同時測詴無限多台電腦:依照 nessus server 那台主機的能力而定。

6.

不依照埠號來決定主機服務的項目:nessus 不會拘泥於 IANA 所定的埠號來決定服 務的項目,也就是說當 FTP server 跑在 31337,當 Web server 跑在 8080 時, nessus 一樣可以辨別他們的服務項目。

3


7.

模擬入侵者的行為:nessus 不會依照相信 service 對外宣稱的版本資訊來決定這個 版本是否安全,他依然會測詴各種可能的問題,像是 version x.y.z 之類的,95%的 安全測詴依然會執行他們的測詴,仍然會嘗詴 overflow 你的 buffers,對你的 mail server 做 relay,甚至毀掉你的系統。

8.

完整的報告:nessus 不會指告訴你哪裡有問題,在大多數的情況下還會告訴你該如何 預防入侵者的攻擊這些弱點,並會分級表示弱點的嚴重性。

9.

可轉換格式報表:可將掃描報告轉成 ASCII text、LaTeX、HTML、"spiffy" HTML 這些格式。

10. 獨立的開發者: nessus 的開發者是完全獨立無顧忌的,跟商業軟體廠商毫無任何關 係,所以決不會因為他們跟某軟體有關係而隱瞞任何的安全的弱點。

 nessus 的運作過程: 1. 尋找有哪些port 有服務正在進行,nessus 的 port scan 部分是依靠 nmap 來完 成。 2. 測詴這個 port 的服務有哪些可能的漏洞存在。 3. 產生測詴報告。 4. 提出系統可能的漏洞。 5. 提出系統可能問題的解決方案。

Server 主要安裝在 UNIX-like 的系統環境,而 Client 可以安裝在 UNIX-like 的作業系統或是微軟的 Windows 作業系統底下。

4


NESSUS 如何取得?

Browse http://www.nessus.org/download/ 直接上 Nessus 的官方網站,可供下載 Nessus 4.4.0 的作業系統如下: Microsoft W indows Windows XP, 2003, Vista, 2008 and 7

Mac OS X Tiger, Leopard and Snow Leopard

Linux Debian, Fedora, Red Hat, SuSE and Ubuntu

FreeBSD FreeBSD 8

Solaris Solaris 10

iPhone iOS 4.x and newer (client only)

New in this version 

Scan Scheduling Nessus 4.4.0 版本,增加了排程的功能,讓 Nessus 可以在適當的時間,並且周期 性的進行掃描。

Enhanced Reporting Nessus 4.4.0 版本,掃描報告包含了 ”Executive” 和 “Detailed” 兩種,可比較 兩種報告的差異,而找出更好的解決方案。

Reload plugins during a scan Nessus 4.4.0 版本,當進行掃描時,可以同時重新載入最新的 Plugins 和組態檔, 不需要中斷掃描。

Lower memory requirements Nessus 4.4.0 版本,每次掃描所需使用的記憶體,比前一版本少了一半。

Get activation code http://www.nessus.org/register 除了 download 安裝的程式之外,記得也要取得 activation code。 Activation code 的主要功能就是讓你可以 download Plug-ins 。 (注意:activation code 只能用一次喔!)

5


← 選擇 ” Obtain an activation code ”

↓選擇 ” HomeFeed “

6


 NESSUS 如何安裝、移除與部署? 

Install Nessus 4.4.0 for Linux ( SuSE 10.0 )

請用 root 完成安裝動作: # rpm –ivh Nessus-4 .4.0-suse10.0.i 58 6.rpm Preparing..

########################################### [100%]

1:Nessus

########################################### [100%]

nessusd (Nessus) 4.4.0 [build M15045] for Linux (C) 1998 - 2010 Tenable Network Security, Inc. Processing the Nessus plugins... [##################################################] All plugins loade d - Please run /opt/nessus//sbin/nessus-adduser to add a user - Register your Nessus scanner at http://www.nessus.org/register/ to obtain all the newest plugins - You can start nessusd by typing /etc/rc.d/nessusd start

使用 Activation Code 來啟用 download Plug-ins 的功能: 先去信箱收信,取得 Activation Code

# /opt/nessus/bin/nessus-fetch -–register C691 -A9FD-9 ACE-1C73-0 BB1 Your activation code has been registered properly – thank you. Now fetching the newest plugin set from plugins.nessus.org... Your Nessus installation is now up-to-date. If auto_upda te is set to 'yes' in nessusd.conf, Nessus will update the plugins by itself. # cat /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc PLUGIN_S ET = "201012010134"; PLUGIN_FEED = " HomeFeed (Non-commercial use olny)";

/opt/nessus/lib/nessus/plugins/plugin_feed_info.inc 可以確認您的Plugin set 的更新日期與您Register的種類。

7


Register 完後,以後可以直接輸入下列指令來取得最新的 Plug-ins: # /opt/nessus/sbin/nessus-update-plugins Fetching the newest updates from nessus.org… Done. The Nessus server will restart when its scan are finished

之後可以在 /opt/nessus/etc/nessus/nessusd.conf 裡修改 auto_uupdate = yes, 這樣以後 Nessus 會自己update Plug-ins。你也可以修改 auto_update_delay = N小 時,最多24小時,最少4小時。 當你不能用以上方法 Register 或者 Nessus 在 NAT 內部時,請如下方式操作: 使用下列指令得到一組字串: # /opt/nessus/bin/nessus-fetch – challenge Challenge code :da1991d3elcacf6feca0c4a2cbc6dal4e5bfd127 You can copy the challenge code above and paste it alongside your activation code at : https://plugins.nessus.org/offline.ph p

到 http://plugins.nessus.org/offline.php 輸入您的 Challenge 出來的字串與 Activation Code。

成功取得最新的 Nessus plugins,匯入 Nessus 即可大功告成。 plugin 檔案名稱為 all-version.tar.gz 透過 nessus-update-plugins 來匯入。

8


# /opt/nessus/sbin/nessus-update-plugins /root/all/all-2.0.tar.gz Expan ding /root/all/all-2.0.tar.gz... Done. The Nessus server wi ll restart when its scans are finished

啟動 nessusd,讓新的 plug-ins 載入,就安裝完成: # service nessusd start Starting the Nessus Daemon

done

Nessus 預設的安裝路徑在 /opt/nessus,由於並非 linux 上的標準路徑,所以將下 面路徑寫在 root 的 .bash_profile 裏面 # vi /root/.bash_profile PATH=$PATH:/opt/nessus/bin:/opt/nessus/sbin M ANPATH=$M ANPATH:/opt/nessus/man export

P ATH

#宣告 PATH 變數

export

M ANPATH

#宣告 MANPATH 變數

存檔以後重讀一次 .bash_profile (# . ~/.bash_profile or # source ~/.bash_profile) 或是重新登入即可馬上生效。 

Make Certificate

Nessus 掃描完後的弱點報表資訊是相當重要的,如果被別人竊取反而變成攻擊者的入侵 教科書。所以 Nessus Server 和 Client 的傳輸要經過加密認證來傳送這些弱點資訊, 所以我們必頇在 Nessus 的 Server 上設定產生憑證,輸入下例指令來產生 Server 端 的憑證: # /opt/nessus/sbin/nessus-mkcert ------------------------------------------------------------------------------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) [US]: TW Your state or province name [NY]: TW Your location (e.g. town) [New York]: Tai pei Your organization [Nessus Users United]: III This host name [NESSUS]:

9


Congratulations. Your server certificate was properly created. The following files were created : . Certification authority : Certificate = /opt/nessus//com/nessus/CA/cacert.pem Private key = /opt/nessus//var/nessus/CA/cakey.pem . Nessus Server : Certificate = /opt/nessus//com/nessus/CA/servercert.pem Private key = /opt/nessus//var/nessus/CA/serverkey.pem

執行 /opt/nessus/sbin/nessus-mkcert 產生認證。此認證乃伺服器與客戶端連線時 加密之用。

新增一個管理 nessus 的帳號 # /opt/nessus/sbin/nessus-adduser Login:admin Login password: Login password (again): Do you want this user to be a Nessus „admin‟ user?(can upload plugins, etc…) (y/n) [n]:y User rules --------------nessusd has a rules system which allows you to restrict the hosts that admin 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 manual for the rules syntax Enter the rules for this user, and enter a BLANK LIN E once you are done : (the user can have an empty rules set) Login

:admin

Password :************** This user will have „admin‟ privileges within the Nessus server Rules Is that ok?(y/n) [y] y

所有手續完成後表示你的 nessus 使用者資料庫中多了一位 admin 的帳號 , 注意這 個帳號並不存在於系統帳號中,所以我們不會再 /etc/passwd 中看到任何 nessus 的 相關字樣。

10


Modify Rules

Nessus 可對每位 User 設定條件。讓一台 Nessus Server 可以給不同的管理者,只 針對他們負責的工作內容來使用。比如說 AD 的管理者只能用 Nessus 來對 AD 做弱 點偵測。所以 Nessus Server 的管理者可以設定 AD 的管理者只能針對 AD Server 做弱點偵測。 規則有兩種 1.適用於整個系統的規則 2.特定於用戶的規則  

系統規則會被放在 /opt/nessus/etc/nessus/nessusd.rules 特定用戶規則放在 /opt/nessus/var/nessus/users/<login>/auth/rules <login>自行代換成你剛才新增的使用者帳號

Keyword: reject , accept , default

語法: accept|reject ip/mask and default accept|reject

※mask is the CIDR netmask,default 必頇放在最後。 Example: 允許使用者掃描本機以及192.168.0.0/16網段內的所有機器,但是不能掃描 192.168.1.1: accept 127.0.0 .0/8 reject 192.168.1 .1/32 reject !192.168.0 .0/16 default reject

允許使用者掃描任何網段,但是不能掃描192.168.1.0/24網段: reject 192.168.1 .0/24 default acce pt

只允許使用者掃描這個IP accept 192.1 68.1.2/32 default reject

在產生使用者的過程中也可以直接按ctrl-D跳過,這樣會允許這個使用者可以掃描任何網段。

Other command  Remove Nessus 在移除之前需要先停止 nessusd 的服務: # killall nessusd

刪除套件:

11


# rpm -e Nessus-4 .4.0-suse10.0

完整移除目錄: # rm -rf /opt/nessus

Change password

# /opt/nessus/sbin/nessus-chpasswd admin Authentication (pass/cert):[pass] Login password: Login password (again): password changed for a dmin

Remove user

# /opt/nessus/sbin/nessus-rmuser Login to remove :admin User removed

 Change port Nessus 預設使用 8834 port,若想改變設定,使用參數 ”-p” # nessusd –p 1500

 報告分析: 

BID ( BugTraq ID ) - BugTraq is a full disclosure moderated mailing list for the *detailed* discussion and announcement of computer security vulnerabilities: what they are, how to exploit them, and how to fix them. - 詳細介紹:http://www.securityfocus.com/archive/1/description#0.1.1 - 可根據不同的 BID number 找尋其資料:http://www.securityfocus.com/bid

CVE ( Common Vulnerabilities and Exposures) - free for public use - CVE is a dictionary of publicly known information security vulnerabilities and exposures. - CVE Name 是 CVE 給定的編號,中間 4 位數字為漏洞發現年度

開放原始碼弱點資料庫(The Open Source Vulnerability Database,簡稱 OSVDB) - 將網際網路相關軟體的安全瑕疵分類,供使用者查詢。 - 官方網站:http://osvdb.org/

12


13


 組態檔位置: /opt/nessus/etc/nessus/nessusd.conf 

以下是組態檔設定說明 (基本上都列出預設值)

plugins_folder

這是 nessus plugin 的存放位置

/opt/nessus/lib/nessus/plugins auto_update = yes

自動從 plugins.nessus.org 下載最新 plugins

auto_update_delay = 24

隔多少小時會再自動下載 plugin

purge_plugin_db = no max_hosts = 100

每次更新時清除 plugin 的 database 並重新製作 能夠同時掃描的最大電腦數量

max_checks = 5

能夠同時檢驗的電腦數量

throttle_scan = yes logfile =

自動調節掃描,在 cpu 用量高時會自動降低使用量 log 檔位置

/opt/nessus//var/nessus/logs/ nessusd.messages www_logfile =

Web Server ( user interface ) log 檔位置

/opt/nessus//var/nessus/logs/ www_server.log log_whole_attack = no

是否將所有攻擊紀錄下來 ,硬碟夠大的話再啟用

dumpfile = /opt/nessus//var/nessus/logs/

dump file 位置

nessusd.dump rules = /opt/nessus//etc/nessus/

系統規則檔

nessusd.rules cgi_path = /cgi-bin:/scripts port_range = default (可指定 1-65535)

CGI 程式碼檢查的路徑 要掃描的 port, default 表示會掃描 /etc/services

optimize_test = yes

最佳化測詴,建議開啟

checks_read_timeout = 5

檢查時預設 5 分鐘沒反應會暫停

non_simult_ports = 139, 445

監聽 port 139 445

plugins_timeout = 320 safe_checks = yes

plugin 的 timeout 秒數 安全掃描

auto_enable_dependencies = yes

自動滿足 plugins 相依性

silent_dependencies = yes

不自動的提取 plugins 中資料

use_mac_addr = no

特徵比對使用 MAC address,在 dhcp 網路中很實用

save_knowledge_base = no plugin_upload = yes

save the knowledge base on disk 使用者是否可升級 plugins

plugin_upload_suffixes

使用者能夠升級哪些附檔名的 plugins

中定義的 port

14


= .nasl, .nasl3, .nasl4, .inc, .inc3, .nbin, .nlib, .audit, .png, .jpg, .gif, .js, .ico, .swf, .html, .xslt, .pol, .xsl slice_network_addresses = no

啟用的話不會以遞增順序掃描網路, ex:10.0.0.1->10.0.0.2->10.0.0.3,而是以網路段 ex:10.0.0.1->10.0.0.127->10.0.0.2->10.0.0.128

listen_address = 0.0.0.0

nessus 預設監聽的 ip 位置為所有網路

#source_ip = 191.168.0.1,192.168.0.2

可設多個 ip,讓多個 host 可同時掃描

listen_port = 1241

( NTP protocol ) 4.2 版之前所使用的通訊協定

xmlrpc_listen_port = 8834

( XMLRPC protocol ) 給 Web Server 用的 port number

xmlrpc_idle_session_timeout = 30

Web Server 30 分鐘 idle 則暫停

#enable_listen_ipv4 = yes #enable_listen_ipv6 = yes ssl_cipher_list = stroge disable_ntp = no

當使用 ssl 連線時,只能用強式密碼連線 不能使用 NTP 通訊協定

disable_xmlrpc = no

不能使用 XMLRPC 介面

nasl_no_signature_check = no nasl_log_type = normal

檢查 nasl 語言所寫的 script 簽章 nasl 的 log 型態

use_kernel_congestion_detection

使用 linux 核心 TCP 擁塞的訊息

= no global.max_scans = 0

使用非零值表示可以同時平行處理該數量的掃描

global.max_web_scan = 0

使用非零值表示可以同時有多個使用者連線

#global.max_simult_tcp_sessions = 2000

在所有掃描中可同時間建立的 tcp sessions 數量

#max_simult_tcp_session = 200

每個掃描所能發起的 tcp sessions 數量

#host.max_simult_tcp_sessions = 20

每個掃描的主機最高可使用多少 tcp sessions

reduce_connections_on

當網路擁塞時減少 tcp 的 sessions

_congestion = no stop_scan_on_disconnect = no

停止掃描斷線的主機

stop_scan_on_hang = no

當有爭議時,停止掃描

paused_scan_timeout = 240

掃描暫停 240 分鐘,就將掃描刪除

report_crashes = yes

報告如果有衝突,則回報給 Tenable

qdb_mem_usage = high

記憶體的使用率;若此一主機只有提供 NESSUS 服 務,則用 high,否則,則用 low

15


 心得: 經過 MSLAB 的歷練,我想大家對自己的能力一定更有信心了;而我也想好好在 LXLAB 盡情地發揮所學!LXLAB 似乎並不像 MSLAB,課堂上老師都有教過,而是要 我們自己去接觸一套新的軟體新的服務,所以當時看到題目時,真的不知如何去著手 LALAB;不過想到之後出社會工作,一定有很大的可能會接觸到完全不熟悉的東西,所 以我就這樣勉勵自己,就把這次 LAB 當作是工作前的挑戰(雖然說來到資策會本來就是 要訓練自己的能力)。 這次我被分配到的題目,比起我們同組的其他人,似乎我的題目比較容易去操作,應 該說比較不會有什麼其他的變因會影響到我做 LAB 的結果;對於 NESSUS 這個主題, 唯一比較困難的是,版本跟之前學長姐的不同,所用的通訊協定新增了 XMLRPC protocol,port number 是 8834,在基本的設定並沒有什麼太大的改變;只有在 client 端部分,並不需要再安裝軟體,而是可以直接透過 Web 連線到 Server 端,大大降低 了管理者的限制,管理者只要有網路便可以透過瀏覽器連到 Server 端去做掃描的動作; 在這次 LAB ,因為我的環境一直改變(從我房間 → 道揚房間 → 學校 204 教室) ,發 生 Client 端的 Web 介面可以登入,卻無法進行掃描設定的部分,曾經也詴圖尋找原因 卻始終無解,連帶我只好重新安裝 NESSUS 5~6 次。這次我的題目,其實最難的部分 應該就是去讀懂 Report 的內容,而詴圖去解決這個問題;這也是我一直想學習,也必 頇要一直一直學習的地方。 這次 LXLAB 大家所涉及的題目幾乎都不同,所以很多時候都必頇靠自己去解決問 題,這也讓我學習到如何去找尋問題並解決;其實,在聽過大家的報告後,大致上對於所 有題目都有初步的認識,而在自己大致上已完成 NESSUS 部分,就很想去幫助其他人, 一起努力把這次的 LAB 完成,可是自己卻從未接觸過,只能就問題給予可能的答案;這 次 LAB 完後,雖然結果不如預期,但卻也從老師那得到許多寶貴的經驗、重要的觀念, 這些都是我們學不來的。最後我想說的是,如果還有時間還有機會,我真的想去接觸學習 其他的服務!

16


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.