中中中中 中中中中 中中中中中中中中中中 中中中中中中中中中中 Linux Linux 中中中中中中中 中中中中中中中 Linux Linux 中中中中中中中 中中中中中中中 中中中 中中中中中中 中中中中中中中中中中 中中中中中中中中中中中
Jan 03, 2016
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
LinuxLinux 系統管理與安全系統管理與安全
吳賢明國立中興大學 計算機及資訊網路中心
中華民國九十年八月三日
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
課程大綱課程大綱關於電腦系統安全電腦安全自我檢測與防護Linux 系統檔案完整性與安全Linux 系統紀錄與安全Linux 系統安全工具Q & A
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
關於電腦安全關於電腦安全Computer Security
– “A computer is secure if you can depend on it and its software to behave as you expect.”
-Practical UNIX and Internet S
ecurity
– “ 電腦安全的終極目標在 - 處理敏感資料時可以被信任的系統” -UNIX 系統保全工具
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
關於電腦安全關於電腦安全資料完整性 (Integrity)
– 確保儲存於該系統的任何資料不被竄改或破壞。
私秘性 (Privacy)– 確保儲存於其中的任何資料及透過該系統傳
輸的資料不被竊取。系統可用性 (Availability)
– 保證維持系統隨時可正常提供服務
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
脆弱的校園網路環境脆弱的校園網路環境數量眾多的電腦系統不成比例的專職管理人員風氣開放自由的電腦使用環境
駭客最愛的攻擊前哨站駭客最愛的攻擊前哨站
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
校園網路安全的隱憂校園網路安全的隱憂 入侵手法的專業及複雜程度程度提昇
– 入侵者所需專業知識卻大幅下降 入侵工具與日俱增,垂手可得 主機數與使用人口逐年激增 網際互連所使用的應用程式種類與數量快速上
揚,具有安全缺失的軟體亦隨之增加 網路安全工具的發展通常落後於多樣化的入侵 網路新殺手 - 電腦病毒,正藉由網路快速擴張
其影響層面,來無影,去無蹤
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
道高一尺 魔高一丈道高一尺 魔高一丈
““Defending Yourself: The Role of Intrusion Detection Systems”, IEEE SOFTWARE Sep/Oct 2000Defending Yourself: The Role of Intrusion Detection Systems”, IEEE SOFTWARE Sep/Oct 2000
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Vulnerability-Vulnerability- 系統弱點系統弱點 系統弱點是系統、程式或標準制定過程
考慮欠週,所遺留可資侵入之漏洞。系統弱點是絕大多數入侵事件的憑藉。系統弱點即時的修補是確保系統安全及
重要的工作。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統弱點增加趨勢系統弱點增加趨勢
http://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.htmlhttp://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.html
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統弱點的生命週期系統弱點的生命週期
““Windows of Vulnerability: A Case Study Analysis”, IEEE SOFTWARE Sep/Oct 2000Windows of Vulnerability: A Case Study Analysis”, IEEE SOFTWARE Sep/Oct 2000
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統弱點分佈與作業系統系統弱點分佈與作業系統
http://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.htmlhttp://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.html
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
校園主機安全防護校園主機安全防護『 The Network is Computer 』 - 主機安全
是校園網路安全的第一步安全政策的擬定與實施主機安全三部曲
– 系統安全防護– 系統安全自我檢測– 快速安全的入侵系統復原
善用系統及網路安全工具
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統安全措施系統安全措施 系統安全:系統防護的三個重要觀念
– 分散:可減少損失– 備援:確保某些系統被破壞時,整體系統仍可運作如常– 防禦縱深:讓攻擊者能夠造成實際損害之前,必須先突破重重
防線。增加攻擊者的困難度。 系統安全工具的使用,在於加強系統的防禦縱深。
系統安全防護:– 實體安全:主機外殼設置防範措施或機房門禁管制。– 帳號安全:一般帳號與 root帳號的管理。– 檔案系統安全:乃是防護的核心,如權限設定、加密、系統指紋、
備份等。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
帳號安全帳號安全帳號安全
– 帳號安全的淪陷通常是系統入侵成功的第一步– 帳號安全應包括一般帳號與 root帳號的管理
重要做法– 教育使用者正確使用及選擇密碼。– 分配密碼:為使用者提供密碼,使他們沒選用脆弱密碼的機會。– 密碼逾時機制:強迫使用者定期更換密碼。– 使用 shadow密碼。將密碼由 /etc/passwd 中分離出來。– 預防性密碼稽查:在密碼生效之前就評估其安全性
預防性密碼檢查工具包括 passwd+ 、 npasswd等, RedHat Linux則內建CrackLib 檢查使用者的密碼。
– 反應性密碼稽查:用密碼檢查程式找出不安全的密碼。 工具 -- Crack 、 Crack for NT
– 限制 root帳號進入系統的方式
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
檔案安全檔案安全檔案系統安全:
– 檔案系統控制誰能存取資訊,以及對資訊能作何種處理。– 當一切防護均失效時,加密機制仍能維護檔案的機密性。
重要做法– 審慎授與使用者適當的檔案權限– 建立系統重要檔案『指紋資料庫』建立系統重要檔案『指紋資料庫』
『指紋資料庫』的完整性是系統安全的一個極重要指標 建立最佳時機為系統初建立及更新時 應建立指紋的檔案包括系統執行檔、應用程式組態檔及其他重要資料檔
– 定時檢查及更新『指紋資料庫』– 相關的工具
sum/cksum :可檢查某檔案的 CRC值。 MD5 :可用來製作訊息和檔案指紋。 RPM(RedHat Package Manager) :軟體安裝程式的驗證與簽章檢查。 Tripwire 、 AIDE: 檔案系統完整性檢查工具
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統安全自我檢測系統安全自我檢測 定期安全自我檢測
– 組態錯誤、程式瑕疵、系統漏洞,以及其他潛在的安全問題。– 檢測應藉助安全工具,有系統且定期進行– 系統弱點掃描工具 --COPS (Computer Oracle and Password Syst
em) 、 Tiger (美國德州 A&M 大學研發 )– 網路弱點掃描工具 --SATAN 、 SAINT 、 ISS 、 Nessus 、
Nmap 、 CGI scanner
安全缺失修補– 組態修正– 修補程式 (Security Patch)– 版本更新
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統安全稽核及其他系統安全稽核及其他其他具體做法建議
– 嚇阻力量是最好的防禦 - 善用系統稽核 (auditing) 與記錄 (log)
– 留意來自網路上及軟體廠商的系統安全漏洞報告,並確實修補之
– 訂閱系統安全相關討論群組文章 (Mailing List)
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
UNIX Security ChecklistUNIX Security Checklist -- --http://www.cert.org/tech_tips/intruder_detection_checklist.htmlhttp://www.cert.org/tech_tips/intruder_detection_checklist.html
Look for Signs That Your System May Have Been Compromised – Examine log filesExamine log files – Look for setuid and setgid FilesLook for setuid and setgid Files – Check system binariesCheck system binaries – Check for packet sniffers – Examine files run by 'cron' and 'at'. – Check for unauthorized services – Examine /etc/passwd fileExamine /etc/passwd file – Check system and network configuration – Look everywhere for unusual or hidden filesLook everywhere for unusual or hidden files – Examine all machines on the local network
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
LinuxLinux 系統檔案完整性與安全系統檔案完整性與安全 常見系統入侵程序
– 進入系統利用各種管道取得系統 Super User權限留下後門 (BacckDoor)便利日後進入系統。
留意系統檔案不正常異動是早期發現入侵徵候及檢查惡意程式碼的最佳方法
正常檔案 v.s 異常檔案– Files Finger Print
常見工具– Tripwire 、 TAMU 、 ATP 、 AIDE
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
LinuxLinux 系統檔案完整性檢查系統檔案完整性檢查 正常檔案特徵紀錄保存 -檔案指紋建立
– 檔案檢查原理是比對,因此你必須在確定系統是乾淨的時候,建立比對依據的指紋資料 (Fingerprint) ,而建立這個檔案的最佳時機是當你完成系統安裝,尚未對外開放的時候,或系統完成更新時 .
File Time 、 Size 、 Access Mode 、 Check Sum…
檔案特徵比對檔案特徵紀錄更新
– 系統檔案正常變動後
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
系統檔案檢查工具系統檔案檢查工具 -AIDE-AIDE AIDE (Advanced intrusion detection environment)
– 是一個可以藉由檔案完整性檢查 (File Integrity Check) ,協助管理者早期發現系統入侵跡象的安全工具。
– AIDE 可以根據管理者訂下的檔案範圍及檢查項目 (Permission, Access Time, Modify Time, Check Sum ....) ,藉由比對方式,產生檔案變動的報告。
– AIDE 可以檢查檔案特性項目包括:存取權限設定 (permissions), inode編號 (inode number), 檔案擁有者 (user), 檔案擁有群組 (group), 檔案大小 (file size),檔案最近被修改時間 (mtime and ctime), 檔案最近被修改時間 (atime), 檔案大小的改變 (growing size) 及檔案鏈結數 (number of links)…
– AIDE 用來檢查檔案完整性的演算法 (Algorithm)包括: sha1, md5, rmd160, tiger (crc32, haval and gost can be compiled in if mhash support is available).
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
AIDEAIDE AIDE適用平台:
– Solaris 2.5.1,2.6,7 、 Linux 2.2.x,2.0.x 、 FreeBSD 2.2.8,3.4 、 Unixware 7.0.1 、 BSDi 4.1 OpenBSD 2.6
Get AIDE:– 檔名: aide-xx.tar.gz (xx is the version name, the curre
nt version is 0.7) – Where :
http://www.securityfocus.com/data/tools/aide-0.7.tar.gz Use archie to find this file
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
AIDEAIDE
AIDE 安裝 (參考 http://nmc.nchu.edu.tw/linux/aide.htm)
– Compile the source– Modify the configuration file
保留哪些檔案的特徵 保留檔案的哪些特徵
– Create initial AIDE Database (For the files finger print) aide --init
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
AIDE – An ExampleAIDE – An Example###把 /etc/passwd 的 permission 由 644 改為 664 ,測試 aide 可以檢查出來[woody@nmc aide-0.7]# ls -l /etc/passwdls -l /etc/passwd -rw-r--r-- 1 root root 5596 Jun 15 09:45 /etc/passwd[woody@nmc aide-0.7]# chmod g+w /etc/passwdchmod g+w /etc/passwd [woody@nmc aide-0.7]# ls -l /etc/passwdls -l /etc/passwd -rw-rw-r-- 1 root root 5596 Jun 15 09:45 /etc/passwd[woody@nmc aide-0.7]# aide - -checkaide - -checkAIDE found differences between database and filesystem!!Start timestamp: 2000-06-16 15:40:30Summary:Total number of files=1211,added files=0,removed files=0, changed files=1 Changed files:changed:/etc/passwd###aide 發現 /etc/passwd 的 permission遭修改,並提出警告Detailed information about changes:File: /etc/passwdPermissions: old = -rw-r--r-- , new = -rw-rw-r--Ctime: old = 2000-06-15 09:45:43, new = 2000-06-16 15:39:32End timestamp: 2000-06-16 15:40:48
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
AIDEAIDE
選擇適當時機建立 aide.db ,更新時謹慎行事
妥善保存 aide.db(Tape or Floopy) 精確修改 aide.conf ,去除無意義的檢查
( 例如經常更動的檔案 ) ,使你的檢查結果更有意義
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Linux Linux 系統紀錄系統紀錄請參考:請參考: http://nmc.nchu.edu.tw/linux/system_log.htmhttp://nmc.nchu.edu.tw/linux/system_log.htm
嚇阻力量是最好的防禦 - 系統稽核 (auditing) 與記錄 (log)
Linux 上的系統記錄機制– syslogd 無關系統記錄 : 如 wtmp 、 utmp 、 lastlog 、
pacct等。– syslogd相關系統記錄檔 : messages 、 syslog 及管理
者所設定之檔案。– 應用程式運作記錄檔 : 如 Apache Server 的 access.lo
g 及 error.log等。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Linux Linux 系統紀錄系統紀錄 --SyslogdSyslogd syslogd
– syslogd 是 UNIX 中負責記錄『大部分』系統事件 (event) 的一個背景程式 (daemon) 。
– syslogd 可以經由設定與設計,記錄包括核心、系統程式及使用者自行開發程式的運作情形及所發生的事件。
– syslogd 的記錄以純文字的方式記錄於檔案中,管理者可以用任何文字編輯緝查閱,藉以掌握系統各項活動。
– /etc/syslog.conf 是 syslogd 運作的關鍵,經由適當的設定, syslogd 可以把相關應用程式的指定事件,寫入特定檔案之中,供管理與系統追蹤之用。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Linux Linux 系統紀錄系統紀錄 --SyslogdSyslogd
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
/etc/syslog.conf/etc/syslog.conf /etc/syslog.conf內容控制 syslogd 如何紀錄系統相關事件 (What 、 Where) 。
/etc/syslog.conf內容更動必須重新啟動 syslogd更動部份方始生效。
/etc/syslog.conf格式Selector1 Action1Selector1 Action1Selector2 Action2Selector2 Action2……..
– 當符合『 當符合『 SelectorSelectorxx 』描述的事件發生時,採取』描述的事件發生時,採取『『 ActionActionxx 』所指定之方式記錄此一事件。』所指定之方式記錄此一事件。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
SelectorSelectorSELECTOR = facility.priority
– Priority 是事件的優先等級。一般而言, syslogd將系統事件分成八個不同的等級debuginfonoticewarning(=warn)error(=err)critalertemerg(=panic) 。 (優先順序由低至高排列 )
– Facility 是產生事件的子系統 (subsystem) , syslog.conf 中用來描素事件產生子系統的關鍵字。
系統內定 facility包括 auth 、 auth-priv 、 cron 、 daemon 、 kern 、lpr 、 mail 、 mark 、 news 、 security(=auth) 、 syslog 、 user 、 uucp ,使用者自行開發之程式則可使用 local1 ~ local7 。
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
ActionAction ACTION這個欄位描述 syslogd會將符合該行中 S
ELECTOR條件的訊息,記錄於何處。 – 一般檔案 (Regular File):
檔案以絕對路徑方式描述,檔案不存在, syslogd啟動,重新讀取 /etc/syslog.conf 時會自動產生。
– 終端機或是主控站 (e.g. /dev/tty0 or /dev/console in Linux)
– 使用者名稱 (List of Users)– 所有線上使用者 (with symbol “*”) – 遠端主機
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Eaxmple 1Eaxmple 1
將除了 facility『 kern』外的所有 facility, priority等級為 crit (and crit only)的 message記錄到檔案 /var/adm/critical中。
#etc/syslog.conf內容# Store critical stuff in critical#*.=crit;kern.none /var/adm/critical
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Eaxmple 2Eaxmple 2
將所有『 kern』 facility相關 messages記錄至 /var/adm/kernel。 將『 kern.crit』、『 kern.alert』及『 kern.emerg』相關訊息,利用 port 143送至遠端主機 finlandia記錄。 (priority比 crit高的訊息有 alert及 emerg)。
將『 kern.crit』、『 kern.alert』及『 kern.emerg』相關訊息傳送到系統 Console。 (Console一般是指人為定義的某一台連接主機的終端機 )。
將『 kern』相關, priority高於或等於『 info』,但 priority為『 error』除外的訊息記錄至檔案『 /var/adm/kernel-info』中。
#etc/syslog.conf內容kern.* /var/adm/kernelkern.crit @finlandiakern.crit /dev/consolekern.info;kern.!err /var/adm/kernel-info
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Eaxmple 3Eaxmple 3
將 mail.info(and mail.info only)的 message轉向至系統的第 6個 Local終端機的銀幕作即時的輸出。在 Linux中 Hot Key『 Alt+F6』將使用者帶至這個終端機。
#etc/syslog.conf內容mail.=info /dev/tty6
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Eaxmple 4Eaxmple 4
將 mail.info及 news.info的相關 message記錄至檔案 /var/adm/info
將所有 facility 的 emerg 事件發生時的相關訊息 ( 例如系統關機 ) ,送至當時線上每一個使用者的終端機輸出,用以通知線上的使用者。
#etc/syslog.conf內容mail,news.=info /var/adm/info*.=emerg *
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
Linux Linux 系統紀錄系統紀錄 --SyslogdSyslogd
What syslogd can help you?– 安全查核 (Security Checking)– 系統組態除錯 (Configuration Debug)– 系統性能評估與擴充規劃 (Performance Sche
duling)使用系統紀錄機制
– 系統事件記錄檔適當的分門別類– 慎選日誌檔所在檔案系統位置 – 定時清除及備份日誌檔
中興大學中興大學計算機及資訊網路中心計算機及資訊網路中心
LinuxLinux 系統管理與安全系統管理與安全
LinuxLinux 系統管理與安全系統管理與安全
Q & AQ & A