Beispiel #1
0
        public void StartRemoteCLI()
        {
            if (_client.Connected)
            {
                using (DataStringPacket _packet = new DataStringPacket(_stream))
                {
                    _packet.data = Convert.ToString(Console.BufferWidth);
                    _packet.SendPacket(_aes);
                    _packet.ReceivePacket(_aes);
                    CLIOutput.WriteToConsole(_packet.data + "\n");
                }

                using (CLIPacket _cliP = new CLIPacket(_stream))
                {
                    _cliP.serverAnswer = "";

                    while (true)
                    {
                        // write cursor
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write(cursor);
                        Console.ForegroundColor = ConsoleColor.White;

                        // read input
                        _cliInput = CLIInput.ReadInput(cursor.Length);

                        if (_cliInput != "")
                        {
                            _cliP.consoleWidth = Console.BufferWidth;
                            _cliP.cliInput     = _cliInput;
                            _cliP.SendPacket(_aes);

                            _cliP.ReceivePacket(_aes);

                            if (_cliP.serverAnswer == "EXIT_CLI")
                            {
                                break;
                            }

                            CLIOutput.WriteToConsole(_cliP.serverAnswer + "\n");
                        }
                    }
                }
            }
            else
            {
                throw new Exception("Not connected!");
            }
        }
Beispiel #2
0
        public void Start()
        {
            using (DataStringPacket _packet = new DataStringPacket(_stream))
            {
                _packet.ReceivePacket(_aes);
                _packet.data = GetBanner(System.Convert.ToInt32(_packet.data));
                _packet.SendPacket(_aes);
            }

            using (CLIPacket _cliP = new CLIPacket(_stream))
            {
                Command _command = null;

                while (true)
                {
                    _cliP.ReceivePacket(_aes);
                    _cliP.serverAnswer = CLIInterpreter(ref _command, _cliP.cliInput);

                    try
                    {
                        if (_cliP.serverAnswer == "VALID_PARAMETERS")
                        {
                            _cliP.serverAnswer = _command.Execute(_cliP.consoleWidth);
                        }
                    }
                    catch (Exception e)
                    {
                        _cliP.serverAnswer = e.Message;
                    }

                    _cliP.SendPacket(_aes);

                    if (_cliP.serverAnswer == "EXIT_CLI")
                    {
                        break;
                    }
                }
            }
        }