I am trying to create a 4-way handshake cracking script in python(Like coWPatty or Aircrack) for the past week or so.
I have a working PBKDF2 function for computing the PMK(Pairwise Master Key) and a working PRF512 function for computing the PTK(Pairwise Transient Key). I now need to calculate the MIC and compare it with the one that I have captured in WireShark, but all of the functions that I have found online for computing MIC's only work on TKIP while I need CCMP(My router uses WPA2 with CCMP). I later found out that CCMP MIC's are computed using something called CCM(Counter Mode with CBC-MAC). I found a module called PyCrypto that has has CCM but I do not know how to use it. This is what I have so far:
def get_mic(key, iv, data):
k = AES.new(key, AES.MODE_CBC, iv)
return k.encrypt(data)
From what I know the key has to be the first 16 bytes of the PTK and data has to be the captured packet data with the MIC parameter replaced with 16*"\x00". I also don't know what the iv has to be.
Thanks in advance!