網 站 安 全 攻 防 實 務 弱 點 掃 描 與 分 析 工 具 蔡 一 郎 2010/12/03
課 程 大 綱 安 全 弱 點 弱 點 評 估 Nessus 簡 介 Nessus 安 裝 Nessus 使 用 與 設 定 弱 點 報 表 分 析 弱 點 修 正 Web 弱 點 掃 描 工 具
何 謂 安 全 弱 點 系 統 或 網 路 上 的 缺 口 所 導 致 的 未 授 權 的 使 用 資 源 或 接 取 服 務 因 程 式 上 或 組 態 設 定 上 的 錯 誤 或 忽 略 而 導 致 的 安 全 問 題
安 全 弱 點 形 成 的 原 因 設 計 階 段 (Design Phase) 脆 弱 的 演 算 法, 或 設 計 時 未 考 慮 到 的 問 題 實 作 階 段 (Implementation Phase) 因 疏 忽 或 是 錯 誤 導 致 的 軟 體 漏 洞 操 作 階 段 (Operation Phase) 使 用 者 的 使 用 或 是 設 定 不 良 所 導 致 人 性 / 習 慣 (Human Nature) 人 性 上 的 弱 點 所 導 致
弱 點 運 用 的 方 式 Bruce force Resource exhausting Buffer overflow Format string TCP Spoofing TCP Hijacking, etc.
弱 點 造 成 的 影 響 造 成 程 式 錯 誤 權 限 提 昇 DoS 資 訊 洩 露 / 竄 改 植 入 木 馬 / 後 門 程 式
安 全 弱 點 的 修 補 軟 體 Apply patch form vendor Apply safe configuration setup Close unnecessary services 安 全 的 使 用 習 慣 Strong password Password protect screen saver Don t open malicious email/files 要 求 軟 體 開 發 者 進 行 弱 點 改 善
弱 點 評 估 的 定 義 用 來 檢 查 網 路 或 作 業 系 統 的 安 全 性 模 擬 攻 擊 者 所 發 出 的 攻 擊 動 作 可 提 供 網 路 管 理 人 員 做 為 弱 點 修 補 之 依 據, 以 提 昇 安 全 性 與 防 毒 軟 體 的 做 法 相 似, 依 據 所 謂 的 弱 點 特 徵 資 料 庫 來 測 試 是 否 存 在 已 知 的 漏 洞
弱 點 掃 描 的 重 要 性 無 絕 對 安 全 的 系 統 攻 擊 手 法 日 新 月 異, 更 新 速 度 越 來 越 快 使 用 弱 點 掃 描 工 具 協 助 管 理 人 員 掌 握 最 新 的 弱 點 資 訊 提 供 弱 點 修 補 的 資 訊 需 不 斷 地 進 行 弱 點 掃 描 與 漏 洞 修 補
使 用 的 限 制 不 可 過 份 依 賴 弱 點 掃 工 具 軟 體 特 徵 資 料 庫 必 需 持 續 更 新 不 正 確 的 使 用 方 式, 有 時 候 反 而 會 更 加 危 險 入 侵 偵 測 系 統 DoS 測 試 誤 判 率 高 : 弱 點 評 估 報 告 不 一 定 是 正 確 的, 必 頇 要 有 探 討 及 分 辨 真 偽 的 能 力
弱 點 評 估 軟 體 的 比 較 商 業 軟 體 優 點 : 有 廠 商 維 護, 支 援 性 較 佳. 使 用 門 檻 較 低, 較 具 親 和 力 缺 點 : 所 需 成 本 高 免 費 軟 體 優 點 : 免 費 缺 點 : 功 能 與 說 明 較 簡 略, 誤 判 率 高, 支 援 較 少
Nessus 軟 體 介 紹 為 一 免 費 的 網 路 安 全 檢 測 工 具 它 是 在 1998 年, 由 法 國 的 Renaud Deraison 所 發 展 的 Nessus 網 頁 :http://www.nessus.org/ 目 前 最 新 的 新 版 本 為 :4.2.1 由 3.0 版 本 開 始 不 提 供 原 始 碼 提 供 弱 點 資 料 庫 更 新 免 費 下 載 版 會 慢 7 天
Nessus 軟 體 的 特 點 以 Plug-in 的 方 式 組 成 主 從 式 架 構 能 同 時 檢 測 無 限 制 的 主 機 能 辨 識 主 機 上 的 服 務 重 覆 服 務 的 檢 測 使 用 自 附 的 直 譯 器 及 程 式 語 言 -- NASL 支 援 多 種 格 式 的 報 告 結 果 txt html pdf 等 格 式
Nessus 架 構 hosts hosts nessus server nessus client hosts hosts
Nessus server 的 安 裝 安 裝 :Nessus server 必 需 安 裝 在 unix like 的 主 機 上, 安 裝 方 式 有 下 列 幾 種 : 直 接 在 網 路 上 安 裝, 執 行 以 下 指 令 : lynx -source http://install.nessus.org sh 下 載 自 動 安 裝 程 式 :nessus-installer.sh #./nesshs-installer.sh 下 載 nessus 的 原 始 碼 後, 個 別 編 譯 安 裝 RPM 套 件 :3.0 之 後 版 本 僅 提 供 RPM 套 件, 不 提 供 原 始 碼
安 裝 步 驟 檢 查 系 統 需 要 的 套 件 gtk2 gtk2-devel(nessus client 需 要 用 的 ) 下 載 rpm 套 件 安 裝 rpm 套 件 建 立 第 一 個 使 用 者 向 nessus 註 冊 : 要 註 冊 才 能 更 新 plugin 啟 動 nessusd
下 載 nessus 套 件
Plugin Feed
HomeFeed Register
Home Feed e-mail
安 裝 # rpm -ivh Nessus-4.2.1-es5.i386.rpm Preparing... ########################################### [100%] 1:Nessus ########################################### [100%] - 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 /sbin/service nessusd start
建 立 第 一 個 使 用 者 # /opt/nessus/sbin/nessus-adduser Using /var/tmp as a temporary file holder Add a new nessusd user ---------------------- Login : 帳 號 名 稱 Login password : 輸 入 密 碼 Login password (again) : 確 認 密 碼
設 定 使 用 者 rule # /opt/nessus/sbin/nessus-adduser Login : student Authentication (pass/cert) : [pass] 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 student 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 LINE once you are done : (the user can have an empty rules set) 按 空 白 鍵 結 束
使 用 者 帳 號 管 理 新 增 使 用 者 /opt/nessus/sbin/nessus-adduser 刪 除 使 用 者 /opt/nessus/sbin/nessus-rmuser 重 設 使 用 者 密 碼 /opt/nessus/sbin/chpasswd 使 用 者 資 料 /opt/nessus/var/nessus/users/ 目 錄 下
向 Nessus 註 冊 # /opt/nessus/bin/nessus-fetch --register 361A-AC0E-6994-CAC1-11F2 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_update is set to 'yes' in nessusd.conf, Nessus will update the plugins by itself.
啟 動 nessus server 啟 動 nessusd # service nessusd start Starting Nessus services: [ OK ] 查 看 nessusd 服 務 是 否 正 常 啟 動 [root@station40 ~]# ps -ef grep nessus root 3369 1 0 18:13? 00:00:00 /opt/nessus//sbin/nessusservice -q -D root 3370 3369 0 18:13? 00:00:06 nessusd -q root 3453 3421 0 19:30 pts/0 00:00:00 grep nessus
nessuswx sessions 狀 態 欄
連 結 至 伺 服 器 端 Communications ->Connect Server IP and port 登 入 帳 號 及 密 碼
Server certificate 第 一 次 登 入 伺 服 器 時 會 詢 問 是 否 接 受 伺 服 器 憑 證, 需 選 擇 Accept Once 或 Accept & Save 才 能 繼 續
建 立 session Sessions -> New 輸 入 session 名 稱
Targets Options Port scan Connection Plugins Comments
設 定 掃 描 目 標 Sigle host 掃 描 單 一 主 機 Subnet 掃 描 整 個 子 網 段 Address range 掃 描 特 定 IP 範 圍
掃 描 選 項 Safe checks 不 實 施 危 險 性 掃 描 項 目, 以 避 免 造 成 系 統 受 損
Port scan 選 項 設 定 掃 描 通 訊 埠 範 圍 設 定 掃 描 方 式
選 擇 plugin 勾 選
執 行 弱 點 掃 描 在 面 板 上 點 選 session =-> Execute 掃 描 完 成 後 可 按 Preview 顯 示 掃 描 結 果
觀 看 掃 描 結 果
產 生 掃 描 報 告
plugin 更 新 Nessus 2.0 版 的 更 新 方 式 : /usr/local/sbin/nessus-update-plugins 可 以 放 到 crontab 中 讓 系 統 定 期 更 新 plug-in Plugins 的 位 置 : /usr/local/lib/nessus/plugins Nessus 3.0 版 本 之 後 可 設 定 啟 動 nessusd 服 務 後 自 動 更 新 設 定 檔 :/opt/nessus/etc/nessus/nessusd.conf auto_update = yes 手 動 更 新 # /opt/nessus/sbin/nessus-update-plugins
Nessus 報 表 : 表 頭
Nessus 報 表 : 弱 點 描 述 服 務 描 述 (Service) 包 含 服 務 名 稱 及 使 用 的 通 訊 埠 ( 危 險 等 級 )Severity 三 個 等 級 :low medium 及 high Description 摘 要 (Synopsis) 描 述 (Description) 解 決 方 案 (Solution) ( 風 險 級 數 )Risk factor
samba 版 本 漏 洞 Synopsis : It is possible to execute code on the remote host through samba. Description : The version of the Samba server installed on the remote host is affected by multiple heap overflow vulnerabilities, which can be exploited remotely to execute code with the privileges of the samba daemon. See also : http://www.samba.org/samba/security/cve-2007-2446.html Solution : Upgrade to Samba version 3.0.25 or later. Risk factor : Critical / CVSS Base Score : 10.0 (CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C) CVE : CVE-2007-2446 BID : 23973, 24195, 24196, 24197, 24198 Other references : OSVDB:34732
php 版 本 漏 洞 Synopsis : The remote web server uses a version of PHP that is affected by multiple flaws. Description : According to its banner, the version of PHP installed on the remote host is older than 5.2.5. Such versions may be affected by various issues, including but not limited to several buffer overflows. See also : http://www.php.net/releases/5_2_5.php Solution : Upgrade to PHP version 5.2.5 or later. Risk factor : High / CVSS Base Score : 7.5 (CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P) CVE : CVE-2007-4887 BID : 26403
網 路 分 享 Synopsis : It is possible to access a network share. Description : The remote has one or many Windows shares that can be accessed through the Network. Depending on the share rights, it may allow an attacker to read/write confidential data. Solution : To restrict access under Windows, open the explorer, do a right click on each shares, go to the 'sharing' tab, and click on 'permissions Risk factor : High / CVSS Base Score : 7.5 (CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P) CVE : CVE-1999-0519, CVE-1999-0520 BID : 8026 Other references : OSVDB:299
SNMP 使 用 預 設 community Synopsis : The community name of the remote SNMP server can be guessed. Description : It is possible to obtain the default community names of the remote SNMP server. An attacker may use this information to gain more knowledge about the remote host, or to change the configuration of the remote system (if the default community allow such modifications). Solution : Disable the SNMP service on the remote host if you do not use it, filter incoming UDP packets going to this port, or change the default community string. Risk factor : High / CVSS Base Score : 7.5 (CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P) Plugin output : The remote SNMP server replies to the following default community strings : private public CVE : CVE-1999-0186, CVE-1999-0254, CVE-1999-0516, CVE-1999-0517, CVE-2004-0311, CVE-2004-1474 BID : 11237, 10576, 177, 2112, 6825, 7081, 7212, 7317, 9681, 986 Other references : IAVA:2001-B-0001, OSVDB:10206
Windows 系 統 漏 洞 Synopsis : Arbitrary code can be executed on the remote host due to a flaw in the 'server' service. Description : The remote host is vulnerable to a buffer overrun in the 'Server' service which may allow an attacker to execute arbitrary code on the remote host with the 'System' privileges. Solution : Microsoft has released a set of patches for Windows 2000, XP and 2003 : http://www.microsoft.com/technet/security/bulletin/ms06-040.mspx Risk factor : Critical / CVSS Base Score : 10.0 (CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C) CVE : CVE-2006-3439 BID : 19409
CVE CVE: Common Vulnerability and Exploit is a dictionary of public known information security and explosures http://cve.mitre.org/ CVE-xxxx-xxxx (xxxx 為 四 位 數 字 ) 第 一 組 數 字 表 示 年 度, 第 二 組 數 字 表 示 該 年 度 第 組 個 被 發 現 的 安 全 弱 點 CAN-xxx-xxxx (xxxx 為 四 位 數 字 ) CAN 為 被 發 現 但 尚 未 通 過 CVE 委 員 評 估, 為 一 弱 點 之 候 選 當 通 過 委 員 會 評 估 後,CAN 會 改 成 CVE, 但 其 後 的 數 字 不 會 改 變
CVSS CVSS:Common Vulnerability Score System 目 的 : 在 於 提 供 一 套 檢 查 資 訊 系 統 安 全 漏 洞 的 標 準 方 式, 並 給 予 每 個 漏 洞 評 分, 可 供 修 補 漏 洞 的 先 後 順 序 做 為 重 要 的 參 考, 所 有 的 漏 洞 評 分 皆 透 過 資 安 專 家 嚴 格 的 評 量 是 由 美 國 國 家 基 礎 建 設 諮 詢 委 員 會 ( NIAC ) 委 託 製 作, 並 且 受 到 業 界 的 支 持
可 能 的 誤 判 清 況 應 用 系 統 判 斷 錯 誤 如 在 linux server 上 出 現 IIS 或 MS-SQL 已 修 補 的 弱 點 Nessus 利 用 banner 判 斷 套 件 已 修 補 但 banner 未 改 變 不 同 系 統 之 修 補 版 本 不 同 自 行 開 的 服 務 使 用 自 訂 的 通 訊 埠 使 用 其 它 常 用 服 務 的 通 訊 埠
系 統 安 全 強 化 的 步 驟 系 統 更 新 定 期 更 新 套 件 修 改 不 安 全 的 設 定 關 閉 不 必 要 的 服 務 弱 點 掃 描 根 據 弱 點 掃 描 報 告 進 行 修 補 再 次 進 行 弱 點 掃 描, 以 確 認 安 全 漏 洞 是 否 已 修 補
Patch update Linux 自 行 下 載 rpm 套 件 或 原 始 碼 更 新 利 用 apt 或 yum 進 行 套 件 更 新 Windows Windows Update Microsoft Update (Windows XP or late) 開 始 程 式 集 Windows Update SMS (System Management Server)
結 論 定 期 執 行 弱 點 掃 描 是 資 安 工 作 的 第 一 步, 也 是 最 重 要 的 一 步 需 經 常 留 意 安 全 通 報, 發 現 自 已 安 裝 之 軟 體 套 件 是 否 出 現 新 的 安 全 漏 洞 建 議 訂 閱 資 安 通 報 發 現 安 全 漏 洞 應 儘 速 進 行 修 補, 若 不 能 修 補 應 考 慮 進 行 接 取 控 制 或 其 它 替 代 方 案 未 經 同 意 對 其 它 人 的 系 統 進 行 掃 描 是 違 法, 進 行 掃 描 前 最 好 有 書 面 同 意 文 件
安 全 通 報 網 站 國 內 : TWCERT/CC:http://www.cert.org.tw/ GSNCERT: http://www.gsn-cert.nat.gov.tw/ 國 外 : http://nvd.nist.gov/ http://www.kb.cert.org/vuls 系 統 / 軟 體 官 方 網 站 資 安 產 品 網 站
MBSA Microsoft Baseline Security Analyzer 微 軟 推 出 的 簡 易 安 全 工 具, 用 來 檢 查 windows 系 統 是 否 有 未 更 新 的 安 全 漏 洞 最 後 的 release 版 本 為 2.1 版 http://technet.microsoft.com/en-us/security/cc184923.aspx
Open source Web vulnerability scanner Nikto:http://cirt.net/nikto2 Paros proxy:http://www.parosproxy.org/index.shtml Web Scarab: http://www.owasp.org/index.php/category:owasp_webs carab_project Wikto:http://www.sensepost.com/research/wikto/ Burp Suite:http://www.portswigger.net/suite/
商 業 版 web vulnerability scanner Web Inspect: https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-201-200%5e9570_4000_100 AppScan http://www-01.ibm.com/software/awdtools/appscan/ Acunetix Web Security Scanner http://www.acunetix.com/
Nikto http://cirt.net/nikto2 開 放 源 web 伺 服 器 掃 描 工 具 針 對 伺 服 器 版 本 檔 案 等 進 行 快 速 掃 描 ( 非 暗 中 掃 描 ) 需 求 SSL support the Net::SSLeay PERL module must be installed 安 裝 # wget http://cirt.net/nikto/nikto-current.tar.gz # tar -zxvf nikto-current.tar.gz # cd nikto-2.1.1/
進 行 更 新 #./nikto.pl update 基 本 的 測 試 # perl nikto.pl h host_ip # perl nikto.pl h host_ip p 443 # perl nikto.pl h https://host_ip/ # perl nikto.pl h host_ip p 443 -ssl
Paros proxy URL: http://www.parosproxy.org/index.shtml JAVA-based 網 頁 應 用 程 式 安 全 工 具 XSS SQL Injection 安 裝 安 裝 JRE(JDK) 下 載 PAROS porxy: http://www.parosproxy.org/download.shtml
Q & A