Esempio n. 1
0
 /// <summary>
 /// Adds a Pairwise Master Key (PMK) to the access point with the specified BSSID.
 /// In WPA2, the PMK is derived from the access point BSSID and password and used to
 /// create other keys used in encryption.
 /// </summary>
 /// <param name="bssid">The BSSID of the access point.</param>
 /// <param name="ssid">The SSID of the access point.</param>
 /// <param name="password">The password of the access point.</param>
 public void AddPassword(PhysicalAddress bssid, string ssid, string password)
 {
     byte[] pmk =
         WPA2CryptographyTools.GeneratePairwiseMasterKey(password, ssid);
     if (AccessPoints.ContainsKey(bssid) == false)
     {
         AccessPoints[bssid] = new AccessPoint(bssid);
     }
     AccessPoints[bssid].PairwiseMasterKey = pmk;
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the destination and source of a PacketDotNet IEEE 802.11 DataFrame.
        /// The destination and source are determined by the return value. <br />
        /// If no access point or station with MAC addresses matching those in the dataFrame
        /// are found in the existing network graph, then the corresponding access point and
        /// station are added to the graph.
        /// </summary>
        /// <param name="dataFrame">The frame whose destination and source to get.</param>
        /// <param name="accessPoint">The access point to or from which the message is sent.</param>
        /// <param name="station">The station to or from which the message is sent.</param>
        /// <returns>True, if the access point is the destination. Otherwise, false.</returns>
        public bool GetDestinationAndSource(
            DataFrame dataFrame,
            out AccessPoint accessPoint,
            out Station station)
        {
            PhysicalAddress bssid         = dataFrame.BssId;
            PhysicalAddress destAddress   = dataFrame.DestinationAddress;
            PhysicalAddress sourceAddress = dataFrame.SourceAddress;

            if (AccessPoints.TryGetValue(bssid, out accessPoint) == false)
            {
                accessPoint         = new AccessPoint(bssid);
                AccessPoints[bssid] = accessPoint;
            }

            if (Stations.TryGetValue(destAddress, out station))
            {
                return(false);
            }
            else if (Stations.TryGetValue(sourceAddress, out station))
            {
                return(true);
            }
            else
            {
                station = new Station();
                if ((dataFrame.FrameControl.ToDS == true) &&
                    (dataFrame.FrameControl.FromDS == false))
                {
                    Stations[sourceAddress] = station;
                    return(true);
                }
                else
                {
                    Stations[destAddress] = station;
                    return(false);
                }
            }
        }