Beispiel #1
0
        static void RealServiceTestTCP(bool install)
        {
            string IP_SERVER_ADDRESS = "127.0.0.1";
            int    PORT = 8976;

            if (install)
            {
                if (Bolter.NonAdmin.IsInAdministratorMode())
                {
                    Admin.InstallService();
                }
                else
                {
                    throw new InvalidOperationException("Need the demo to be in Admin mode to install the service");
                }
            }

            var client = new ReceiverClient();

            client.ConnectToBolterService(IP_SERVER_ADDRESS, PORT);
            // client.SendMessage("First_msg");
            // client.SendMessage("2nd_msg");
            // client.SendMessage("last msg");
            // client.SendMessage("2nd_msg_2");
            int LOGON32_LOGON_BATCH             = 4; // DOESNT WORK
            int LOGON32_LOGON_NETWORK           = 3;
            int LOGON32_LOGON_INTERACTIVE       = 2;
            int LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
            int LOGON32_LOGON_SERVICE           = 5;
            int type = LOGON32_LOGON_INTERACTIVE;

            client.RequestImpersonation(type);
            Thread.Sleep(5000);
            client.RequestSetBatchAndCMDBlock(true);

            //client.WaitAndPrintResponse();
            // client.SendToService("{ \"name\":\"SetBatchAndCMDBlock\",\"block\":false}");
            ///client.SendToService("Last msg");
            // client.RequestSetBatchAndCMDBlock(false);
            // client.RequestSetBatchAndCMDBlock(true);

            // Auto free
            var timer = new System.Timers.Timer(20000);

            timer.Elapsed += (s, e) =>
            {
                // Reconnect test
                // client.RequestDisableAllAdminRestrictions(AppDomain.CurrentDomain.BaseDirectory);
                client.SendMessage("Hello");
                Thread.Sleep(3000);
                client.SendMessage("Hello2");
                if (install)
                {
                    Admin.UninstallService();
                }
            };
            timer.AutoReset = false;
            timer.Start();
        }
Beispiel #2
0
        private static void TcpAdminBridgeTest()
        {
            var tcpClient = new ReceiverClient();
            // TODO relative paths
            var bridgePath     = @"C:\Users\franc\source\repos\Bolter\BridgeProcess\bin\Debug\netcoreapp3.1\BridgeProcess.exe";
            var mockServiceApp = @"C:\Users\franc\source\repos\Bolter\MockService\bin\Debug\netcoreapp3.1\MockService.exe";

            tcpClient.ConnectToBolterService(IP_SERVER_ADDRESS, PORT);

            // Info commands
            tcpClient.SendMessage("unblocksqdsqd");
            tcpClient.SendMessage("ooo");
            tcpClient.RequestInstallService();
            Console.ReadLine();
            Bolter.NonAdmin.DisableAllNonAdminRestrictions();
            tcpClient.RequestDisableAllAdminRestrictions(AppDomain.CurrentDomain.BaseDirectory);
        }