WPA2 ¡°KRACK¡± Îó²î¼ò½éÓëÖØÏÖ
Ðû²¼Ê±¼ä 2018-01-241¡¢¸ÅÊö
2017Äê10Ô£¬±ÈÀûʱÇå¾²Ñо¿Ô±Mathy VanhoefÅû¶ÁËÎÞÏßÍøÂçÐÒéWPA2±£´æ¸ßΣÎó²î£¬Îó²îÔÊÐí¹¥»÷Õß¼àÌýAPºÍ½ÓÈëµãSTAÖ®¼ä´«ÊäµÄWi-FiÊý¾ÝÁ÷Á¿¡£×÷ÕßÐû²¼ÁËÎó²îÑéÖ¤ÑÝʾÊÓƵ[1][2]¡£ÓÉÓÚÎó²î±£´æÓÚWiFiÐÒé²ã£¬ÀíÂÛÉÏËùÓÐÖ§³ÖWPA2µÄ¿Í»§¶Ë£¨×ÀÃæ²Ù×÷ϵͳ¡¢Òƶ¯OS¡¢Â·ÓÉÆ÷¡¢ÎïÁªÍø×°±¸µÈ£©¶¼½«Êܵ½¡°KRACK¡±¹¥»÷µÄÓ°Ï죨Æä͸¹ýWiFi´«ÊäµÄÊý¾Ý±£´æ±»¸Ä¶¯¡¢Ðá̽µÄΣº¦£¬ÖîÈç±»¹¥»÷ÕßµÄÖ§¸¶¡¢¹¤ÒµÕ˺š¢Óû§Ãû¡¢ÃÜÂë¡¢Óʼþ¡¢ÕÕƬµÈÃô¸ÐÐÅÏ¢¿É±»½Ø»ñ£¬Î£º¦´óÓ°Ïì¹æÄ£¹ã£©¡£
ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøADLabͨ¹ý¶ÔÈ«ÁãÃÜÔ¿Îó²îµÄÆÊÎöÀÖ³ÉÖØÏÖ¡°KRACK¡±¹¥»÷¡£
2¡¢ÐÒé¼ò½é
802.11iÊÇIEEEÊÂÇé×éΪÎÞÏßÍøÂç802.11ÐÒé×é½ç˵µÄÇå¾²±ê×¼¡£WPAʵÏÖÁËIEEE 802.11i±ê×¼µÄ´ó²¿·Ö£¬ÊÇÔÚ802.11iÍêÕû֮ǰÌæ»»WEPµÄ¹ý¶É¼Æ»®£¬ºó±»WPA2È¡´ú[3]¡£WPAºÍWPA2¶¼ÊÇ»ùÓÚ802.11i£¬Çø±ðÔÚÓÚWPA2ÒªÇóÖ§³Ö¸üÇå¾²µÄCCMP¡£WPAºÍWPA2¾ùʹÓÃ802.11iÖнç˵µÄËÄ´ÎÎÕÊÖ¡£
ÏÂͼÊÇ¿Í»§¶Ë£¨Station, STA£©ÅþÅþÁÚÈëµã£¨Access Point, AP£©µÄÐÂÎŽ»»¥Àú³Ì¡£

STAºÍAPÔÚËÄ´ÎÎÕÊÖÖÐÐÉ̻ỰÃÜÔ¿PTK£¨Pairwise Transient Key£©£¬PTKÊÇÓÉPMKºÍPKEÅÌËãÌìÉú£¬¶øPMKÓÉANonce¡¢SNonceºÍË«·½MACµØµãµÈÅÌËãÌìÉú¡£PTK·ÖΪKCK£¬KEKºÍTKÈý²¿·Ö£¬ÆäÖУ¬KCKÓÃÓÚMICУÑ飬KEKÓÃÓÚ¼ÓÃÜGTK£¬TKΪÊý¾Ý¼ÓÃÜÃÜÔ¿¡£ËÄ´ÎÎÕÊÖÍê³Éºó£¬´«ÊäÊý¾ÝʹÓÃTK¾ÙÐмÓÃÜ¡£

3¡¢Îó²îÔÀí
wpa_supplicantÊÇlinuxϵͳÏÂWiFi¿Í»§¶Ë£¬ÓÃÓÚÅþÁ¬ÎÞÏßÍøÂ磬Android WiFiϵͳÒýÈëÁËwpa_supplicant£¬ËüµÄÕû¸öWiFiϵͳÊÇÒÔwpa_supplicantΪ½¹µãÀ´½ç˵ÉϲãÓû§½Ó¿ÚºÍϲãÇý¶¯½Ó¿Ú¡£
ÏÂͼΪwpa_supplicant°æ±¾Ðû²¼Ê±¼äÏß¡£Android 6.0 WiFiϵͳÊÇ»ùÓÚv2.5£¬Android 6.0+ WiFiϵͳÊÇ»ùÓÚv2.6¡£

v2.4°æ±¾ÒýÈëÁËÒ»¸öÈ«ÁãÃÜÔ¿Îó²î¡£Õâ¸öÎó²îÊÇÓÉ802.11±ê×¼ÖеÄÒ»¾ä»°ÒýÆðµÄ£¬¸Ã±ê×¼¼ä½Ó½¨ÒéÔÚ×°ÖÃÁËTKÖ®ºó´ÓÄÚ´æɨ³ýTK£»2016Äê10ÔÂÐû²¼µÄV2.6¶ÔÕâ¸öÎó²î¾ÙÐÐÁËÒ»´ÎÐÞ¸´£¬ÓÉÓÚ˼Á¿²»ÖÜÈ«£¬´úÂëÈÔÈ»±£´æÎó²î£»ÔÚ2017Äê10ÔÂÐû²¼µÄ²¹¶¡ÖУ¬×îÖÕÐÞ¸´ÁËÕâ¸öÎó²î¡£ÏÂÃæÍŽá´úÂë¶ÔÎó²î¾ÙÐÐÏêϸÆÊÎö¡£
3.1. V2.4(2.5)
wpa_supplicant 2.4(2.5) ËÄ´ÎÎÕÊÖÖеÄ״̬תÒÆÈçÏÂͼËùʾ£º
£¨1£©µ±ÅþÁ¬µ½ÎÞÏßÍøÂç¾ÙÐÐËÄ´ÎÎÕÊÖµÄʱ¼ä£¬Ê×ÏȽøÈëPTK_INIT״̬¡£
£¨2£©µ±ÎüÊÕµ½Msg1ʱ£¬½øÈëPTK-START½×¶Î¡£wpa_supplicant»áËæ»úÌìÉúÒ»¸öSNonce£¬ÅÌËãÒ»¸öÔÝʱPTK£¨TPTK£©£¬²¢ÇÒÔÚMsg2Öн«SNonce·¢Ë͸øAP¡£
£¨3£©µ±ÎüÊÕµ½Msg3ʱ£¬ÈôÊÇMICºÍreplay counterУÑéÀֳɣ¬½øÈëPTK-NEGOTIATING״̬¡£È»ºó½«TPTK¸³Öµ¸øPTK£¬²¢·¢ËÍMsg4¡£
£¨4£©½Ó׎øÈëPTK-DONE½×¶Î£¬×°ÖÃPTKºÍGTK£¬²¢ÇÒ·¿ª802.1xµÄ¶Ë¿Ú£¬Ê¹wpa_supplicantºÍAPÕý³£ÎüÊպͷ¢ËÍÊý¾Ý°ü¡£
ÓÉÓÚÎÞÏßÍøÂç±£´æ×ÌÈÅ£¬¿ÉÄÜ»áÔì³ÉÊý¾ÝÖ¡µÄɥʧ£¬Òò´ËÔÚ802.11i»®¶¨ÈôÊÇAPûÓÐÊÕµ½Msg2ºÍMsg4£¬»áÏìÓ¦µÄÖØ´«Msg1ºÍMsg3¡£´ÓͼÖпÉÒÔ¿´³ö£¬µ±Íê³ÉPTK×°Öúó£¬ÈôÊÇÊÕµ½ÖØ´«µÄMsg3£¬»áÖØÐÂ×°ÖÃPTK¡£

µ±wpa_supplicantÊÕµ½Msg3ºó£¬»áŲÓÃwpa_supplicant_install_ptkº¯Êý×°ÖÃPTK£¬ÆäÖÐwpa_sm_set_keyº¯ÊýÈÏÕ潫ÃÜÔ¿PTK.TK×°Öõ½Çý¶¯¡£ÔÚsupplicant v2.4(v2.5)ÖУ¬ÔÚŲÓÃwpa_sm_set_keyº¯ÊýÍê³ÉPTKµÄ×°Öúó£¬Ö´ÐÐos_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN)£¬¶ÔPTK.TK¾ÙÐÐÇåÁã²Ù×÷¡£
ÈôÊǹ¥»÷ÕßЮÖÆMsg3»òMsg4£¬Ôì³ÉMsg3µÄÖØ´«£¬Æ¾Ö¤×´Ì¬×ªÒÆͼ£¬STA»áÖØÐÂ×°ÖÃPTK£¬¶øPTK.TK֮ǰÒѾ±»ÇåÁ㣬µ¼ÖÂSTA×°ÖÃÈ«Áã¼ÓÃÜÃÜÔ¿¡£

3.2. V2.6
ÏÂÃæÍŽáV2.5ºÍV2.6µÄÔ´´úÂë¾ÙÐÐÆÊÎö¡£
£¨1£©V2.6ÔÚwpa_sm½á¹¹ÌåÖÐÌí¼ÓÁËÒ»¸ö±ê¼Çλtk_to_set¡£

£¨2£©V2.6ÐÞ¸ÄÁËwpa_supplicant_install_ptkº¯Êý¡£ÔÚ×°ÖÃÍêPTKºó£¬½«tk_to_set¸³ÖµÎª0£¬µ±ÔٴνøÈë¸Ãº¯Êýʱ£¬ÈôÊÇtk_to_set==0£¬Ö±½Óreturn£¬²»ÔÙÖØ×°PTK¡£

£¨3£©V2.6ÐÞ¸Äwpa_supplicant_process_1_of_4º¯Êý¡£µ±Ã¿´ÎÊÕµ½Msg1ʱ£¬ÅÌËãtptk£¬²¢½«tk_to_setÖØÖÃΪ1¡£

Õë¶ÔV2.6£¬¹¥»÷Õßͨ¹ýÔÚÖØ´«µÄMsg3֮ǰ²åÈëÒ»¸öαÔìµÄMsg1£¬ÈÔÈ»¿ÉÒÔʵÏÖÈ«ÁãÃÜÔ¿µÄ×°Öá£ËäÈ»STAÊ×´Î×°ÖÃPTKºó¶Ôtk_to_set¾ÙÐÐÇåÁ㣬¿ÉÊǽô½Ó´¦Öóͷ£Î±ÔìµÄ Msg1ʱ£¬½«tk_to_setÖØÖÃΪ1£¬Òò´ËÔÚ×îºó´¦Öóͷ£ÖØ´«Msg3ʱ£¬ÀÖ³ÉÈƹýwpa_supplicant_install_ptkº¯ÊýµÄtk_to_setÌõ¼þÅжϴúÂë¡£
ÔÚ2017Äê10ÔÂÐû²¼µÄ²¹¶¡ÖУ¬É¾³ýÁËwpa_supplicant_process_1_of_4º¯ÊýÖеÄsm->tk_to_set = 1;Óï¾ä£¬ÐÞ¸´ÁËÈ«ÁãÃÜÔ¿Îó²î¡£
4¡¢Îó²îÖØÏÖ
ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøADLab ¡°KRACK¡±ÖØÏÖÊÓƵµØµãΪ£ºhttps://v.qq.com/x/page/m0538vcwqbb.html ¡£
ÊÓƵÖзºÆðµÄ°ì·¨¼°ÌáÐÑ×ÖÄ»£º
1.±¾ÊµÑéʹÓÃNexus6ÊÖ»ú×÷Ϊ±»¹¥»÷×°±¸¡£
2.Ê×ÏÈ£¬NexusÅþÁ¬µ½ÕæʵAP(SSID=wap£¬¼ÓÃÜ·½·¨ÊÇWPA2£¬ÐŵÀ10£¬ÆµÂÊ2457)¡£
3.½Ó×Å£¬ÔËÐÐHostapd½¨Éè¿Ë¡AP(SSID=wap£¬¼ÓÃÜ·½·¨ÊÇWPA2£¬ÐŵÀ3£¬ÆµÂÊ2422)¡£
4.ͬʱ£¬Æô¶¯wireshark¼àÌý¿Ë¡APÍø¿¨£¬²¶»ñ¿Í»§¶ËÊý¾Ý¡£
5.ÔËÐй¥»÷¾ç±¾£¬Ö¸¶¨APµÄSSIDºÍNexusµÄMacµØµã¡£
6.ÔËÐÐssltrip,¾ÙÐÐHttps½µ¼¶¡£
a.wiresharkÏÔʾÁ˽¨ÉèÅþÁ¬µÄÊý¾Ý°ü¡£
b.¹¥»÷Àֳɣ¬NexusÅþÁ¬µ½¿Ë¡wap£¬ÆµÂÊ2422¡£
c.»á¼ûuk.match.com ÏÔʾĿ½ñÅþÁ¬ÎªhttpÅþÁ¬£¬ÊäÈë²âÊÔÓû§ÃûºÍÃÜÂë¡£
d.wireshark¿ÉÒÔÀֳɲ¶»ñÓû§ÃûºÍÃÜÂë¡£
e.¹Ø±ÕHostapd£¨ÆµÂÊ2422£©¡£
f.ÖØÐÂÅþÁ¬µ½Õæʵwap£¨ÆµÂÊ2457£©£¬Ôٴλá¼ûuk.match.com ÏÔʾÅþÁ¬ÎªhttpsÅþÁ¬¡£
ϱíÖÐÁгöÁËÖØÏÖÊÓƵÖÐʹÓõÄ×°±¸£º

5¡¢Îó²î±àºÅ¼°ÐÞ¸´ÇéÐÎ
¡°KRACK¡±Éæ¼°µÄÏà¹ØÎó²î±àºÅ£º
CVE-2017-13077: ÔÚËÄ´ÎÎÕÊÖÖÐÖØ×°³É¶Ô¼ÓÃÜÃÜÔ¿£¨PTK-TK£©
CVE-2017-13078: ÔÚËÄ´ÎÎÕÊÖÖÐÖØ×°×éÃÜÔ¿£¨GTK£©
CVE-2017-13079: ÔÚËÄ´ÎÎÕÊÖÖÐÖØ×°ÍêÕû×éÃÜÔ¿£¨IGTK£©
CVE-2017-13080: ÔÚ×éÃÜÔ¿ÎÕÊÖÖÐÖØ×°×éÃÜÔ¿£¨GTK£©
CVE-2017-13081: ÔÚ×éÃÜÔ¿ÎÕÊÖÖÐÖØ×°ÍêÕû×éÃÜÔ¿£¨IGTK£©
CVE-2017-13082: ½ÓÊÜÖØд«ÊäµÄ¿ìËÙBSSÇл»£¨FT£©ÖØйØÁªÇëÇó£¬ÖØ×°³É¶Ô¼ÓÃÜÃÜÔ¿£¨PTK-TK£©
CVE-2017-13084: ÔÚPeerKeyÎÕÊÖÖÐÖØ×°STKÃÜÔ¿
CVE-2017-13086: ÔÚTDLS£¨Tunneled Direct-Link Setup£©ÎÕÊÖÖÐÖØ×°TDLS PeerKey£¨TPK£©
CVE-2017-13087: ´¦Öóͷ£ÎÞÏßÍøÂçÖÎÀí£¨WNM£©ÐÝÃßģʽÏìӦ֡ʱÖØ×°×éÃÜÔ¿£¨GTK£©
CVE-2017-13088: ´¦Öóͷ£ÎÞÏßÍøÂçÖÎÀí£¨WNM£©ÐÝÃßÏìӦ֡ʱÖØ×°ÍêÕû×éÃÜÔ¿£¨IGTK£©
ÐÞ¸´ÇéÐΣº
2017Äê10ÔÂ2ÈÕ£¬LinuxµÄhostapdºÍwpa_supplicant ²¹¶¡ÒÑÐû²¼£¬Ïê¼û https://w1.fi/security/2017-1/¡£
2017Äê10ÔÂ10ÈÕ£¬Î¢ÈíÔÚWindows 10 ²Ù×÷ϵͳÖÐÐû²¼²¹¶¡ KB4041676¡£
Æ»¹ûÔÚ×îÐ嵀 beta °æ±¾iOS¡¢macOS¡¢ tvOSºÍ watchOSÖÐÐÞ¸´ÁËÎÞÏßÍøÂçÇå¾²Îó²î¡£
6¡¢²Î¿¼Á´½Ó
[1]https://www.krackattacks.com/
[2]https://papers.mathyvanhoef.com/ccs2017.pdf
[3]https://zh.wikipedia.org/wiki/WPA