internal bool IsSessionKey(string msg) { try { string decryptedMessage = RSAModule.DecryptStringToString(msg); string[] segments = decryptedMessage.Split(':'); if (ServerCore.DebugMode) { Console.WriteLine ("Session Key Received From Client [{1}]", decryptedMessage, ClientId); } InitializeAesModule(segments[0], segments[1]); return(true); } catch (Exception e) { Console.WriteLine("[Error]: Unable To Handle Session Key!"); Console.WriteLine(e.ToString()); DisposeOfClientAndConnection(); return(false); } }
private static void InitializeModules() { RsaKeysLoaded = RSAModule.QueryRsa(); m_AesModule = new AesModule(); m_AesModule.InitializeProviderFromFile(); MySqlConnector.InitializeMySqlPasswordFromEncrypted(); MySqlConnection SqlConnection = MySqlConnector.InitializeMySqlConnection(); if (SqlConnection != null) { SqlConnection.Dispose(); Console.WriteLine ("Mysql Database Connection Sucessful.."); } }
internal static void InitializeMySqlPasswordFromEncrypted() { try { string decryptedPassword = RSAModule.DecryptStringToString(password); Console.WriteLine("Mysql Database Password Decrypted.."); connectionData = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD="******";"; } catch (Exception e) { Console.WriteLine(e.ToString()); } }
private static void LoopReadInput() { while ((m_ServerCommand = Console.ReadLine()).ToLowerInvariant() != m_TerminationCommand) { if (m_ServerCommand.IndexOf("decrsa") != -1) { RSAModule.ParseDecryptCommand(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("encrsa") != -1) { RSAModule.ParseEncryptCommand(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("decaes") != -1) { m_AesModule.ParseDecryptCommand(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("encaes") != -1) { m_AesModule.ParseEncryptCommand(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("crtacct") != -1) { AccountDatabaseHandler.CreateAccountFromConsole(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("getsalt") != -1) { AccountDatabaseHandler.GetUserSaltFromConsole(m_ServerCommand); continue; } else if (m_ServerCommand.IndexOf("auth") != -1) { AccountDatabaseHandler.ChallengeAuthenticationFromConsole(m_ServerCommand); continue; } switch (m_ServerCommand.ToLowerInvariant()) { case "count": { Console.WriteLine ("Number Of Authorized Clients Connected: {0}", ClientManager.ClientCount); break; } case "debug": { if (DebugMode) { Console.WriteLine("Debug Mode Disabled."); DebugMode = false; } else { Console.WriteLine("Debug Mode Enabled."); DebugMode = true; } break; } case "genrsa": { Task.Run(() => { RSAModule.GenerateNewRsaKeys(); Console.WriteLine("New Rsa Keys Generated.."); }); break; } case "outrsa": { Task.Run(() => { RSAModule.OutputCurrentRsaKeys(); Console.WriteLine("Current Rsa Keys Cached.."); }); break; } case "genaes": { Task.Run(() => { m_AesModule.GenerateProviderAndOutput(); Console.WriteLine("Aes Key And Vector Generated.."); }); break; } case "threadinfo": { Diagnostics.OutputThreadCountData(); break; } case "allthreads": { Diagnostics.OutputIndividualThreadData(); break; } default: Console.WriteLine("Invalid Command, Please Enter Valid Input."); break; } } ; }