예제 #1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            AccessPoint  selectedAP = accessPoints.ToList()[checkedItem];
            DialogResult resConnect = MetroMessageBox.Show(this, "Are you sure you want to connect to '" + selectedAP.Name + "' network?", "Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resConnect == DialogResult.Yes)//Подключиться к сети
            {
                AuthRequest authRequest = new AuthRequest(selectedAP);
                bool        overwrite   = true;

                if (authRequest.IsPasswordRequired) //если требуется ввод пароля
                {
                    if (selectedAP.HasProfile)      //если есть профиль
                    {
                        DialogResult resProfile = MetroMessageBox.Show(this, "Do you want to use existing profile?", "Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (resProfile == DialogResult.Yes) //использовать сущетвующий профиль
                        {
                            overwrite = false;              //не перезаписывать профиль
                        }
                    }

                    if (overwrite)                                         //перезаписать профиль
                    {
                        authRequest.Password = PasswordPrompt(selectedAP); //получить пароль
                    }
                }
                selectedAP.ConnectAsync(authRequest, overwrite, OnConnectedComplete);//попытка подключения
            }
        }
예제 #2
0
        public void ConnectToOriginal()
        {
            signalStrengthTimer.Stop();
            stillConnectedTimer.Stop();

            if (originalAccessPoint == null)
            {
                return;
            }

            try {
                AccessPoint connectedAccessPoint = GetConnectedAccessPoint();
                if (connectedAccessPoint != null && connectedAccessPoint.Name.Equals(originalAccessPoint.Name))
                {
                    listener.ConnectedToDifferentNetwork(connectedAccessPoint.Name);
                    return;
                }

                AuthRequest authRequest = new AuthRequest(originalAccessPoint);
                originalAccessPoint.ConnectAsync(authRequest);
            }
            catch (Exception)
            {
                listener.NoWifiAvailable();
            }
        }
예제 #3
0
        public Task <bool> ConnectWiFiSSID(string Password)
        {
            var         tcs         = new TaskCompletionSource <bool>();
            AuthRequest authRequest = new AuthRequest(ConnectAccessPoint);
            bool        overwrite   = true;

            if (authRequest.IsPasswordRequired)
            {
                if (ConnectAccessPoint.HasProfile)
                // If there already is a stored profile for the network, we can either use it or overwrite it with a new password.
                {
                    overwrite = false;
                }

                if (overwrite)
                {
                    authRequest.Password = Password;

                    //if (authRequest.IsUsernameRequired)
                    //{
                    //    Console.Write("\r\nPlease enter a username: "******"\r\nPlease enter a domain: ");
                    //    authRequest.Domain = Console.ReadLine();
                    //}
                }
            }

            ConnectAccessPoint.ConnectAsync(authRequest, overwrite, e => tcs.TrySetResult(e));
            return(tcs.Task);
        }
예제 #4
0
        private void Reconnect(TimeSpan?WaitTime = null)
        {
            if (oAP != null)
            {
                var r = new AuthRequest(oAP);

                if (WaitTime.HasValue)
                {
                    Thread.Sleep(WaitTime.Value);
                }

                oAP.ConnectAsync(r, false, x =>
                {
                    if (!x)
                    {
                        WriteToConsole(ConsoleType.WiFiReconnectionProblem, oAP.Name);
                        oAP = GetNext(oAPs, oAP);
                        Reconnect(TimeSpan.FromMinutes(1));
                    }
                    else
                    {
                        WriteToConsole(ConsoleType.WiFiReconnected);
                    }
                });
            }
        }
예제 #5
0
        private void ConnectToCloudRover(AccessPoint cloudRoverAccessPoint)
        {
            if (!cloudRoverAccessPoint.HasProfile)
            {
                listener.CloudRoverNoProfile();
                return;
            }

            listener.ConnectingToCloudRover();
            AuthRequest authRequest = new AuthRequest(cloudRoverAccessPoint);

            cloudRoverAccessPoint.ConnectAsync(authRequest, false, OnConnectedComplete);
        }
        private static void Connect()
        {
            var accessPoints = List();

            Console.Write("\r\nEnter the index of the network you wish to connect to: ");

            int selectedIndex = int.Parse(Console.ReadLine());

            if (selectedIndex > accessPoints.ToArray().Length || accessPoints.ToArray().Length == 0)
            {
                Console.Write("\r\nIndex out of bounds");
                return;
            }
            AccessPoint selectedAP = accessPoints.ToList()[selectedIndex];

            // Auth
            AuthRequest authRequest = new AuthRequest(selectedAP);
            bool        overwrite   = true;

            if (authRequest.IsPasswordRequired)
            {
                if (selectedAP.HasProfile)
                // If there already is a stored profile for the network, we can either use it or overwrite it with a new password.
                {
                    Console.Write("\r\nA network profile already exist, do you want to use it (y/n)? ");
                    if (Console.ReadLine().ToLower() == "y")
                    {
                        overwrite = false;
                    }
                }

                if (overwrite)
                {
                    if (authRequest.IsUsernameRequired)
                    {
                        Console.Write("\r\nPlease enter a username: "******"\r\nPlease enter a domain: ");
                        authRequest.Domain = Console.ReadLine();
                    }
                }
            }

            selectedAP.ConnectAsync(authRequest, overwrite, OnConnectedComplete);
        }
예제 #7
0
        private void dictionary_crack(AccessPoint selectedAP)
        {
            if (passwords.Count == 0)
            {
                MessageBox.Show("Please Select a Wordlist");
                return;
            }

            foreach (string pass in passwords)
            {
                SetControlPropertyThreadSafe(label4, "Text", pass);

                SetControlPropertyThreadSafe(label5, "Text", count.ToString());
                count++;

                // Auth
                AuthRequest authRequest = new AuthRequest(selectedAP);
                bool        overwrite   = true;

                if (authRequest.IsPasswordRequired)
                {
                    if (overwrite)
                    {
                        if (authRequest.IsUsernameRequired)
                        {
                            Console.Write("\r\nPlease enter a username: "******"\r\nPlease enter a domain: ");
                            authRequest.Domain = Console.ReadLine();
                        }
                    }
                }

                selectedAP.ConnectAsync(authRequest, overwrite, OnConnectedComplete);
                int i = Convert.ToInt32(textBox1.Text);
                Thread.Sleep(i * 1000);
                if (check(selectedAP) == true && CheckForInternetConnection() == true)
                {
                    var timeEnded = DateTime.Now;
                    SetControlPropertyThreadSafe(label4, "Text", pass);
                    MessageBox.Show("Password is :" + pass, "Wifi Bruteforce", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SetControlPropertyThreadSafe(label34, "Text", timeEnded.ToString());
                    return;
                }
            }
        }
예제 #8
0
        private void btn_connect_Click(object sender, EventArgs e)
        {
            var         index      = listView1.FocusedItem.Index;
            AccessPoint selectedAP = accessPoints.ToList()[index];

            // Auth
            AuthRequest authRequest = new AuthRequest(selectedAP);

            if (authRequest.IsPasswordRequired)
            {
                authRequest.Password = EnterPassword(selectedAP, txt_password.Text);
            }

            selectedAP.ConnectAsync(authRequest, true, OnConnectedComplete);
        }
예제 #9
0
        private void crack(AccessPoint selectedAP)
        {
            if (passwords.Count == 0)
            {
                MessageBox.Show("Please Select a Wordlist");
                return;
            }
            int count = 1;

            foreach (string pass in passwords)
            {
                SetControlPropertyThreadSafe(label3, "Text", "Status: Trying Password: "******" (" + count + " / " + passwords.Count + ")"); count++;
                // Auth
                AuthRequest authRequest = new AuthRequest(selectedAP);
                bool        overwrite   = true;

                if (authRequest.IsPasswordRequired)
                {
                    if (overwrite)
                    {
                        if (authRequest.IsUsernameRequired)
                        {
                            Console.Write("\r\nPlease enter a username: "******"\r\nPlease enter a domain: ");
                            authRequest.Domain = Console.ReadLine();
                        }
                    }
                }

                selectedAP.ConnectAsync(authRequest, overwrite, OnConnectedComplete);
                int i = Convert.ToInt32(textBox1.Text);
                Thread.Sleep(i * 1000);
                if (check(selectedAP) == true && CheckForInternetConnection() == true)
                {
                    SetControlPropertyThreadSafe(label3, "Text", "Status: Successfully Cracked: " + selectedAP.Name + " With Password: " + pass);
                    return;
                }
            }
        }
예제 #10
0
        private void ConnectAccessPoint(AccessPoint ap)
        {
            AuthRequest authRequest = new AuthRequest(ap);
            bool        overwrite   = false;

            if (authRequest.IsPasswordRequired)
            {
                if (!ap.HasProfile)
                {
                    //= Interaction.InputBox("", "Input PassWord");
                    InputDialog.Show(out string pwd, "Input the password");
                    if (pwd.Length >= 8 && !string.IsNullOrWhiteSpace(pwd.Trim()) && ap.IsValidPassword(pwd))
                    {
                        authRequest.Password = pwd;
                    }
                }
            }
            ap.ConnectAsync(authRequest, overwrite, OnConnectedComplete);
        }
예제 #11
0
        public static bool Connect(AccessPoint accessPoint, String password = null, Action <bool> onCompleteCallback = null)
        {
            var authRequest      = new AuthRequest(accessPoint);
            var overwriteProfile = authRequest.IsPasswordRequired && !accessPoint.HasProfile;

            if (overwriteProfile)
            {
                authRequest.Password = password;
            }

            if (onCompleteCallback != null)
            {
                accessPoint.ConnectAsync(authRequest, overwriteProfile, onCompleteCallback);
                return(true);
            }
            else
            {
                return(accessPoint.Connect(authRequest, overwriteProfile));
            }
        }
예제 #12
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        public bool ExecuteTest(bool configure)
        {
            if (_testThread != null)
            {
                return(false);
            }
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;

            TestOk         = false;
            ConfigPossible = false;
            AdapterType    = -1;
            AccessPoint ap = _form.GetSelectedAp();

            if (ap != null)
            {
                AuthRequest authRequest = new AuthRequest(ap);
                if (authRequest.IsPasswordRequired)
                {
                    authRequest.Password = _form.WifiPassword;
                }
                ap.ConnectAsync(authRequest, true, success =>
                {
                    _form.BeginInvoke((Action)(() =>
                    {
                        if (!success)
                        {
                            _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        }
                        else
                        {
                            _form.PerformSearch();
                        }
                    }));
                });
                return(true);
            }

            WlanInterface wlanIface = _form.GetSelectedWifiDevice();

            if (wlanIface != null)
            {
                try
                {
                    WlanConnectionAttributes conn = wlanIface.CurrentConnection;
                    string ssidString             = Encoding.ASCII.GetString(conn.wlanAssociationAttributes.dot11Ssid.SSID).TrimEnd('\0');
                    string ipAddr = string.Empty;
                    bool   isEnet = string.Compare(ssidString, Patch.AdapterSsidEnet, StringComparison.OrdinalIgnoreCase) == 0;

                    IPInterfaceProperties ipProp = wlanIface.NetworkInterface.GetIPProperties();
                    if (ipProp == null)
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return(false);
                    }
                    ipAddr = (from addr in ipProp.DhcpServerAddresses where addr.AddressFamily == AddressFamily.InterNetwork select addr.ToString()).FirstOrDefault();
                    if (string.IsNullOrEmpty(ipAddr))
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return(false);
                    }

                    if (isEnet)
                    {
                        if (configure)
                        {
                            Process.Start(string.Format("http://{0}", ipAddr));
                            _form.UpdateStatusText(Resources.Strings.WifiUrlOk);
                            TestOk         = true;
                            ConfigPossible = true;
                            return(true);
                        }
                    }
                    _testThread = new Thread(() =>
                    {
                        try
                        {
                            Thread.CurrentThread.CurrentCulture   = cultureInfo;
                            Thread.CurrentThread.CurrentUICulture = cultureInfo;
                            if (isEnet)
                            {
                                TestOk = RunWifiTestEnetRetry(ipAddr);
                                if (TestOk)
                                {
                                    ConfigPossible = true;
                                }
                            }
                            else
                            {
                                TestOk = RunWifiTestElm(ipAddr, configure, out bool configRequired);
                                if (TestOk && configRequired)
                                {
                                    ConfigPossible = true;
                                }
                            }
                        }
                        finally
                        {
                            _testThread = null;
                            _form.UpdateButtonStatus();
                        }
                    });
                    _testThread.Start();
                }
                catch (Exception)
                {
                    _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                    return(false);
                }
                return(true);
            }

            BluetoothDeviceInfo devInfo = _form.GetSelectedBtDevice();

            if (devInfo == null)
            {
                return(false);
            }
            string pin = _form.BluetoothPin;

            _testThread = new Thread(() =>
            {
                try
                {
                    Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;
                    _form.UpdateStatusText(Resources.Strings.Connecting);
                    if (!ConnectBtDevice(devInfo, pin))
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return;
                    }
                    TestOk = RunBtTest(configure, out bool configRequired);
                    if (TestOk && configRequired)
                    {
                        ConfigPossible = true;
                    }
                }
                finally
                {
                    DisconnectStream();
                    _testThread = null;
                    _form.UpdateButtonStatus();
                }
            });
            _testThread.Start();
            return(true);
        }
예제 #13
0
        //int progress = 0;
        private void bruteforce(char[] fin, String pwd, int pos, int length, AccessPoint selectedAP)
        {
            //timer1.Start();
            Stopwatch st = new Stopwatch();

            st.Start();

            sw.Start();

            if (pos < length)
            {
                foreach (char ch in fin)
                {
                    bruteforce(fin, pwd + ch, pos + 1, length, selectedAP);

                    elapsedSec = Convert.ToInt32(sw.Elapsed.TotalSeconds);

                    // Auth
                    AuthRequest authRequest = new AuthRequest(selectedAP);
                    bool        overwrite   = true;

                    if (authRequest.IsPasswordRequired)
                    {
                        if (overwrite)
                        {
                            if (authRequest.IsUsernameRequired)
                            {
                                Console.Write("\r\nPlease enter a username: "******"\r\nPlease enter a domain: ");
                                authRequest.Domain = Console.ReadLine();
                            }
                        }
                    }

                    selectedAP.ConnectAsync(authRequest, overwrite, OnConnectedComplete);
                }

                try
                {
                    SetControlPropertyThreadSafe(label4, "Text", pwd);

                    SetControlPropertyThreadSafe(label5, "Text", count.ToString());
                    count++;

                    speed = count / elapsedSec;
                    SetControlPropertyThreadSafe(label23, "Text", speed + " passwords/s");

                    passwordLeft = (int)permutations - count;
                    /*estimatedTime = speed * (int)permutations - passwordLeft * speed;*/
                    /*estimatedTime = ((int)permutations * speed - passwordLeft) * speed;*/

                    //estimatedTime = ((int)permutations - passwordLeft) / speed;
                    estimatedTime = (passwordLeft * 100) / (int)permutations;

                    /*SetControlPropertyThreadSafe(progressBar1, "Maximum", (int)permutations);
                     * SetControlPropertyThreadSafe(progressBar1, "Value", estimatedTime);
                     * SetControlPropertyThreadSafe(label30, "Text", estimatedTime.ToString() + "%");*/

                    SetControlPropertyThreadSafe(progressBar1, "Value", 0);
                    SetControlPropertyThreadSafe(progressBar1, "Step", 1);
                    SetControlPropertyThreadSafe(progressBar1, "Minimum", 0);

                    /*progressBar1.Value = 0;
                     * progressBar1.Step = 1;
                     * progressBar1.Minimum = 0;
                     * progressBar1.Maximum = 5000;*/

                    while (st.Elapsed < TimeSpan.FromSeconds(1))
                    {
                        count++;
                        //SetControlPropertyThreadSafe(progressBar1, "Value", progressBar1.Value++);
                        progress += 1;
                        SetControlPropertyThreadSafe(progressBar1, "Value", progress);
                    }
                    SetControlPropertyThreadSafe(progressBar1, "Maximum", (int)permutations);

                    if (check(selectedAP) == true && CheckForInternetConnection() == true)
                    {
                        var timeEnded = DateTime.Now;
                        SetControlPropertyThreadSafe(label4, "Text", pwd);
                        MessageBox.Show("Password is :" + pwd, "Wifi Bruteforce", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        SetControlPropertyThreadSafe(label34, "Text", timeEnded.ToString());
                        sw.Stop();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }
        }
예제 #14
0
 public void ConnectAsync(AuthRequest authRequest, Action <bool> onConnectComplete, bool remember)
 {
     accessPoint.ConnectAsync(authRequest, !remember, onConnectComplete);
 }
예제 #15
0
 public static void Connect(AccessPoint accessPoint, AuthRequest authRequest)
 {
     accessPoint.ConnectAsync(authRequest);
 }
예제 #16
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        public bool ExecuteTest(bool configure)
        {
            if (_testThread != null)
            {
                return(false);
            }
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;

            TestOk         = false;
            ConfigPossible = false;
            AccessPoint ap = _form.GetSelectedAp();

            if (ap != null)
            {
                AuthRequest authRequest = new AuthRequest(ap);
                if (authRequest.IsPasswordRequired)
                {
                    authRequest.Password = _form.WifiPassword;
                }
                ap.ConnectAsync(authRequest, true, success =>
                {
                    _form.BeginInvoke((Action)(() =>
                    {
                        if (!success)
                        {
                            _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        }
                        else
                        {
                            _form.PerformSearch();
                        }
                    }));
                });
                return(true);
            }

            WlanInterface wlanIface = _form.GetSelectedWifiDevice();

            if (wlanIface != null)
            {
                try
                {
                    IPInterfaceProperties ipProp = wlanIface.NetworkInterface.GetIPProperties();
                    if (ipProp == null)
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return(false);
                    }
                    string ipAddr = (from addr in ipProp.DhcpServerAddresses where addr.AddressFamily == AddressFamily.InterNetwork select addr.ToString()).FirstOrDefault();
                    if (string.IsNullOrEmpty(ipAddr))
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return(false);
                    }
                    if (configure)
                    {
                        Process.Start(string.Format("http://{0}", ipAddr));
                        _form.UpdateStatusText(Resources.Strings.WifiUrlOk);
                        TestOk         = true;
                        ConfigPossible = true;
                        return(true);
                    }
                    _testThread = new Thread(() =>
                    {
                        try
                        {
                            Thread.CurrentThread.CurrentCulture   = cultureInfo;
                            Thread.CurrentThread.CurrentUICulture = cultureInfo;
                            TestOk = RunWifiTestRetry(ipAddr);
                            if (TestOk)
                            {
                                ConfigPossible = true;
                            }
                        }
                        finally
                        {
                            _testThread = null;
                            _form.UpdateButtonStatus();
                        }
                    });
                    _testThread.Start();
                }
                catch (Exception)
                {
                    _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                    return(false);
                }
                return(true);
            }

            BluetoothDeviceInfo devInfo = _form.GetSelectedBtDevice();

            if (devInfo == null)
            {
                return(false);
            }
            string pin = _form.BluetoothPin;

            _testThread = new Thread(() =>
            {
                try
                {
                    Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;
                    _form.UpdateStatusText(Resources.Strings.Connecting);
                    if (!ConnectBtDevice(devInfo, pin))
                    {
                        _form.UpdateStatusText(Resources.Strings.ConnectionFailed);
                        return;
                    }
                    bool configRequired;
                    TestOk = RunBtTest(configure, out configRequired);
                    if (TestOk && configRequired)
                    {
                        ConfigPossible = true;
                    }
                }
                finally
                {
                    DisconnectBtDevice();
                    _testThread = null;
                    _form.UpdateButtonStatus();
                }
            });
            _testThread.Start();
            return(true);
        }
예제 #17
0
파일: DLG_Wifi.cs 프로젝트: luckypal/Kiosk
        private bool Connect(string _name, bool _over, string _username, string _password, string _domain, string _rename, string _sec = null, bool _auto = true)
        {
            IEnumerable <AccessPoint> source = List();
            AccessPoint accessPoint          = null;
            int         num = 1;

            for (int i = 0; i < source.ToArray().Length; i++)
            {
                string text = "";
                if (!string.IsNullOrEmpty(source.ToList()[i].Name))
                {
                    text = source.ToList()[i].Name;
                }
                else if (source.ToList()[i]._network.dot11BssType == Dot11BssType.Infrastructure && source.ToList()[i]._network.networkConnectable)
                {
                    switch (source.ToList()[i]._network.dot11DefaultAuthAlgorithm)
                    {
                    case Dot11AuthAlgorithm.IEEE80211_SharedKey:
                        text = "<HIDEN WEP> " + num;
                        num++;
                        break;

                    case Dot11AuthAlgorithm.IEEE80211_Open:
                        text = "<HIDEN OPEN> " + num;
                        num++;
                        break;

                    case Dot11AuthAlgorithm.RSNA_PSK:
                        text = "<HIDEN RSNA PSK> " + num;
                        num++;
                        break;

                    case Dot11AuthAlgorithm.RSNA:
                        text = "<HIDEN RSNA> " + num;
                        num++;
                        break;

                    case Dot11AuthAlgorithm.WPA:
                        text = "<HIDEN WPA> " + num;
                        num++;
                        break;

                    case Dot11AuthAlgorithm.WPA_PSK:
                        text = "<HIDEN WPA PSK> " + num;
                        num++;
                        break;
                    }
                }
                if (text.ToLower() == _name.ToLower())
                {
                    accessPoint = source.ToList()[i];
                    break;
                }
            }
            if (accessPoint == null)
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(_rename))
            {
                accessPoint._network.dot11Ssid.SSIDLength = (uint)_rename.Length;
                byte[] array = new byte[32];
                for (int i = 0; i < 32; i++)
                {
                    array[i] = 0;
                }
                byte[] bytes = Encoding.ASCII.GetBytes(_rename);
                for (int i = 0; i < bytes.Length; i++)
                {
                    array[i] = bytes[i];
                }
                accessPoint._network.dot11Ssid.SSID = array;
                accessPoint._network.profileName    = _rename;
            }
            switch (_sec)
            {
            case "IEEE80211_Open":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.IEEE80211_Open;
                break;

            case "IEEE80211_SharedKey":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.IEEE80211_SharedKey;
                break;

            case "WPA":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.WPA;
                break;

            case "WPA_PSK":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.WPA_PSK;
                break;

            case "RSNA":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.RSNA;
                break;

            case "RSNA_PSK":
                accessPoint._network.dot11DefaultAuthAlgorithm = Dot11AuthAlgorithm.RSNA_PSK;
                break;
            }
            AuthRequest authRequest = new AuthRequest(accessPoint);
            bool        flag        = _over;

            if (authRequest.IsPasswordRequired && flag)
            {
                if (authRequest.IsUsernameRequired && !string.IsNullOrEmpty(_username))
                {
                    authRequest.Username = _username;
                }
                authRequest.Password = _password;
                if (authRequest.IsDomainSupported && !string.IsNullOrEmpty(_domain))
                {
                    authRequest.Domain = _domain;
                }
            }
            authRequest.AutoConnect = _auto;
            accessPoint.ConnectAsync(authRequest, flag, OnConnectedComplete);
            return(true);
        }