private bool logout(int itemIndex) { bool result = false; ListViewItem lvi = accounts.Items[itemIndex]; Domain domain = (Domain)lvi.Tag; if (domain != null) { DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domain.ID, null); Status authStatus = domainAuth.Logout(simiasManager.WebServiceUri, simiasManager.DataPath); if (authStatus != null && authStatus.statusCode == StatusCodes.Success) { result = true; domain.DomainInfo.Authenticated = false; lvi.Tag = domain; if (this.simiasWebService.GetRememberOption(domain.ID) == false) { this.simiasWebService.StorePassPhrase(domain.ID, "", CredentialType.None, false); } FormsTrayApp.globalProp().updateifListViewDomainStatus(domain.DomainInfo.ID, false); (FormsTrayApp.globalProp()).RemoveDomainFromUIList(domain.DomainInfo.ID, null); } } return result; }
public bool logoutFromDomain(Domain domain) { bool result = false; if (domain != null) { DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domain.ID, null); Status authStatus = domainAuth.Logout(simiasManager.WebServiceUri, simiasManager.DataPath); if (authStatus != null && authStatus.statusCode == StatusCodes.Success) { result = true; domain.DomainInfo.Authenticated = false; if (this.simiasWebService.GetRememberOption(domain.ID) == false) { this.simiasWebService.StorePassPhrase(domain.ID, "", CredentialType.None, false); } FormsTrayApp.globalProp().updateifListViewDomainStatus(domain.DomainInfo.ID, false); (FormsTrayApp.globalProp()).RemoveDomainFromUIList(domain.DomainInfo.ID, null); FormsTrayApp.globalProp().UpdateiFolderStatus(domain.DomainInfo.Authenticated, domain.DomainInfo.ID); } } return result; }
public Status AuthenticateDomainWithProxy(string domainID) { string userID; string credentials; DomainInformation dom = (DomainInformation)keyedDomains[domainID]; if (dom == null) return null; try { SetHttpProxyForHost(dom.Host); CredentialType credentialType = simws.GetDomainCredentials( domainID, out userID, out credentials); if ((credentialType == CredentialType.Basic) && (credentials != null)) { DomainAuthentication domainAuth = new DomainAuthentication( "iFolder", domainID, credentials); Status status = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); if (status.statusCode == StatusCodes.InvalidCredentials) { simws.SetDomainCredentials(domainID, null, CredentialType.None); } return status; } } catch {} return null; }
public void LogoutDomain(string domainID) { DomainAuthentication domainAuth = new DomainAuthentication( "iFolder", domainID, null); domainAuth.Logout(simiasManager.WebServiceUri, simiasManager.DataPath); try { DomainInformation dom = simws.GetDomainInformation(domainID); if (dom != null) { dom.Authenticated = false; ClearDomainPassPhrase(domainID); if (keyedDomains.Contains(dom.ID)) keyedDomains[dom.ID] = dom; else { AddDomainToHashtable(dom); if (DomainAdded != null) { DomainAddedIdleHandler addedHandler = new DomainAddedIdleHandler(domainID, this); GLib.Idle.Add(addedHandler.IdleHandler); } } } } catch{} if (DomainLoggedOut != null) DomainLoggedOut(this, new DomainEventArgs(domainID)); }
public Status AuthenticateDomain(string domainID, string password, bool bSavePassword) { Status status; DomainAuthentication domainAuth = new DomainAuthentication( "iFolder", domainID, password); try { status = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); if (status.statusCode == StatusCodes.Success || status.statusCode == StatusCodes.SuccessInGrace) { if (bSavePassword) { try { if (password != null && password.Length > 0) simws.SetDomainCredentials(domainID, password, CredentialType.Basic); else simws.SetDomainCredentials(domainID, null, CredentialType.None); } catch (Exception) { } } status = HandleDomainLoggedIn(domainID, status); } } catch (Exception) { status = null; } return status; }
public Status AuthenticateDomain(string domainID) { DomainAuthentication domainAuth = new DomainAuthentication( "iFolder", domainID, null); try { return domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); } catch {} return null; }
private bool login() { bool result = false; DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password); string HostUrl = domainInfo.Host; Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); switch (authStatus.statusCode) { case StatusCodes.InvalidCertificate: if (authStatus.UserName != null) domainInfo.Host = authStatus.UserName; byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host); System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray); BeginInvoke( displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 }); messageEvent.WaitOne(); if ( messageDialogResult == DialogResult.Yes ) { simiasWebService.StoreCertificate(byteArray, domainInfo.Host); result = login(); } break; case StatusCodes.Success: case StatusCodes.SuccessInGrace: result = true; if (authStatus.statusCode.Equals(StatusCodes.SuccessInGrace)) { BeginInvoke( displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("graceLogin"), authStatus.RemainingGraceLogins), resourceManager.GetString("graceLoginTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); } if ( updatePasswordPreference ) { try { if ( rememberPassword ) { simiasWebService.SetDomainCredentials( domainInfo.ID, password, CredentialType.Basic ); } else { simiasWebService.SetDomainCredentials( domainInfo.ID, null, CredentialType.None ); } } catch (Exception ex) { BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); } } break; case StatusCodes.InvalidCredentials: case StatusCodes.InvalidPassword: case StatusCodes.UnknownUser: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.AccountDisabled: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.AccountLockout: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.SimiasLoginDisabled: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.UserAlreadyMoved: result = login(); break; default: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; } return result; }
private bool authenticate() { bool result = false; try { DomainAuthentication domainAuth = new DomainAuthentication( "iFolder", domainInfo.ID, null); Status status = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); switch (status.statusCode) { case StatusCodes.InvalidCertificate: byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host); System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray); BeginInvoke( displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 } ); messageEvent.WaitOne(); if ( messageDialogResult == DialogResult.Yes ) { simiasWebService.StoreCertificate(byteArray, domainInfo.Host); result = authenticate(); } break; case StatusCodes.Success: result = true; break; case StatusCodes.SuccessInGrace: BeginInvoke( displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("graceLogin"), status.RemainingGraceLogins), resourceManager.GetString("graceLoginTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); result = true; break; default: { string userID; CredentialType credType = simiasWebService.GetDomainCredentials(domainInfo.ID, out userID, out password); if ((credType == CredentialType.Basic) && (password != null)) { domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password); Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); switch (authStatus.statusCode) { case StatusCodes.Success: result = true; break; case StatusCodes.SuccessInGrace: BeginInvoke( displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("graceLogin"), status.RemainingGraceLogins), resourceManager.GetString("graceLoginTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); result = true; break; case StatusCodes.AccountDisabled: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.AccountLockout: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.SimiasLoginDisabled: BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; case StatusCodes.UnknownUser: case StatusCodes.InvalidPassword: case StatusCodes.InvalidCredentials: simiasWebService.SetDomainCredentials(domainInfo.ID, null, CredentialType.None); BeginInvoke( displayMessageDelegate, new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } ); messageEvent.WaitOne(); break; } } break; } } } catch {} return result; }
public bool initialConnect() { bool result = false; bool certPrompt = false; try { SetProxyForDomain(server, true); domainInfo = simiasWebService.ConnectToDomain(user, password, server); switch (domainInfo.StatusCode) { case StatusCodes.InvalidCertificate: string serverName = domainInfo.HostUrl != null ? domainInfo.HostUrl : server; byte[] byteArray = simiasWebService.GetCertificate(server); System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray); if (!autoAccountEnabled || (autoAccountEnabled && promptForInvalidCert)) certPrompt = true; if (certPrompt) { if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("verifyCert"), serverName), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 }); messageEvent.WaitOne(); } else { MyMessageBox mmb = new MyMessageBox(string.Format(resourceManager.GetString("verifyCert"), serverName), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2); mmb.StartPosition = FormStartPosition.CenterScreen; messageDialogResult = mmb.ShowDialog(); } if (messageDialogResult == DialogResult.Yes) { if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp)) { server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString(); } else { UriBuilder ub = new UriBuilder(server); ub.Scheme = Uri.UriSchemeHttps; server = ub.ToString(); } simiasWebService.StoreCertificate(byteArray, server); ServersForCertStore.Add(server); result = initialConnect(); } else { simiasWebService.RemoveCertFromTable(server); } } else { if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp)) { server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString(); } else { UriBuilder ub = new UriBuilder(server); ub.Scheme = Uri.UriSchemeHttps; server = ub.ToString(); } simiasWebService.StoreCertificate(byteArray, server); ServersForCertStore.Add(server); result = initialConnect(); } break; case StatusCodes.Success: case StatusCodes.SuccessInGrace: DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password); domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); domainInfo.Authenticated = true; if (rememberPassword) { try { simiasWebService.SetDomainCredentials(domainInfo.ID, password, CredentialType.Basic); } catch (Exception ex) { if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("Exception is {0}", ex.Message); } } } ServersForCertStore.Clear(); if (defaultServer) { try { simiasWebService.SetDefaultDomain(domainInfo.ID); domainInfo.IsDefault = true; } catch (Exception ex) { if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("setDefaultError"), resourceManager.GetString("accountErrorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0} : {1}", resourceManager.GetString("accountErrorTitle"), resourceManager.GetString("setDefaultError")); } } } if (domainInfo.StatusCode.Equals(StatusCodes.SuccessInGrace) && !autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { string.Format(resourceManager.GetString("graceLogin"), domainInfo.RemainingGraceLogins), resourceManager.GetString("graceLoginTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } if (EnterpriseConnect != null) { EnterpriseConnect(this, new DomainConnectEventArgs(domainInfo)); } result = true; break; case StatusCodes.InvalidCredentials: case StatusCodes.InvalidPassword: case StatusCodes.UnknownUser: string servername = domainInfo.HostUrl != null ? domainInfo.HostUrl : server; if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { if (password != "") { FormsTrayApp.log.Info("{0}:{1} RetCode: {2}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("failedAuth"), domainInfo.StatusCode); } } simiasWebService.RemoveCertFromTable(servername); break; case StatusCodes.AccountDisabled: if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("accountDisabled")); } break; case StatusCodes.AccountLockout: if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("accountLockout")); } break; case StatusCodes.SimiasLoginDisabled: if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("iFolderAccountDisabled")); } break; case StatusCodes.UnknownDomain: if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("unknownDomain"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("unknownDomain")); } break; default: if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("serverConnectError")); } break; } } catch (Exception ex) { if (ex.Message.Contains("logging to old server")) { MyMessageBox box = new MyMessageBox(resourceManager.GetString("Upgrade.Text"), resourceManager.GetString("Upgrade.Title"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); box.StartPosition = FormStartPosition.CenterScreen; switch (box.ShowDialog()) { case DialogResult.OK: case DialogResult.Cancel: return false; } } if ((ex.Message.IndexOf("Simias.ExistsException") != -1) || (ex.Message.IndexOf("already exists") != -1)) { if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("alreadyJoined"), resourceManager.GetString("alreadyJoinedTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("alreadyJoinedTitle"), resourceManager.GetString("alreadyJoined")); } } else if (!httpsConnect && (ex.Message.IndexOf("InvalidOperationException") != -1)) { if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp)) { server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString(); } else { UriBuilder ub = new UriBuilder(server); ub.Scheme = Uri.UriSchemeHttps; server = ub.ToString(); } httpsConnect = true; result = initialConnect(); } else { if (!autoAccountEnabled) { BeginInvoke(displayMessageDelegate, new object[] { resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 }); messageEvent.WaitOne(); FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectError"), ex.Message); } else { FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("serverConnectError")); } } } return result; }
private bool authenticate() { bool result = false; Cursor.Current = Cursors.WaitCursor; try { DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password.Text); Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath); MyMessageBox mmb; switch (authStatus.statusCode) { case StatusCodes.InvalidCertificate: byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host); System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray); mmb = new MyMessageBox(string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2); if (mmb.ShowDialog() == DialogResult.Yes) { simiasWebService.StoreCertificate(byteArray, domainInfo.Host); result = authenticate(); } break; case StatusCodes.Success: case StatusCodes.SuccessInGrace: if (authStatus.statusCode.Equals(StatusCodes.SuccessInGrace)) { mmb = new MyMessageBox( string.Format(resourceManager.GetString("graceLogin"), authStatus.RemainingGraceLogins), resourceManager.GetString("graceLoginTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information); mmb.ShowDialog(); } try { updateStarted = FormsTrayApp.CheckForClientUpdate(domainInfo.ID); } catch { } if (rememberPassword.Checked) { try { simiasWebService.SetDomainCredentials(domainInfo.ID, password.Text, CredentialType.Basic); } catch (Exception ex) { mmb = new MyMessageBox(resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); } } result = true; break; case StatusCodes.InvalidCredentials: case StatusCodes.InvalidPassword: case StatusCodes.UnknownUser: mmb = new MyMessageBox(resourceManager.GetString("badPassword"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); break; case StatusCodes.AccountDisabled: mmb = new MyMessageBox(resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); break; case StatusCodes.AccountLockout: mmb = new MyMessageBox(resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); break; case StatusCodes.SimiasLoginDisabled: mmb = new MyMessageBox(resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); break; default: mmb = new MyMessageBox(string.Format(resourceManager.GetString("serverReconnectError"), authStatus.statusCode.ToString()), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); break; } } catch (Exception ex) { MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error); mmb.ShowDialog(); } Cursor.Current = Cursors.Default; return result; }
static void Main(string[] args) { Console.WriteLine("Welcome to Neko \r\n", Console.ForegroundColor = ConsoleColor.Green); Console.ResetColor(); Console.Write(@" _ \`*-. ) _`-. . : `. . : _ ' \ ; *` _. `*-._ `-.- ' `-. ; ` `. :. . \ . \ . : .-' . ' `+.; ; ' : : ' | ; ;-. ; ' : :`-: _.`* ; .* ' / .*'; .*`-+' `*' `*-* `*-* `*-*' "); Console.WriteLine("\r\n\r\nThis is a tool designed for various pen-testing activities on the local machine and remote machines if Active Directory components are selected.", Console.ForegroundColor = ConsoleColor.Magenta); Console.ResetColor(); bool infoConfirmed = false; // Attempt to get domain information GetDomainInfo.DomainAuthentication(); while (infoConfirmed == false) { Console.WriteLine("\r\nWill you be using any Active Directory components, such as LDAP recon, remote registry, or lateral movement via WMI? \r\n\r\nEnter 'y' or 'n':"); string adCheck = Console.ReadLine(); while (adCheck != "y" && adCheck != "n") { Console.WriteLine("\r\nInvalid selection. Enter 'y' or 'n':"); adCheck = Console.ReadLine(); } // Check if authentication to AD is required if (adCheck == "y") { if (DomainAuthentication.Authenticate() == true) { break; } } else if (adCheck == "n") { // Information verified proceeding to next step. infoConfirmed = true; } } // Get attack type AttackType.Selection(); bool done = false; while (!done) { // See if user wants to go back to main menu or exit Console.WriteLine("\r\n" + "Enter 'm' for Main Menu or 'e' for exit:"); string mainMenu = Console.ReadLine(); while (mainMenu != "m" && mainMenu != "e") { Console.WriteLine("Invalid selection. Enter 'm' for Main Menu or 'e' for exit:"); mainMenu = Console.ReadLine(); } if (mainMenu == "e") { done = true; } // Send user back to main menu if (mainMenu == "m") { // Clear console Console.Clear(); // Reset attack type AttackType.attackType = null; // Get attack type again AttackType.Selection(); } } }