Exemplo n.º 1
0
 private DataGridViewRow FindRow(AccessPoint ap)
 {
     foreach (DataGridViewRow row in scannerGrid.Rows)
     {
         if (row.Cells["macColumn"].Value.ToString() == ap.MacAddress.ToString())
         {
             return row;
         }
     }
     return null;
 }
Exemplo n.º 2
0
        public bool Eval(AccessPoint ap)
        {
            bool status = true;

            //Age
            if (Age > -1 && OpAge != Op.NotSet) status &= CompInt(ap.Age, OpAge, Age);

            //Alias
            if (!string.IsNullOrEmpty(Alias) && OpAlias != Op.NotSet) status &= CompString(ap.Alias, OpAlias, Alias, true);

            //Channel
            if (Channel > -1 && OpChannel != Op.NotSet) status &= CompInt((int)ap.Channel, OpChannel, Channel);

            //IsTypeN
            if (IsTypeN != Bool.Nil && OpIsTypeN != Op.NotSet) status &= CompBool(ap.IsN, OpIsTypeN, IsTypeN);

            //Is40MHz
            if (Is40MHz != Bool.Nil && OpIs40MHz != Op.NotSet)
            {
                status &= ap.NSettings == null
                         ? OpIs40MHz != Op.Equal
                         : CompBool(ap.NSettings.Is40MHz, OpIs40MHz, Is40MHz);
            }

            //MacAddress
            if (!string.IsNullOrEmpty(MacAddress) && OpMacAddress != Op.NotSet) status &= CompString(ap.MacAddress.ToString(), OpMacAddress, MacAddress, true);

            //MaxRate
            if (MaxRate > -1 && OpMaxRate != Op.NotSet) status &= CompInt((int)ap.MaxRate, OpMaxRate, MaxRate);

            //Security filtering ranking, filter as int
            if (!string.IsNullOrEmpty(Security) && OpSecurity != Op.NotSet && SecurityRanking(Security) != -1)
                status &= CompInt(SecurityRanking(ap.Privacy), OpSecurity, SecurityRanking(Security));

            //Rssi
            if (Rssi > -101 && OpRssi != Op.NotSet)
                status &= CompInt(ap.LastData.Rssi, OpRssi, Rssi);

            //Ssid
            if (!string.IsNullOrEmpty(Ssid) && OpSsid != Op.NotSet) status &= CompString(ap.Ssid, OpSsid, Ssid, true);

            //Network Type
            if (!string.IsNullOrEmpty(NetworkType) && OpNetworkType != Op.NotSet) status &= CompString(ap.NetworkType, OpNetworkType, NetworkType, true);

            //Vendor
            if (!string.IsNullOrEmpty(Vendor) && OpVendor != Op.NotSet) status &= CompString(ap.Vendor, OpVendor, Vendor, true);

            return status;
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            AccessPoint point = obj as AccessPoint;

            return((point != null) && point.MyNetworkDataCollection.Equals(MyNetworkDataCollection));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Writes out a NS1 file for the supplied APs
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="points"></param>
        public static void Write(string filename, AccessPoint[] points)
        {
            List<byte> bData = new List<byte>();

            //NetS - signature
            bData.AddRange(new byte[] { 0x4E, 0x65, 0x74, 0x53 });
            //12 - version 12
            bData.AddRange(new byte[] { 0x0c, 0x00, 0x00, 0x00 });

            //How may APs follow
            bData.AddRange(BitConverter.GetBytes(points.Length));

            //Loop through all APs and write them to the list
            foreach (AccessPoint ap in points)
            {
                //Length of the SSID
                bData.Add((byte)ap.Ssid.Length);

                //The SSID
                bData.AddRange(Encoding.ASCII.GetBytes(ap.Ssid));

                //The MAC address
                bData.AddRange(ap.MacAddress.Bytes);

                //RSSI
                bData.AddRange(BitConverter.GetBytes(ap.LastData.Rssi));

                //Noise - not reported
                bData.AddRange(BitConverter.GetBytes(0).Reverse());

                //SNR - not reported
                bData.AddRange(BitConverter.GetBytes(0).Reverse());

                //802.11 capability flags. This just shows if the AP uses WEP and/or is AdHoc
                if(ap.Security.ToLower() != "open")
                {
                    if(ap.NetworkType != "Infrastructure") bData.AddRange(new byte[] { 0x12, 0x00, 0x00, 0x00 });
                    else bData.AddRange(new byte[] { 0x11, 0x00, 0x00, 0x00 });
                }
                else
                {
                    if (ap.NetworkType != "Infrastructure") bData.AddRange(new byte[] { 0x02, 0x00, 0x00, 0x00 });
                    else bData.AddRange(new byte[] { 0x01, 0x00, 0x00, 0x00 });
                }

                //Beacon interval - not reported, just use 100 msec.
                bData.AddRange(BitConverter.GetBytes((uint)100));

                //First seen time
                bData.AddRange(BitConverter.GetBytes(ap.FirstSeenTimestamp.ToFileTime()));

                //Last seen time
                bData.AddRange(BitConverter.GetBytes(ap.LastSeenTimestamp.ToFileTime()));

                //Latitude
                bData.AddRange(BitConverter.GetBytes(ap.GpsData.Latitude));

                //Longitude
                bData.AddRange(BitConverter.GetBytes(ap.GpsData.Longitude));

                //No APDATA entries.
                //TODO: add this
                bData.AddRange(BitConverter.GetBytes(0));

                //Length of name. Not used
                bData.Add(0);

                //No Name bytes

                //Bit field Channel activity. Not Used.
                bData.AddRange(BitConverter.GetBytes((long)0));

                //Channel
                bData.AddRange(BitConverter.GetBytes((int)ap.Channel));

                //IP address. Not used.
                bData.AddRange(BitConverter.GetBytes(0).Reverse());

                //Min. signal,dBm
                bData.AddRange(BitConverter.GetBytes(-100));

                //Max noise.
                bData.AddRange(BitConverter.GetBytes(0));

                //Speed
                bData.AddRange(BitConverter.GetBytes(((int)ap.MaxRate) * 10));

                //IP subnet address. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //IP netmask. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //Misc flags. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //IElength. Not used/Not needed.
                bData.AddRange(BitConverter.GetBytes((uint)0));
            }
            //Write bytes to file
            System.IO.File.WriteAllBytes(filename, bData.ToArray());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Writes out a NS1 file for the supplied APs
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="points"></param>
        public static void Write(string filename, AccessPoint[] points)
        {
            List<byte> bData = new List<byte>();

            //NetS - signature
            bData.AddRange(new byte[] { 0x4E, 0x65, 0x74, 0x53 });
            //12 - version 12
            bData.AddRange(new byte[] { 0x0c, 0x00, 0x00, 0x00 });

            //How may APs follow
            bData.AddRange(BitConverter.GetBytes(points.Length));

            //Loop through all APs and write them to the list
            foreach (AccessPoint ap in points)
            {
                //Length of the SSID
                bData.Add((byte)ap.Ssid.Length);

                //The SSID
                bData.AddRange(Encoding.ASCII.GetBytes(ap.Ssid));

                //The MAC address
                bData.AddRange(ap.MacAddress.Bytes);

                //RSSI
                bData.AddRange(BitConverter.GetBytes(ap.LastData.Rssi));

                //Noise - not reported, use fake value of -100
                bData.AddRange(BitConverter.GetBytes(-100));

                //SNR - calculate difference of RSSI and -100
                bData.AddRange(BitConverter.GetBytes(-(-100 - ap.LastData.Rssi)));

                //802.11 capability flags. This just shows if the AP uses WEP and/or is AdHoc
                if(ap.Privacy.ToLower() != "none")
                {
                    if(ap.NetworkType != "Infrastructure") bData.AddRange(new byte[] { 0x12, 0x00, 0x00, 0x00 });
                    else bData.AddRange(new byte[] { 0x11, 0x00, 0x00, 0x00 });
                }
                else
                {
                    if (ap.NetworkType != "Infrastructure") bData.AddRange(new byte[] { 0x02, 0x00, 0x00, 0x00 });
                    else bData.AddRange(new byte[] { 0x01, 0x00, 0x00, 0x00 });
                }

                //Beacon interval - not reported, just use 100 msec.
                bData.AddRange(BitConverter.GetBytes((uint)100));

                //First seen time
                bData.AddRange(BitConverter.GetBytes(ap.FirstSeenTimestamp.ToFileTime()));

                //Last seen time
                bData.AddRange(BitConverter.GetBytes(ap.LastSeenTimestamp.ToFileTime()));

                //Latitude
                bData.AddRange(BitConverter.GetBytes(ap.GpsData.Latitude));

                //Longitude
                bData.AddRange(BitConverter.GetBytes(ap.GpsData.Longitude));

                //Number of APDATA entries.
                bData.AddRange(BitConverter.GetBytes(ap.MyNetworkDataCollection.Count));

                lock (ap.MyNetworkDataCollection)
                {
                    foreach (NetworkData data in ap.MyNetworkDataCollection)
                    {
                        // Timestamp
                        bData.AddRange(BitConverter.GetBytes(data.MyTimestamp.ToFileTime()));

                        // RSSI
                        bData.AddRange(BitConverter.GetBytes(data.Rssi));

                        // Noise not reported
                        bData.AddRange(BitConverter.GetBytes(-100));

                        // Location source, 0 = none, 2 = GPS
                        // Since gps locations aren't stored in NetworkData objects, this will be 0
                        bData.AddRange(BitConverter.GetBytes(0));

                        // GpsData - no bytes because source is 0
                    }
                }

                //Length of name. Not used
                bData.Add(0);

                //No Name bytes

                //Bit field Channel activity. Not Used.
                bData.AddRange(BitConverter.GetBytes((long)0));

                //Channel
                bData.AddRange(BitConverter.GetBytes((int)ap.Channel));

                //IP address. Not used.
                bData.AddRange(BitConverter.GetBytes(0).Reverse());

                //Min. signal,dBm
                bData.AddRange(BitConverter.GetBytes(-100));

                //Max noise.
                bData.AddRange(BitConverter.GetBytes(0));

                //Speed
                bData.AddRange(BitConverter.GetBytes(((int)ap.MaxRate) * 10));

                //IP subnet address. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //IP netmask. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //Misc flags. Not used.
                bData.AddRange(BitConverter.GetBytes((uint)0));

                //IElength. Not used/Not needed.
                bData.AddRange(BitConverter.GetBytes((uint)0));
            }
            //Write bytes to file
            System.IO.File.WriteAllBytes(filename, bData.ToArray());
        }
Exemplo n.º 6
0
 /// <summary>
 /// Determines if the AP should be filtered out. APs must pass ALL filters for this to return true
 /// </summary>
 /// <param name="ap">The AP to filter</param>
 /// <returns>true if the AP passes, otherwise false</returns>
 private bool RunFilters(AccessPoint ap)
 {
     lock (_filters)
     {
         return _filters.Where(f => f.Enabled).All(f => f.Eval(ap));
     }
 }