如何计算 cap 文件中有效 WPA 握手的次数

How to count the number of valid WPA handshakes in a cap file

我想知道一个 cap 文件中有多少有效的 WPA 握手。

我确实尝试过使用这种方法:

  tshark -r file.cap -R "(wlan.fc.type_subtype == 0x08 || wlan.fc.type_subtype == 0x05 || eapol)" -2 


   1   0.064507 D-LinkIn_89:9f:44 → Broadcast    802.11 325 Beacon frame, SN=2485, FN=0, Flags=........, BI=100, SSID=AAAAA
   2  15.639995 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 155 Key (Message 2 of 4)
   3  15.643065 D-LinkIn_89:9f:44 → LgElectr_94:af:ba EAPOL 213 Key (Message 3 of 4)
   4  27.695798 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 155 Key (Message 2 of 4)
   5  27.703480 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 133 Key (Message 4 of 4)
   6  54.926712 D-LinkIn_89:9f:44 → LgElectr_94:af:ba EAPOL 133 Key (Message 1 of 4)
   7  54.975420 D-LinkIn_89:9f:44 → LgElectr_94:af:ba EAPOL 213 Key (Message 3 of 4)
   8  81.340985 D-LinkIn_89:9f:44 → LgElectr_94:af:ba EAPOL 133 Key (Message 1 of 4)
   9  81.351228 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 155 Key (Message 2 of 4)
  10  81.353779 D-LinkIn_89:9f:44 → LgElectr_94:af:ba EAPOL 213 Key (Message 3 of 4)
  11  81.358911 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 133 Key (Message 4 of 4)
  12 119.080377 LgElectr_94:af:ba → D-LinkIn_89:9f:44 EAPOL 133 Key (Message 4 of 4)

我想要以下输出:

count.sh file.cap

3(3 次有效握手)。

我不知道的是识别一组消息何时是有效的握手来破解它(比如 aircrack-ng)。

求助。

好吧,经过更多的挖掘,我意识到答案就在我眼前。

我找到了 LazyScript (github repo) that has a feature to check/validate WPA/WPA2 handshakes. Diving into the source code I figured it out that it uses Pyrit and Cowpatty

因此,总而言之,有一种非常 easy/simple 的方法来计算 cap 文件中的握手次数(同时检查质量):

pyrit -r fileWithHandShakes.cap analyze

它会给出这个输出:

Pyrit 0.4.0 (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

Parsing file '/folder/fileWithHandShakes.cap' (1/1)...
Parsed 112 packets (112 802.11-packets), got 1 AP(s)

#1: AccessPoint fd:94:e3:43:bc:b6 ('MyWifi'):
  #1: Station 30:fd:38:c1:2b:bb, 3 handshake(s):
    #1: HMAC_SHA1_AES, good, spread 1
    #2: HMAC_SHA1_AES, bad, spread 17
    #3: HMAC_SHA1_AES, bad, spread 22
  #2: Station 44:00:10:06:bc:bc, 2 handshake(s):
    #1: HMAC_SHA1_AES, good, spread 1
    #2: HMAC_SHA1_AES, bad, spread 3

这是计算握手次数以及检查握手质量的方法。