1 / 37

Linux 系統管理與安全

Linux 系統管理與安全. 吳賢明 國立中興大學 計算機及資訊網路中心 中華民國九十年八月三日 . 課程大綱. 關於電腦系統安全 電腦安全自我檢測與防護 Linux 系統檔案完整性與安全 Linux 系統紀錄與安全 Linux 系統安全工具 Q & A. 關於電腦安全. Computer Security “A computer is secure if you can depend on it and its software to behave as you expect.” -Practical UNIX and Internet Security

Download Presentation

Linux 系統管理與安全

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux系統管理與安全 吳賢明 國立中興大學 計算機及資訊網路中心 中華民國九十年八月三日 

  2. 課程大綱 • 關於電腦系統安全 • 電腦安全自我檢測與防護 • Linux系統檔案完整性與安全 • Linux 系統紀錄與安全 • Linux系統安全工具 • Q & A

  3. 關於電腦安全 • Computer Security • “A computer is secure if you can depend on it and its software to behave as you expect.”-Practical UNIX and Internet Security • “電腦安全的終極目標在-處理敏感資料時可以被信任的系統” -UNIX 系統保全工具

  4. 關於電腦安全 • 資料完整性(Integrity) • 確保儲存於該系統的任何資料不被竄改或破壞。 • 私秘性(Privacy) • 確保儲存於其中的任何資料及透過該系統傳輸的資料不被竊取。 • 系統可用性(Availability) • 保證維持系統隨時可正常提供服務

  5. 駭客最愛的攻擊前哨站 脆弱的校園網路環境 • 數量眾多的電腦系統 • 不成比例的專職管理人員 • 風氣開放自由的電腦使用環境

  6. 校園網路安全的隱憂 • 入侵手法的專業及複雜程度程度提昇 • 入侵者所需專業知識卻大幅下降 • 入侵工具與日俱增,垂手可得 • 主機數與使用人口逐年激增 • 網際互連所使用的應用程式種類與數量快速上揚,具有安全缺失的軟體亦隨之增加 • 網路安全工具的發展通常落後於多樣化的入侵 • 網路新殺手-電腦病毒,正藉由網路快速擴張其影響層面,來無影,去無蹤

  7. 道高一尺 魔高一丈 “Defending Yourself: The Role of Intrusion Detection Systems”, IEEE SOFTWARE Sep/Oct 2000

  8. Vulnerability-系統弱點 • 系統弱點是系統、程式或標準制定過程考慮欠週,所遺留可資侵入之漏洞。 • 系統弱點是絕大多數入侵事件的憑藉。 • 系統弱點即時的修補是確保系統安全及重要的工作。

  9. 系統弱點增加趨勢 http://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.html

  10. 系統弱點的生命週期 “Windows of Vulnerability: A Case Study Analysis”, IEEE SOFTWARE Sep/Oct 2000

  11. 系統弱點分佈與作業系統 http://www.securityfocus.com/frames/?content=/forums/bugtraq/faq.html

  12. 校園主機安全防護 • 『The Network is Computer』-主機安全是校園網路安全的第一步 • 安全政策的擬定與實施 • 主機安全三部曲 • 系統安全防護 • 系統安全自我檢測 • 快速安全的入侵系統復原 • 善用系統及網路安全工具

  13. 系統安全措施 • 系統安全:系統防護的三個重要觀念 • 分散:可減少損失 • 備援:確保某些系統被破壞時,整體系統仍可運作如常 • 防禦縱深:讓攻擊者能夠造成實際損害之前,必須先突破重重防線。增加攻擊者的困難度。 • 系統安全工具的使用,在於加強系統的防禦縱深。 • 系統安全防護: • 實體安全:主機外殼設置防範措施或機房門禁管制。 • 帳號安全:一般帳號與root帳號的管理。 • 檔案系統安全:乃是防護的核心,如權限設定、加密、系統指紋、備份等。

  14. 帳號安全 • 帳號安全 • 帳號安全的淪陷通常是系統入侵成功的第一步 • 帳號安全應包括一般帳號與root帳號的管理 • 重要做法 • 教育使用者正確使用及選擇密碼。 • 分配密碼:為使用者提供密碼,使他們沒選用脆弱密碼的機會。 • 密碼逾時機制:強迫使用者定期更換密碼。 • 使用shadow密碼。將密碼由/etc/passwd中分離出來。 • 預防性密碼稽查:在密碼生效之前就評估其安全性 • 預防性密碼檢查工具包括passwd+、npasswd等,RedHat Linux則內建CrackLib檢查使用者的密碼。 • 反應性密碼稽查:用密碼檢查程式找出不安全的密碼。 • 工具-- Crack 、Crack for NT • 限制root帳號進入系統的方式

  15. 檔案安全 • 檔案系統安全: • 檔案系統控制誰能存取資訊,以及對資訊能作何種處理。 • 當一切防護均失效時,加密機制仍能維護檔案的機密性。 • 重要做法 • 審慎授與使用者適當的檔案權限 • 建立系統重要檔案『指紋資料庫』 • 『指紋資料庫』的完整性是系統安全的一個極重要指標 • 建立最佳時機為系統初建立及更新時 • 應建立指紋的檔案包括系統執行檔、應用程式組態檔及其他重要資料檔 • 定時檢查及更新『指紋資料庫』 • 相關的工具 • sum/cksum:可檢查某檔案的CRC值。 • MD5:可用來製作訊息和檔案指紋。 • RPM(RedHat Package Manager):軟體安裝程式的驗證與簽章檢查。 • Tripwire 、AIDE: 檔案系統完整性檢查工具

  16. 系統安全自我檢測 • 定期安全自我檢測 • 組態錯誤、程式瑕疵、系統漏洞,以及其他潛在的安全問題。 • 檢測應藉助安全工具,有系統且定期進行 • 系統弱點掃描工具--COPS (Computer Oracle and Password System) 、 Tiger (美國德州A&M大學研發) • 網路弱點掃描工具--SATAN 、SAINT、ISS 、 Nessus 、Nmap 、CGI scanner • 安全缺失修補 • 組態修正 • 修補程式(Security Patch) • 版本更新

  17. 系統安全稽核及其他 • 其他具體做法建議 • 嚇阻力量是最好的防禦-善用系統稽核(auditing)與記錄(log) • 留意來自網路上及軟體廠商的系統安全漏洞報告,並確實修補之 • 訂閱系統安全相關討論群組文章(Mailing List)

  18. UNIX Security Checklist --http://www.cert.org/tech_tips/intruder_detection_checklist.html • Look for Signs That Your System May Have Been Compromised • Examine log files • Look for setuid and setgid Files • Check system binaries • Check for packet sniffers • Examine files run by 'cron' and 'at'. • Check for unauthorized services • Examine /etc/passwd file • Check system and network configuration • Look everywhere for unusual or hidden files • Examine all machines on the local network

  19. Linux系統檔案完整性與安全 • 常見系統入侵程序 • 進入系統利用各種管道取得系統Super User權限留下後門(BacckDoor)便利日後進入系統。 • 留意系統檔案不正常異動是早期發現入侵徵候及檢查惡意程式碼的最佳方法 • 正常檔案 v.s 異常檔案 • Files Finger Print • 常見工具 • Tripwire 、TAMU 、ATP 、AIDE

  20. Linux系統檔案完整性檢查 • 正常檔案特徵紀錄保存-檔案指紋建立 • 檔案檢查原理是比對,因此你必須在確定系統是乾淨的時候,建立比對依據的指紋資料(Fingerprint),而建立這個檔案的最佳時機是當你完成系統安裝,尚未對外開放的時候,或系統完成更新時. • File Time 、 Size 、 Access Mode 、 Check Sum… • 檔案特徵比對 • 檔案特徵紀錄更新 • 系統檔案正常變動後

  21. 系統檔案檢查工具-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).

  22. AIDE • 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 current version is 0.7) • Where :  • http://www.securityfocus.com/data/tools/aide-0.7.tar.gz • Use archie to find this file

  23. AIDE • 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

  24. AIDE – An Example ###把/etc/passwd的permission由644改為664,測試aide可以檢查出來 [woody@nmc aide-0.7]# ls -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/passwd [woody@nmc aide-0.7]# ls -l /etc/passwd -rw-rw-r-- 1 root root 5596 Jun 15 09:45 /etc/passwd [woody@nmc aide-0.7]# aide - -check AIDE found differences between database and filesystem!! Start timestamp: 2000-06-16 15:40:30 Summary: 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

  25. AIDE • 選擇適當時機建立aide.db,更新時謹慎行事 • 妥善保存aide.db(Tape or Floopy)  • 精確修改aide.conf,去除無意義的檢查(例如經常更動的檔案),使你的檢查結果更有意義

  26. Linux 系統紀錄 請參考:http://nmc.nchu.edu.tw/linux/system_log.htm • 嚇阻力量是最好的防禦-系統稽核(auditing)與記錄(log) • Linux上的系統記錄機制 • syslogd無關系統記錄:如wtmp、utmp、lastlog、pacct等。 • syslogd相關系統記錄檔: messages、syslog及管理者所設定之檔案。 • 應用程式運作記錄檔: 如Apache Server的access.log及error.log等。

  27. Linux 系統紀錄-Syslogd • syslogd • syslogd是UNIX中負責記錄『大部分』系統事件(event)的一個背景程式(daemon) 。 • syslogd可以經由設定與設計,記錄包括核心、系統程式及使用者自行開發程式的運作情形及所發生的事件。 • syslogd的記錄以純文字的方式記錄於檔案中,管理者可以用任何文字編輯緝查閱,藉以掌握系統各項活動。 • /etc/syslog.conf是syslogd運作的關鍵,經由適當的設定,syslogd可以把相關應用程式的指定事件,寫入特定檔案之中,供管理與系統追蹤之用。

  28. Linux 系統紀錄-Syslogd

  29. /etc/syslog.conf • /etc/syslog.conf內容控制syslogd如何紀錄系統相關事件(What、Where) 。 • /etc/syslog.conf內容更動必須重新啟動syslogd更動部份方始生效。 • /etc/syslog.conf格式 Selector1 Action1 Selector2 Action2 …. • 當符合『 Selectorx』描述的事件發生時,採取『Actionx』所指定之方式記錄此一事件。

  30. Selector • SELECTOR = facility.priority • Priority是事件的優先等級。一般而言,syslogd將系統事件分成八個不同的等級 debuginfonoticewarning(=warn)error(=err)critalertemerg(=panic)。(優先順序由低至高排列) • Facility是產生事件的子系統(subsystem),syslog.conf中用來描素事件產生子系統的關鍵字。系統內定facility包括auth、auth-priv、cron、daemon、kern、lpr、mail、mark、news、security(=auth)、syslog、user、uucp,使用者自行開發之程式則可使用local1 ~ local7。

  31. Action • ACTION這個欄位描述syslogd會將符合該行中SELECTOR條件的訊息,記錄於何處。 • 一般檔案(Regular File): • 檔案以絕對路徑方式描述,檔案不存在,syslogd啟動,重新讀取/etc/syslog.conf時會自動產生。 • 終端機或是主控站(e.g. /dev/tty0 or /dev/console in Linux) • 使用者名稱(List of Users) • 所有線上使用者(with symbol “*”) • 遠端主機

  32. Eaxmple 1 #etc/syslog.conf內容 # Store critical stuff in critical # *.=crit;kern.none /var/adm/critical • 將除了facility『kern』外的所有facility,priority等級為crit (and crit only)的message記錄到檔案/var/adm/critical中。

  33. Eaxmple 2 #etc/syslog.conf內容 kern.* /var/adm/kernel kern.crit @finlandia kern.crit /dev/console kern.info;kern.!err /var/adm/kernel-info • 將所有『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』中。

  34. Eaxmple 3 #etc/syslog.conf內容 mail.=info /dev/tty6 • 將mail.info(and mail.info only)的message轉向至系統的第6個Local終端機的銀幕作即時的輸出。在Linux中Hot Key『Alt+F6』將使用者帶至這個終端機。

  35. Eaxmple 4 #etc/syslog.conf內容 mail,news.=info /var/adm/info *.=emerg * • 將mail.info及news.info的相關message記錄至檔案/var/adm/info • 將所有facility的emerg事件發生時的相關訊息(例如系統關機),送至當時線上每一個使用者的終端機輸出,用以通知線上的使用者。

  36. Linux 系統紀錄-Syslogd • What syslogd can help you? • 安全查核(Security Checking) • 系統組態除錯(Configuration Debug) • 系統性能評估與擴充規劃(Performance Scheduling) • 使用系統紀錄機制 • 系統事件記錄檔適當的分門別類 • 慎選日誌檔所在檔案系統位置 • 定時清除及備份日誌檔

  37. Linux系統管理與安全 Q & A

More Related