Esempio n. 1
0
        public RemoteComputer(Socket _clientSocket)
        {
            clientSocket = _clientSocket;
            AES          = new AesCryptoServiceProvider();
            AES.GenerateKey();
            AES.GenerateIV();

            byte[] data = new byte[1000];

            int lengthOfMessage = clientSocket.Receive(data);

            MessageEncrypt.EncryptAndSendAESKey(clientSocket, data, AES, lengthOfMessage);

            lengthOfMessage = clientSocket.Receive(data);
            ComputerName    = CommandMessage.GetNameFromByte(data, lengthOfMessage);
            ComputerName    = MessageEncrypt.AESDecrypt(ComputerName, AES);

            lengthOfMessage = clientSocket.Receive(data);
            ComputerUser    = CommandMessage.GetNameFromByte(data, lengthOfMessage);
            ComputerUser    = MessageEncrypt.AESDecrypt(ComputerUser, AES);

            lengthOfMessage = clientSocket.Receive(data);
            ClientIP        = CommandMessage.GetNameFromByte(data, lengthOfMessage);
            ClientIP        = MessageEncrypt.AESDecrypt(ClientIP, AES);

            Thread ReciveScreenImageThread = new Thread(ReciveScreenImage);

            ReciveScreenImageThread.IsBackground = true;
            ReciveScreenImageThread.Start(); //запускаем поток
        }
Esempio n. 2
0
        private void ExecuteCommand(byte[] commandBytes, int length)
        {
            commandBytes = MessageEncrypt.AESDecrypt(commandBytes, AES);
            CommandMessage message = new CommandMessage(commandBytes);

            switch (message.CommandType)
            {
            case NetworkCommands.MOUSE_MOVE:
                mouse_event((uint)(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | 0x2000), (uint)message.GetMouseCoordinatesX(), (uint)message.GetMouseCoordinatesY(), 0, 0);
                break;

            case NetworkCommands.MOUSE_LEFTDOWN:
                mouse_event((uint)(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE), (uint)message.GetMouseCoordinatesX(), (uint)message.GetMouseCoordinatesY(), 0, 0);
                break;

            case NetworkCommands.MOUSE_RIGHTDOWN:
                mouse_event((uint)(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_ABSOLUTE), (uint)message.GetMouseCoordinatesX(), (uint)message.GetMouseCoordinatesY(), 0, 0);
                break;

            case NetworkCommands.MOUSE_LEFTUP:
                mouse_event((uint)(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE), (uint)message.GetMouseCoordinatesX(), (uint)message.GetMouseCoordinatesY(), 0, 0);
                break;

            case NetworkCommands.MOUSE_RIGHTUP:
                mouse_event((uint)(MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE), (uint)message.GetMouseCoordinatesX(), (uint)message.GetMouseCoordinatesY(), 0, 0);
                break;

            case NetworkCommands.KEYBOARD_DOWN:
                keybd_event((byte)message.firstParam, (byte)message.secondParam, 1 | 0, (UIntPtr)0);
                break;

            case NetworkCommands.KEYBOARD_UP:
                keybd_event((byte)message.firstParam, (byte)message.secondParam, 1 | 2, (UIntPtr)0);
                break;

            case NetworkCommands.MOUSE_WHEEL_ROTATED:
                if (message.firstParam < 0)
                {
                    mouse_event(0x0800, 0, 0, unchecked ((uint)-150), 0);
                }
                else
                {
                    mouse_event(0x0800, 0, 0, unchecked ((uint)150), 0);
                }
                break;

            case NetworkCommands.RECIVE_FILE:
                ReceiveFile(message.firstParam);
                break;

            case NetworkCommands.STOP_SENDING:
                StopSendingScreen();
                break;

            case NetworkCommands.START_SENDING:
                StartSendingScreen();
                break;

            case NetworkCommands.RUN_FILE:
                RunFile(commandBytes, length);
                break;

            case NetworkCommands.RUN_COMMAND_LINE:
                RunCommandLine();
                break;

            case NetworkCommands.CLOSE_CONNECTION:
                StopSendingScreen();
                ReceiveThread.Abort();
                break;
            }
        }