static void Main(string[] args) { using WiFiMonitor wiFiMonitor = new WiFiMonitor(constructNetworkGraph: true); wiFiMonitor.PacketArrived += (object sender, PacketArrivedEventArgs e) => { DataFrame dataFrame = e.ArrivedPacket.Extract <DataFrame>(); if (dataFrame?.PayloadData == null) { return; } wiFiMonitor.NetworkGraph.GetDestinationAndSource( dataFrame, out AccessPoint accessPoint, out Station station); if (station.PairwiseTransientKey == null) { return; } Console.WriteLine("Attempting to decrypt"); byte[] decryptedBytes = WPA2CryptographyTools.CCMPTryDecryptDataFrame( dataFrame, station.PairwiseTransientKey[32..48]); string decodedText = Encoding.UTF8.GetString(decryptedBytes); Console.WriteLine(decodedText); };
public void CCMPTryDecryptDataFrame_WithValidInput_ShouldDecryptCorrectly(int i) { // Arrange Packet encryptedPacket = Packet.ParsePacket(LinkLayers.Ieee80211, _ciphertextMPDUs[i]); DataFrame encryptedDataFrame = encryptedPacket.Extract <DataFrame>(); // Act byte[] actualDecryptedBody = WPA2CryptographyTools.CCMPTryDecryptDataFrame(encryptedDataFrame, _tks[i]); bool decryptedCorrectly = HelperMethods.CompareBuffers( _plaintextDatas[i], actualDecryptedBody, _plaintextDatas[i].Length) == 0; // Assert Assert.IsTrue(decryptedCorrectly); }