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.Connect(authRequest, overwrite); }
public override Task <GenericMessage> ConnectWithAuth(ConnectionRequest request, ServerCallContext context) { AccessPoint accessPoint = _wifi.GetAccessPoints().First(ap => ap.Name.Equals(request.AccessPoint.Name)); SimpleWifi.AuthRequest auth = new SimpleWifi.AuthRequest(accessPoint) { Password = request.AuthRequest.Password, Domain = request.AuthRequest.Domain, Username = request.AuthRequest.Username }; return(Task.FromResult(new GenericMessage { Result = accessPoint.Connect(auth) })); }
public SubForm(AccessPoint ap, ref RichTextBox showRichTextBox2) { this.showRichTextBox2 = showRichTextBox2; InitializeComponent(); this.selectedAP = ap; // Создаём объект аутентификации authRequest = new AuthRequest(selectedAP); overwrite = true; textBoxUsername.Enabled = authRequest.IsUsernameRequired; textBoxPassword.Enabled = authRequest.IsPasswordRequired; textBoxDomain.Enabled = authRequest.IsDomainSupported; }
/// <summary> /// Connect synchronous to the access point. /// </summary> public bool Connect(AuthRequest request, bool overwriteProfile = false) { // No point to continue with the connect if the password is not valid if overwrite is true or profile is missing. if (!request.IsPasswordValid && (!HasProfile || overwriteProfile)) return false; // If we should create or overwrite the profile, do so. if (!HasProfile || overwriteProfile) { if (HasProfile) _interface.DeleteProfile(Name); request.Process(); } // TODO: Auth algorithm: IEEE80211_Open + Cipher algorithm: None throws an error. // Probably due to connectionmode profile + no profile exist, cant figure out how to solve it though. return _interface.ConnectSynchronously(WlanConnectionMode.Profile, _network.dot11BssType, Name, 6000); }
/// <summary> /// Предусмотрен брут только тех точек, которые требуют только пароль /// </summary> public void GetBrut(object ap) { AccessPoint selectedAP = (AccessPoint)ap; var authRequest = new AuthRequest(selectedAP); if (authRequest.IsDomainSupported || authRequest.IsUsernameRequired) { ChangeShowRichTextBox2(" Соединение требует не только пароль, но и логин пользователя/домен\n"); stopBrut = true; return; } if (authRequest.IsPasswordRequired) { for (int i = 0; i < passwords.Length && !stopBrut; i++) { bool overwrite = true; string pass = passwords[i]; // Требуется ли пароль if (overwrite) { bool validPassFormat = false; validPassFormat = selectedAP.IsValidPassword(pass); if (!validPassFormat) { ChangeShowRichTextBox2("-> Невалидный пароль:" + pass + "\r\n"); continue; } else { authRequest.Password = pass; bool success = selectedAP.Connect(authRequest, overwrite); if (success) { stopBrut = true; ChangeShowRichTextBox2(" Соединение удалось, пароль: " + pass); ChangeButtonBrut("Начать перебор паролей к сети",true); return; } else { ChangeShowRichTextBox2 (i + " Соединение не удалось по паролю: " + pass); } } } ChangeLabelUsedPasses((i + 1).ToString()); ChangeLabelUnUsedPasses((passwords.Length - i - 1).ToString()); } } else { ChangeShowRichTextBox2(" Соединение свободно, пароль не требуется\n"); ChangeButtonBrut("Начать перебор паролей к сети"); t.Abort(); stopBrut = true; return; } t.Abort(); stopBrut = true; ChangeButtonBrut("Начать перебор паролей к сети"); ChangeShowRichTextBox2(string.Format("\n Пароль не найден")); }
private bool ConnectToWifi(SimpleWifi.AccessPoint ap, string password) { SimpleWifi.AuthRequest authRequest = new SimpleWifi.AuthRequest(ap); authRequest.Password = wifi_passwordBox.Password; return(ap.Connect(authRequest)); }
/// <summary> /// Connect asynchronous to the access point. /// </summary> public void ConnectAsync(AuthRequest request, bool overwriteProfile = false) { // TODO: Refactor -> Use async connect in wlaninterface. ThreadPool.QueueUserWorkItem(new WaitCallback((o) => { Connect(request, overwriteProfile); })); }
/// <summary> /// Connect synchronous to the access point. /// </summary> public bool Connect(AuthRequest request, bool overwriteProfile = false, int timeout = 6000) { // No point to continue with the connect if the password is not valid if overwrite is true or profile is missing. if (!request.IsPasswordValid && (!HasProfile || overwriteProfile)) return false; bool result = false; // If we should create or overwrite the profile, do so. if (!HasProfile || overwriteProfile) { if (HasProfile) _interface.DeleteProfile(Name); request.Process(); } bool connect = false; //while (!connect) //{ //result = _interface.ConnectSynchronously(WlanConnectionMode.Profile, _network.dot11BssType, Name, timeout); //while (_interface.InterfaceState == WlanInterfaceState.Associating || // _interface.InterfaceState == WlanInterfaceState.Authenticating) //{ // Thread.Sleep(10); //} while (_interface.InterfaceState == WlanInterfaceState.Associating || _interface.InterfaceState == WlanInterfaceState.Authenticating) { Thread.Sleep(10); } Thread.Sleep(2500); if (_interface.InterfaceState == WlanInterfaceState.Connected) { result = true; connect = true; } //} // TODO: Auth algorithm: IEEE80211_Open + Cipher algorithm: None throws an error. // Probably due to connectionmode profile + no profile exist, cant figure out how to solve it though. return result; }
/// <summary> /// Connect asynchronous to the access point. /// </summary> public void ConnectAsync(AuthRequest request, bool overwriteProfile = false, Action<bool> onConnectComplete = null) { // TODO: Refactor -> Use async connect in wlaninterface. ThreadPool.QueueUserWorkItem(new WaitCallback((o) => { bool success = false; try { success = Connect(request, overwriteProfile); } catch (Win32Exception) { success = false; } if (onConnectComplete != null) onConnectComplete(success); })); }