Veternal1226
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # KRACK ###### tags: `lesson` --- # KRACK - WPA2破解 助教: - 進行這個攻擊有什麼限制? 中間人裝置需在熱點AP與受害裝置訊號接收範圍 需要知道受害者裝置的MAC addr. - 假設攻擊成功,造成的影響與危害 - 在書面補上,無法成功的推測詳細說明 - 利用此技術可以做到什麼事情?跟其他使用行為有什麼差異 - 寫出過程中的新發現 ## 背景 ### Wi-Fi加密演進 Wi-Fi的加密協議標準演進如下圖所示,WEP使用RC4串流加密技術,但因為IV(Initial Vector)長度過短,因此有被暴力破解的可能性;WPA實作了大部分的802.11標準,但其主要使用的臨時密鑰完整性協議(TKIP)有可能被破解;WPA2為目前主流的網路存取點(Access Point)使用的加密協議標準,加密方式從RC4 & TKIP換成更安全的AES進階加密標準,在WPA2中,金鑰的交換使用了四向交握協議,此協議也是我們這次主要討論與破解的部分;WPA3使用了更安全的SAE實體同步驗證,但其尚未發展成熟所以暫不討論。 ![](https://i.imgur.com/R3FH8od.png) 表一、 Wi-Fi加密演進 目前主流的WPA/WPA2使用的加密協議可依加密類型進行分類: - WPA/WPA2:需要架設Radius伺服器,透過Radius伺服器進行各個使用者的身分認證,因此每個使用者所使用的金鑰會不同,且均由Radius伺服器管理,常用於公司等安全需求較高的環境。 - WPA/WPA2-PSK:使用預共享金鑰模式(Pre-Shared Key),AP端與使用者使用同一組雙方都知道的PSK金鑰,因為不用額外架設Radius伺服器,所以成本較低,較常用於家庭一般使用等僅須一般等級安全性的環境。 依據加密算法可分為: - Temporal Key Integrity Protocol(TKIP):臨時密鑰完整性協議,常用於WPA之加密標準,為較舊的加密標準,有被攻擊的可能性因此不建議使用。 - Advanced Encryption Standard(AES):高級加密標準,WPA與WPA2均可使用,安全性比TKIP高,較建議使用。 ### Wi-Fi連線 WIFI連線的粗略架構如下圖所示,依照連線使用定位可分為使用者(Client)、存取點(Access Point)與網路 使用者透過加密協議(如WPA2)與AP連接,AP再與網路透過HTTP/HTTPS等協議連接以提供使用者網路存取服務,這篇報告將會著重在討論使用者與AP連接的加密協議,並沒有討論到AP與網路間使用的加密協議。 對於使用者與AP間使用的加密協議而言,使用者的角色為加密協議的請求者(Supplicant),AP為加密協議的認證者(Authenticator)。 ![](https://i.imgur.com/QiujIzv.png) 圖二、 WIFI連線的粗略架構 WPA2的完整流程圖如下圖所示,第一部分(上方)為連線建立階段,第二部分(中間)為PTK四向交握階段,也是漏洞主要發生的位置,因此重點將放在此階段,第三部分(下方)為GTK交換階段。 ![](https://i.imgur.com/OBcqqIg.png) 圖三、 WPA2的完整連線流程 在討論四向交握之前須了解以下概念: 1. 四向交握使用的金鑰 臨時金鑰有以下兩種:成對瞬態金鑰(Pairwise Transient Key,PTK)與群組暫時金鑰(Group Temporal Key,GTK),各裝置間使用不同的PTK與AP成對達成協議,而連到同個AP下的裝置的GTK均為同一組。 PTK是由ANonce、SNonce與共享金鑰組合產生(ANonce與SNonce後面會提到),而GTK通常是由AP端產生。 ![](https://i.imgur.com/7CgckRY.png) 圖四、 PTK與GTK差異圖解 2. Nonce 在資訊安全中,Nonce是一個在加密通訊只能使用一次的數字。在認證協定中,它往往是一個隨機或偽隨機數。在四向交握中使用到兩種Nonce:第一種的ANonce與SNonce是由AP/client的MAC address與先前提到的共享金鑰(如WPA2-PSK中的PSK)組成;第二種是用於加密封包用的nonce,此nonce指的是封包號碼(packet number)。 四向交握可分為以下四步: 第一步: AP將共享金鑰與自己的MAC address結合產生ANonce,將ANonce傳給client。 (備註:圖片中的r是為了防止重放攻擊(replay attack)的數,此處不討論) 第一步之後第二步之前: client在收到ANonce後,因為可以算出自己的SNonce,共享金鑰也已知,因此能成功產生PTK並暫存在記憶體。 第二步: client將共享金鑰與自己的MAC address結合產生SNonce,將SNonce傳給client。 第二步之後: AP在收到ANonce後,成功產生PTK並暫存在記憶體。 ![](https://i.imgur.com/pzSx9zl.png) 圖五、 四向交握第一步與第二步 第三步: AP向client傳送確認訊息,確認要安裝此組PTK,並同時將GTK也一併傳送。 第四步: client收到確認訊息後回復AP端OK。 第四步之後: client會安裝記在記憶體的PTK與剛收到的GTK,並將代表封包號碼的Nonce設為0,AP也會把此PTK與此client連結與安裝。 ![](https://i.imgur.com/CnAywoF.png) 圖六、 四向交握第三步與第四步 ![](https://i.imgur.com/yYMZRv1.png) 圖七、 四向交握第四步結束後重製Nonce為0 安裝完PTK後,PTK會與各封包號碼(nonce)結合產生keystream,之後兩者間的通訊會利用keystream做加密,因為每個封包的號碼(nonce)都不同,因此較難解密。 ![](https://i.imgur.com/vPBXtnG.png) 圖八、 PTK加密方式圖解 就安全性來說,四向交握有被證明是安全的,透過PTK與封包號碼的加密金鑰方式也是安全的,但是當兩者結合後,在實作方面就可能產生漏洞,因為四向交握實作時無法保證金鑰只被安裝一次,加密金鑰在證明安全性時並沒有考慮到使用的封包號碼可能重複,兩者合起來就會造成漏洞,四向交握也沒有確認記錄PTK的記憶體有沒有受過更改,KRACK就是利用這些漏洞進行解密。 ## KRACK KRACK(Key Reinstallation AttaCK),由Mathy Vanhoef在Black Hat Europe 2017上公開漏洞,主要利用 WPA2的四向交握(4-way handshake),攻擊者可在第三次的交握中,欺騙存取點向裝置重複傳送加密金鑰,但在裝置重複安裝相同的金鑰時,Nonce 金鑰就會被重設。由於 Nonce 金鑰可被重用,攻擊者便可破解加密。KRACK的特色在於攻擊方的中間者**不需要知道WIFI密碼也能破解**,因此危害度很高,但**攻擊方需在AP的訊號範圍內**並能同時接收到受害者與AP的訊號,因受到此物理限制,所以無法進行大量自動攻擊。 我們選擇KRACK攻擊的目標在於使用中間人攻擊擷取相同AP下其他裝置網路封包,並重現KRACK攻擊,破解WPA2加密機制,解密其他裝置傳送的封包內容以獲取帳號密碼等敏感性資料。 KRACK攻擊有許多種實作方式,這邊僅列出金鑰重新安裝與全零PTK兩種攻擊方式。 ### KRACK-金鑰重新安裝 第一種KRACK的實作方式為金鑰重新安裝,首先在client與AP間增加能同時接收到兩者訊號的中間人(Man In The Middle),此中間人會捕捉到AP使用到的頻道並將其屏蔽,並產生一個使用不同頻道的假AP讓client連結,對AP而言連線進來的是正常用戶,對client來說也與連到正常AP的行為無差異,因此雙方皆難以察覺。 在四向交握的過程中,中間人先正常協助轉傳前兩步的連線訊息,但在交換第三與第四訊息時,中間人會將從client端傳到AP端的第四訊息阻擋,阻擋造成的結果為client認為已經成功安裝PTK,並將Nonce清為0,但AP端因為沒收到第四訊息,因此認為此PTK尚未安裝成功。 ![](https://i.imgur.com/HWYGyUK.png) 圖九、 阻擋第四訊息 因為AP端未收到第四訊息,在超時後便會重新發送第三訊息,client端在收到第三訊息後會再送一次第四訊息,但因為對client來說PTK是已經安裝完成的狀態,因此會將此訊息四加密後送出,並且此次使用的Nonce為1,送出此加密後的訊息四後,client會重新安裝PTK並再次將Nonce清為0,中間人不阻擋此訊息四,因此client與AP成功利用此PTK建立加密連線。 ![](https://i.imgur.com/zbpis7i.png) 圖十、 重新安裝PTK並重製Nonce為0 在加密連線成功後,從client端發出的第一個加密訊息使用的Nonce為1,與之前訊息四使用的Nonce相同,因此只要能解出加密訊息四的keystream,就能解密出可能含有敏感資料的此訊息。 ![](https://i.imgur.com/GpPAAPk.png) 圖十一、 兩者使用相同Nonce (Nonce皆為1) 在中間人接收到的訊息中,有包含加密前的訊息四與加密後的訊息四,因為訊息四的內容僅為回覆OK,內容相對簡單,兩者絕大多數的欄位是相同內容,因此能成功解出Nonce為1的keystream,再將此keystream用來解密第一個加密的訊息即可成功解密,成功實現金鑰重新安裝攻擊。 ![](https://i.imgur.com/tKl8hdl.png) 圖十二、 解密流程圖解 ### KRACK-全零PTK 此攻擊是針對使用Android與Linux架構的裝置,利用Android與Linux在實作WPA2時未考慮到的漏洞進行攻擊,也是我們這次實作時使用的攻擊方式,基本上攻擊流程與金鑰重新安裝攻擊相似,一樣是正常轉傳第一第二訊息,收到第三訊息後阻擋第四訊息。在client端收到第一次訊息三時,系統會使用記憶體中記錄的PTK進行安裝,此次安裝的PTK是正常的PTK,在安裝完後系統會將記錄PTK用的此段記憶體清空為全0。 ![](https://i.imgur.com/CqSkRzF.png) 圖十三、 第一次安裝PTK 因為AP端未收到第四訊息,在超時後便會重新發送第三訊息,client端在收到第三訊息後會再送一次第四訊息,並再次安裝PTK,但因為上次安裝完後存放PTK用的記憶體已被清空,因此此次安裝的PTK即為有漏洞的全零金鑰,根據前述圖八所示,加密用的keystream是由PTK與封包號碼(Nonce)組成,因為此處使用的PTK為已知的全0,封包號碼也直接寫在封包欄位中未進行加密,將兩者結合可獲得加密使用的keystream,因此可利用此keystream解密出封包內容。 ![](https://i.imgur.com/X14m6pT.png) 圖十四、 重新安裝全零PTK --- ## 實作 --- ## 補充資料 與KRACK相關的CVE漏洞列表如下所示: CVE-2017-13077: Reinstallation of the pairwise encryption key (PTK-TK) in the 4-way handshake. CVE-2017-13078: Reinstallation of the group key (GTK) in the 4-way handshake. CVE-2017-13079: Reinstallation of the integrity group key (IGTK) in the 4-way handshake. CVE-2017-13080: Reinstallation of the group key (GTK) in the group key handshake. CVE-2017-13081: Reinstallation of the integrity group key (IGTK) in the group key handshake. CVE-2017-13082: Accepting a retransmitted Fast BSS Transition (FT)Reassociation Request and reinstalling the pairwise encryption key (PTK-TK) while processing it. CVE-2017-13084: Reinstallation of the STK key in the PeerKey handshake. CVE-2017-13086: reinstallation of the Tunneled Direct-Link Setup (TDLS) PeerKey (TPK) key in the TDLS handshake. CVE-2017-13087: reinstallation of the group key (GTK) when processing a Wireless Network Management (WNM) Sleep Mode Response frame. CVE-2017-13088: reinstallation of the integrity group key (IGTK) when processing a Wireless Network Management (WNM) Sleep Mode Response frame. ## 參考資料 Black Hat Europe 2017: https://www.youtube.com/watch?v=fZ1R9RliM1w KRACK專網: https://www.krackattacks.com/ 實作: https://www.youtube.com/watch?v=Oh4WURZoR98 https://github.com/vanhoefm/krackattacks-scripts https://github.com/vanhoefm/krackattacks-poc-zerokey https://github.com/lucascouto/krackattack-all-zero-tk-key --- # dump --- 官網 https://www.krackattacks.com/ --- Black hat Europe 2017 https://www.youtube.com/watch?v=fZ1R9RliM1w 裝兩次KEY AP-user 傳PTK(ANouce) user-AP 傳PTK(SNouce) 以上已確保PTK隱密 7:25如何加密 理論上不能強制nouce number變成0 會讓連線重連 10:00 中間人 24:43 ALL ZERO --- 實作 https://www.youtube.com/watch?v=Oh4WURZoR98 --- https://www.techbang.com/posts/54497-krack-authors-in-person-13-qa-quick-responses-to-your-questions 4路的握手協議已經在數學上被證明了是夠安全的,為什麼KRACK攻擊會成功? "簡單的回答,就是目前的4路握手協議並沒有辦法確保金鑰只能被安裝一次。它只能確保金鑰維持隱密性,以及握手過程中傳遞的訊息並不會被偽造。 KRACK並沒有破解4路握手協議的安全性。事實上,在過程中傳遞的加密金鑰依然是安全的,以及握手協議過程中,用來確認AP端以及客戶端的身份驗證性也是安全的。KRACK並沒有破解加密金鑰,因此4路握手協議依然是安全的。" --- Kali USB https://www.kali.org/docs/usb/kali-linux-live-usb-install/ 網卡驅動 https://www.kalitut.com/2019/05/how-to-install-rtl8812au.html ~~以下無效 作廢 https://blog.tenyi.com/2019/03/ubuntu-dlink-dwa-182-80211ac-usb.html install bc~~ WPA wiki https://zh.wikipedia.org/wiki/WPA KRACK wiki https://zh.wikipedia.org/wiki/KRACK lucascouto https://github.com/lucascouto/krackattack-all-zero-tk-key vanhoefm https://github.com/vanhoefm/krackattacks-scripts

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully