public void AsIfLoggedInWhenNot() { // Tell program to use test environment ba_createData.Properties.Settings.Default.Test = true; // Start server - server side var serverControl = new MainServerControl(); // ADD REMOTE ACCESS //ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true; var clientConnection = new TcpClient(); clientConnection.Connect(IpAddress, 3000); var clientStream = new SslStream(clientConnection.GetStream(), false, ValidateServerCertificate, null); var serverCertificate = X509Certificate.CreateFromCertFile(Thread.GetDomain().BaseDirectory + "\\rolandio.cer"); var certificates = new X509CertificateCollection(new[] { serverCertificate }); clientStream.AuthenticateAsClient(IpAddress, certificates, SslProtocols.Default, false); // We now ask the server if we are logged in and ready to communicate SendMessageToServer(clientStream, "AM I ACTIVE\r\n"); Assert.AreEqual(GetMessageFromServer(clientStream), "801"); }
public bool LoginTheClient() { // Tell program to use test environment ba_createData.Properties.Settings.Default.Test = true; // Databse substring have length 8 ba_createData.Properties.Settings.Default.EncryptionLength = 8; // Start server - server side var serverControl = new MainServerControl(); // ADD REMOTE ACCESS //ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true; var clientConnection = new TcpClient(); clientConnection.Connect(IpAddress, 3000); var clientStream = new SslStream(clientConnection.GetStream(), false, ValidateServerCertificate, null); var serverCertificate = X509Certificate.CreateFromCertFile(Thread.GetDomain().BaseDirectory + "\\rolandio.cer"); var certificates = new X509CertificateCollection(new[] { serverCertificate }); clientStream.AuthenticateAsClient(IpAddress, certificates, SslProtocols.Default, false); // Login procedure var bytesToSend = Encoding.ASCII.GetBytes("LOGIN\r\n"); clientStream.Write(bytesToSend, 0, bytesToSend.Length); // Get Response var loginResponse = GetMessageFromServer(clientStream); if (loginResponse.Trim() == "200 OK") { SendMessageToServer(clientStream, "CLIENT_1027\r\n"); // Get Response var userMessage = GetMessageFromServer(clientStream); if (userMessage.Equals("PASSWORD")) { SendMessageToServer(clientStream, "12345678\r\n"); // Get Response var loginIsAcceptedResponse = GetMessageFromServer(clientStream); if (loginIsAcceptedResponse.Equals("LOGIN 200 OK")) { _loggedInCredentials = clientStream; // Client is logged in } } } // We now ask the server if we are logged in and ready to communicate SendMessageToServer(clientStream, "AM I ACTIVE\r\n"); return(GetMessageFromServer(clientStream).Equals("200 OK")); }
public void LoginToServer() { // Start server var serverControl = new MainServerControl(); // ADD REMOTE ACCESS ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true; var clientConnection = new TcpClient(); clientConnection.Connect("192.168.1.217", 3000); var clientStream = new SslStream(clientConnection.GetStream(), false, ValidateServerCertificate, null); var serverCertificate = X509Certificate.CreateFromCertFile(Thread.GetDomain().BaseDirectory + "rolandio.cer"); var certificates = new X509CertificateCollection(new[] { serverCertificate }); clientStream.AuthenticateAsClient("192.168.1.217", certificates, SslProtocols.Default, false); var bytesToSend = Encoding.ASCII.GetBytes("LOGIN\r\n"); clientStream.Write(bytesToSend, 0, bytesToSend.Length); // Get Response var loginResponse = GetMessageFromServer(clientStream); if (loginResponse.Trim() == "200 OK") { SendMessageToServer(clientStream, "CLIENT_1027\r\n"); // Get Response var userMessage = GetMessageFromServer(clientStream); if (userMessage.Equals("PASSWORD")) { SendMessageToServer(clientStream, "12345678\r\n"); // Get Response var loginIsAcceptedResponse = GetMessageFromServer(clientStream); if (loginIsAcceptedResponse.Equals("LOGIN 200 OK")) { _loggedInCredentials = clientStream; // Simmple test SendMessageToServer(clientStream, "LOOK UP SINGLE HASH\r\n"); var readyForHash = GetMessageFromServer(clientStream); if (readyForHash.Equals("200 OK")) { SendMessageToServer(clientStream, "00f538c3d410822e241486ca061a57ee$\r\n"); var report = GetMessageFromServer(clientStream); } } } } }
public void TestSingleHashRamOnly() { // Tell program to use test environment ba_createData.Properties.Settings.Default.Test = true; // Turn off caching ba_createData.Properties.Settings.Default.UseCashing = false; // Turn on RAM only mode ba_createData.Properties.Settings.Default.UseRAMOnly = true; // Setup memory database // Start server - server side var serverControl = new MainServerControl(); // ADD REMOTE ACCESS //ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true; var clientConnection = new TcpClient(); clientConnection.Connect(IpAddress, 3000); var clientStream = new SslStream(clientConnection.GetStream(), false, ValidateServerCertificate, null); var serverCertificate = X509Certificate.CreateFromCertFile(Thread.GetDomain().BaseDirectory + "\\rolandio.cer"); var certificates = new X509CertificateCollection(new[] { serverCertificate }); clientStream.AuthenticateAsClient(IpAddress, certificates, SslProtocols.Default, false); // We now ask the server if we are logged in and ready to communicate SendMessageToServer(clientStream, "AM I ACTIVE\r\n"); // Load values into memory, this is suitable for servers with loads of RAM ba_createData.Scanner.MemoryDatabase.SuffixArray = Database.GetSuffixArrayTableByPattern('a'); ba_createData.Scanner.MemoryDatabase.LcpArray = Database.GetAllLcpTableContent(); ba_createData.Scanner.MemoryDatabase.TextFile = Database.GetAllTextFromDatabase(); //Assert.AreEqual(GetMessageFromServer(clientStream), "801"); }
public void Server() { textBox6.ForeColor = System.Drawing.Color.Green; textBox6.Text = @"On"; CurrentServer = new MainServerControl(); }