Try   HackMD

OS筆記-Chapter 15: Security

tags: OS

目錄


安全性問題

  • 入侵者(intruder)/破壞者(cracker):嘗試突破安全性的人

  • 威脅(threat):違反安全的潛在

  • 攻擊(attach)嘗試破壞安全性

  • 攻擊藉由偽裝(masquerading)突破認證(authentication)

    • 重送攻擊(replay attack):有效資料重複的傳輸,例如:重複轉移錢
    • 中間人攻擊(man-in-the-middle attack):藉由連線劫持(session hijacking)攔截通訊
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • 為了保護系統,我們在四個層次採取安全措施

    • 硬體:保護能存取機器的機房
    • 人:只有適當的使用者可以存取
      • 人可能經由社交工程(social engineering)被欺騙
      • 網路釣魚(phishing)
      • 垃圾箱潛水(dumpster diving)
    • 作業系統:系統必須自我保護
    • 網路:大部分資料會經由網路傳輸

程式威脅(Program Threats)

  • 後門(back-door):能提供訊息或讓攻擊者容易存取的一個缺口

  • 木馬(Trojan horse):偽裝成無害程式,騙使用者開啟,例如:安裝無害軟體,利用隱密通道(covert channel)安裝間諜軟體

    • 模擬登入頁面,竊取帳密
    • 間諜軟體(spyware):監控系統、後門、廣告
  • 陷阱之門(trap door):迴避正常的安全檢查程序,例如:銀行的程式中加入錯誤的四捨五入以偷取小數點後的金額,積少成多

  • 邏輯炸彈(logic bomb):符合預先設定的參數,就會觸發的安全漏洞

  • 堆疊和緩衝區的溢位(Stack and Buffer Overflow)

    • 執行結果將產生一個root的殼(shell),或是其它特權指令的執行
    • 利用溢位置換堆疊中的返回位置,使程式返回攻擊者注入的程式碼區段
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
    • 因溢位而覆蓋掉原先的返回位置
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • 病毒(virus)

    • 自身複製,感染其它程式
    • 不會自己散播至其它機器
    • 病毒注射器(virus dropper):在系統中插入病毒
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
    • 按鍵側錄程式(keystroke logger)

系統和網路威脅(System and Network Threats)

  • 作業系統越開放就越有可能有錯誤讓人利用

    • 預設是安全(secure by default):降低系統的攻擊表面(attack surface)
  • 蠕蟲(worm)

    • 自身複製(spawn),感染其它程式
    • 會自己散播至其它機器
    • 掛勾(grappling hook/bootstrap/vector):連接原先已感染的機器,並載入主程式到上鉤的系統
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • 連接阜掃描(Port scanning):不算是攻擊,是用來偵測弱點

  • 拒絕服務(DOS,denial of service)

    • 擾亂系統或設備的合法使用
    • 兩種類型
      • 使用許多設備的資源造成沒有工作可以執行
      • 混亂設備的網路
    • 分散式拒絕服務(DDOA,distributed denial-of-service):多個被操控的殭屍設備向同一個目標攻擊

以密碼學為安全性工具

  • 電腦送出位元到網路上,卻不知道誰可能接收這些位元

  • 密碼學(cryptography)被用來限制訊息的潛在傳送者和接收者

  • 加密(encryption)

    • 加密演算法由以下元件組成
      • 鑰匙K
      • 訊息M
      • 祕文C
      • 加密函數E(k):M->C
      • 解密函數D(k):C->M
        Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
    • 對稱加密(symmetric encryption)
      • 使用相同的鑰匙加密和解密
      • 鑰匙的安全必須被保護
      • DES(data-encryption standard):64-bit,區段加密,不夠安全
      • AES(advanced encryption standard):128-bit
      • RC4:串流加密(stream cipher)
    • 非對稱加密(asymmetric encryption)
      • 加密與解密使用不同鑰匙
      • RSA加密
        1. N=pq
        2. r=(p-1)(q-1)
        3. e<q,gcd(e,q)=1
        4. ed ≡ 1 (mod r)
        5. (N,e)公鑰,加密:c ≡ mᵉ (mod N)
        6. (N,d)私鑰,解密:m ≡ cᵈ (mod N)
      • 大家用公鑰加密,擁有私鑰者才能知道內容
        Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
  • 認證(authentication)

    • 限制訊息可能傳送者(知道是誰傳來的)
    • 認證演算法由以下元件組成
      • 鑰匙K
      • 訊息M
      • 認證因子A
      • 產生認證函數S(k):M->A
      • 對訊息驗證函數V(k):M✖A->{True,False}
    • 雜湊函數(hash function)
      • H(M)產生固定大小的資料區塊,稱為訊息摘要(messege digest)或雜湊值(hash value)
      • H(M)=H(M'),只有當M=M'
      • H必須被保護,否則H(M)的內容可以被偽造
    • 對稱加密法
      • 訊息認證碼(MAC,messeage-authentication code)
      • 使用安全的鑰匙認證訊息
    • 數位簽名演算法(digital-sifnature algorithm)
      • 認證因子在此稱為數位簽名
      • 與RSA相似,只是鑰匙的使用是反過來的
      • 使用私鑰加密,公鑰持有者能認證
      • 不可否認性(nonrepudiation)
  • 鑰匙分配

    • 公開鑰匙不需要保密,簡單的儲存可以用來儲存鑰匙環
      • 但攻擊者也可能偽造公開鑰匙
        Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
    • 數位憑證(digital certificate):由信任的第三方數位簽署的公開鑰匙
  • 密碼學的製作

    • 通常網路協定以階層(layer)的方式組織
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
    • 密碼學幾乎能插入OSI中任何階層
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • 範例:SSL

    • SSL 3.0是一種讓兩台電腦安全地通信的密碼協定
    • 進化成TLS協定
    • 客戶與伺服器可以建立一個安全的會議層鑰匙(session key),避免中間人攻擊及重送攻擊
    • 步驟
      1. 伺服器由憑證機構得到憑證,憑證內容
        • 伺服器屬性
        • 公鑰
        • 憑證有效期間
        • 非對稱加密演算法E()的識別
      2. 客戶從憑證機構取得驗證演算法
      3. 客戶連線至伺服器,傳送隨機值
      4. 伺服器回應,並加上憑證
      5. 客戶驗證(包含有效期間)

使用者認證(User Authentication)

  • 作業系統的主要安全問題

  • 密碼

    • 最普通的方法
    • 但可能被猜出或意外的暴露
      • 猜密碼可能從一般人常使用的資料(如:生日、電話等等)或是暴力破解
      • 若密碼寫在能夠被讀出的地方,則可能暴露
    • 一些系統使用老化,強迫使用者在固定期間內要去改變密碼
    • 密碼安全
      • 使用雜湊(hash)
      • 希望有一個不可逆轉的函數,這樣就算存起來的密碼被看到也無法去解碼而知道真正的密碼
      • 但若是取得整份密碼檔,還是可能被解碼還原
  • 單次密碼(One-time passwords)

    • 系統使用一個配對密碼(paired password)的集合,系統隨機選擇並顯示密碼對的一部分,使用者接受盤問(challenged)且須回應(respond)出正確答案
    • 可以用不同的方式製作(如:USB裝置、信用卡)
  • 生物識別技術

    • 指紋讀取

安全性防禦的製作(Implementing Security Defenses)

  • 大多數專業安全性贊成縱深防禦(defense in depth),敘述多層的防禦比較少層為佳

  • 安全性策略(security policy)

    • 包含要保密什麼的敘述
    • 有了策略,才知道什麼是需要的,什麼是不被允許的
    • 週期檢討和更新
  • 弱點評估

    • 涵蓋很廣,從社交工程到危險評估(risk assessment)到阜掃描
    • 大部分弱點評估的核心動作是侵入測試(penetration)
    • 隱藏式保全(security through obscurity):主張工具餔應該寫來測試安全性,這樣安全性漏洞將會很難被發現
  • 侵入偵測(intrusion detection)

    • 包括
      • 即時/事實發生後
      • 侵入的型態
      • 反應
        1. 簡單:停止侵入活動的行程
        2. 複雜:虛擬攻防系統(honeypot),暴露給侵入者假資源
    • 侵入偵測系統(IDS,intrusion-detection system):偵測侵入,發出警告
      • 識別標誌的偵測(signature-based detection):
        1. 檢查特定行為樣式
        2. 非預期的新公及無法偵測
      • 異常偵測(anomaly detection):檢查異常行為
        1. 侵入活動可能被包含在正常的標準中
        2. 避免假警報與遺漏的侵入數目過多
    • 侵入預防系統(IDP,intrusion-prevention system):除非偵測到侵入,否則流量通過
  • 病毒保護

    • 當防毒軟體發現一個已知樣式,進行程式消毒(disinfection)
    • 有些病毒當感染時,自我修改以避免與防毒程式的樣式相符
    • 行程於sandbox中執行,防毒軟體分析行程的表現
  • 記錄及記帳

    • 系統呼叫可以被記錄以作為對程式行為的分析
    • 記帳用來發現程式效能改變

保護系統和網路的防火牆(Firewalling to Protect Systems and Networks)

  • 防火牆(firewall)用來分隔信任或不可信任的系統

  • 從網際網路到非軍事領域(DMZ,demilitarized zone)以及從公司到網際網路的連結式允許的,但網際網路或DMZ到公司則是不允許的

  • 防火牆不能防止穿透(tunnel)的攻擊

  • 防火牆可能被欺騙(spoofing)

電腦安全等級(Computer Security Classifications)

  • 4個等級:A、B、C、D
    • D:最低標準
    • C:透過審核,提供保護
      • C1:識別具有相同保護級別的合作用戶
      • C2:允許用戶級別的存取控制
    • B:C的所有屬性,但是每個對象可能具有唯一的敏感度標籤
      • B1、B2、B3
    • A:使用正式的設計和驗證技術來確保安全性