示例#1
0
        public override bool Connect()
        {
            try
            {
                this.Dock = DockStyle.Fill;
                string           url      = UrlConverter.ExtractAbsoluteUrl(this.Favorite);
                IGuardedSecurity security = this.ResolveFavoriteCredentials();

                if (!String.IsNullOrEmpty(security.UserName) && !String.IsNullOrEmpty(security.Password))
                {
                    string securityValues    = string.Format("{0}: {1}", security.UserName, security.Password);
                    string securityHeader    = Convert.ToBase64String(Encoding.ASCII.GetBytes(securityValues));
                    string additionalHeaders = string.Format("Authorization: Basic {0}{1}", securityHeader, Environment.NewLine);
                    this.browser.Navigate(url, additionalHeaders);
                }
                else
                {
                    this.browser.Navigate(url);
                }

                this.BringToFront();
                this.browser.BringToFront();
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to HTTP", exc);
                return(false);
            }
            return(true);
        }
示例#2
0
        private void ConfigureSecurity(RdpOptions rdpOptions)
        {
            if (rdpOptions.Security.EnableTLSAuthentication)
            {
                this.client.AdvancedSettings5.AuthenticationLevel = 2;
            }

            this.nonScriptable.EnableCredSspSupport = rdpOptions.Security.EnableNLAAuthentication;

            var audioMode = (int)rdpOptions.Redirect.Sounds;

            this.client.SecuredSettings2.AudioRedirectionMode = (audioMode >= 0 && audioMode <= 2) ? audioMode : 0;

            IGuardedSecurity security = this.ResolveFavoriteCredentials();

            this.client.UserName = security.UserName;
            this.client.Domain   = security.Domain;
            try
            {
                if (!String.IsNullOrEmpty(security.Password))
                {
                    if (this.nonScriptable != null)
                    {
                        this.nonScriptable.ClearTextPassword = security.Password;
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Error("Error when trying to set the ClearTextPassword on the nonScriptable mstsc object", exc);
            }
        }
示例#3
0
        public void OnlyDefaultPassword_ResolveCredentials_ReturnsDefaultPassword()
        {
            FilePersistedTestLab.SetDefaultFileLocations();
            Settings.Instance.DefaultPassword = PASSWORD;
            IGuardedSecurity result  = this.ResolveCredentials(original);
            const string     MESSAGE = "If no values are defined in stored password or credentials, they are resolved from default settings.";

            Settings.Instance.DefaultPassword = string.Empty;
            Assert.AreEqual(PASSWORD, result.Password, MESSAGE);
        }
示例#4
0
        public void CredentialSet_ResolveCredentials_ReturnsCredentialValues()
        {
            ICredentialSet credential = this.SetupCredential();

            original.Credential = credential.Id;
            IGuardedSecurity result  = this.ResolveCredentials(original);
            const string     MESSAGE = "When credential set is defined, its pasword is used to connect.";

            Assert.AreEqual(credential.EncryptedPassword, result.EncryptedPassword, MESSAGE);
        }
示例#5
0
        private void ToTsgwOptions(FavoriteConfigurationElement source, TsGwOptions destination, IGuardedCredentialFactory credentialsFactory)
        {
            destination.CredentialSource = source.TsgwCredsSource;
            destination.HostName         = source.TsgwHostname;
            destination.SeparateLogin    = source.TsgwSeparateLogin;
            destination.UsageMethod      = source.TsgwUsageMethod;

            IGuardedSecurity securityOptoins = credentialsFactory.CreateSecurityOptoins(destination.Security);

            securityOptoins.Domain = source.TsgwDomain;
            destination.Security.EncryptedPassword = source.TsgwEncryptedPassword;
            securityOptoins.UserName = source.TsgwUsername;
        }
示例#6
0
        public override Boolean Connect()
        {
            String protocol = "unknown";

            try
            {
                Logging.Info(String.Format("Connecting to a {0} Connection", Favorite.Protocol));
                term = new TerminalEmulator();

                Controls.Add(term);
                term.BringToFront();
                this.BringToFront();

                term.Parent = this.Parent;
                term.Dock   = System.Windows.Forms.DockStyle.Fill;

                ConsoleOptions consoleOptions = this.GetConsoleOptionsFromFavorite();
                AssignTerminalCollors(consoleOptions);
                term.Font    = FontParser.FromString(consoleOptions.Font);
                term.Rows    = consoleOptions.Rows;
                term.Columns = consoleOptions.Columns;

                this.client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                this.client.Connect(Favorite.ServerName, Favorite.Port);

                IGuardedSecurity security = this.ResolveFavoriteCredentials();
                switch (Favorite.Protocol)
                {
                case TelnetConnectionPlugin.TELNET:
                {
                    protocol = ConfigureTelnetConnection(security);
                }
                break;

                case SshConnectionPlugin.SSH:
                {
                    protocol = ConfigureSshConnection(security);
                }
                break;
                }

                this.term.Focus();
                return(true);
            }
            catch (Exception exc)
            {
                Logging.Fatal(String.Format("Connecting to {0} Connection", protocol), exc);
                LastError = exc.Message;
                return(false);
            }
        }
示例#7
0
        private void ConfigureTsGateway(RdpOptions rdpOptions)
        {
            // Terminal Server Gateway Settings
            this.client.TransportSettings.GatewayUsageMethod = (uint)rdpOptions.TsGateway.UsageMethod;
            this.client.TransportSettings.GatewayCredsSource = (uint)rdpOptions.TsGateway.CredentialSource;
            this.client.TransportSettings.GatewayHostname    = rdpOptions.TsGateway.HostName;
            var tsgwGuarded = this.CredentialFactory.CreateCredential(rdpOptions.TsGateway.Security);

            this.client.TransportSettings2.GatewayDomain             = tsgwGuarded.Domain;
            this.client.TransportSettings2.GatewayProfileUsageMethod = 1;
            var security             = this.ResolveTransportGatewayCredentials(rdpOptions);
            IGuardedSecurity guarded = this.CredentialFactory.CreateSecurityOptoins(security);

            this.client.TransportSettings2.GatewayUsername = guarded.UserName;
            this.client.TransportSettings2.GatewayPassword = guarded.Password;
        }
示例#8
0
        private string ConfigureTelnetConnection(IGuardedSecurity security)
        {
            TcpProtocol    tcpProtocol = new TcpProtocol(new NetworkStream(this.client));
            TelnetProtocol p           = new TelnetProtocol();

            tcpProtocol.OnDataIndicated += p.IndicateData;
            tcpProtocol.OnDisconnect    += this.OnDisconnected;
            p.TerminalType             = this.term.TerminalType;
            p.Username                 = security.UserName;
            p.Password                 = security.Password;
            p.OnDataIndicated         += this.term.IndicateData;
            p.OnDataRequested         += tcpProtocol.RequestData;
            this.term.OnDataRequested += p.RequestData;
            this.connected             = this.client.Connected;

            return(TelnetConnectionPlugin.TELNET);
        }
示例#9
0
        private void LaunchPutty()
        {
            this.puttyProcess = new Process();
            this.puttyProcess.StartInfo.FileName = this.GetPuttyBinaryPath();

            IGuardedSecurity credentials = this.ResolveFavoriteCredentials();

            this.puttyProcess.StartInfo.Arguments   = new ArgumentsBuilder(credentials, this.Favorite).Build();
            this.puttyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;

            this.puttyProcess.Start();
            this.puttyProcess.WaitForInputIdle();

            this.AdjustWindowStyle(this.puttyProcess.MainWindowHandle);
            Methods.SetParent(this.puttyProcess.MainWindowHandle, this.Handle);

            this.windowCaptured = true;

            this.ClipPutty();
        }
示例#10
0
        public override bool Connect()
        {
            try
            {
                vmrc = new AxVMRCClientControl();
                Controls.Add(vmrc);
                vmrc.BringToFront();
                this.BringToFront();
                vmrc.Parent = this.Parent;

                vmrc.ServerAddress = Favorite.ServerName;
                vmrc.ServerPort    = Favorite.Port;
                IGuardedSecurity resolved = this.ResolveFavoriteCredentials();
                vmrc.UserName     = resolved.UserName;
                vmrc.UserDomain   = resolved.Domain;
                vmrc.UserPassword = resolved.Password;

                var options = this.Favorite.ProtocolProperties as VMRCOptions;
                vmrc.AdministratorMode = options.AdministratorMode;
                vmrc.ReducedColorsMode = options.ReducedColorsMode;

                Size size = DesktopSizeCalculator.GetSize(this, Favorite);
                //vmrc.ServerDisplayHeight = size.Height;
                //vmrc.ServerDisplayWidth = size.Width;

                vmrc.OnStateChanged    += new _IVMRCClientControlEvents_OnStateChangedEventHandler(vmrc_OnStateChanged);
                vmrc.OnSwitchedDisplay += new _IVMRCClientControlEvents_OnSwitchedDisplayEventHandler(vmrc_OnSwitchedDisplay);

                Text = "Connecting to VMRC Server...";
                vmrc.Connect();
                //vmrc.BringToFront();
                //vmrc.Update();
                return(true);
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to VMRC", exc);
                return(false);
            }
        }
示例#11
0
        private string ConfigureSshConnection(IGuardedSecurity security)
        {
            this.sshProtocol = new SSHClient.Protocol();
            this.sshProtocol.setTerminalParams(term.TerminalType, term.Rows, term.Columns);
            this.sshProtocol.OnDataIndicated += term.IndicateData;
            this.sshProtocol.OnDisconnect    += this.OnDisconnected;
            term.OnDataRequested             += this.sshProtocol.RequestData;

            String           key              = String.Empty;
            var              options          = this.Favorite.ProtocolProperties as SshOptions;
            KeyConfigElement keyConfigElement = this.Settings.SSHKeys.Keys[options.CertificateKey];

            if (keyConfigElement != null)
            {
                key = keyConfigElement.Key;
            }

            this.sshProtocol.setProtocolParams(options.AuthMethod, security.UserName, security.Password, key, options.SSH1, options.SSHKeyFile);

            this.sshProtocol.Connect(client);
            this.connected = true; // SSH will throw if fails
            return((options.SSH1) ? "SSH1" : "SSH2");
        }
示例#12
0
        private void LaunchPutty()
        {
            this.puttyProcess = new Process();
            this.puttyProcess.StartInfo.FileName = GetPuttyBinaryPath();

            IGuardedSecurity credentials = this.ResolveFavoriteCredentials();
            string           arguments   = new ArgumentsBuilder(credentials, this.Favorite).Build();

            // security issue: password visible in taskbar
            this.puttyProcess.StartInfo.Arguments   = arguments;
            this.puttyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            this.puttyProcess.EnableRaisingEvents   = true;
            this.puttyProcess.Exited += this.PuttyProcessOnExited;
            this.puttyProcess.Start();
            this.puttyProcess.WaitForInputIdle();

            IntPtr puttyWindow = this.puttyProcess.MainWindowHandle;

            this.AdjustWindowStyle(puttyWindow);
            Methods.SetParent(puttyWindow, this.Handle);
            this.windowCaptured = true;

            this.ClipPutty();
        }
示例#13
0
        protected IGuardedSecurity ResolveFavoriteCredentials()
        {
            IGuardedSecurity security = this.CredentialFactory.CreateSecurityOptoins(this.Favorite.Security);

            return(security.GetResolvedCredentials());
        }
示例#14
0
        public override bool Connect()
        {
            try
            {
                iIcaClient = new AxICAClient();
                ((Control)iIcaClient).DragEnter += new DragEventHandler(ICAConnection_DragEnter);
                ((Control)iIcaClient).DragDrop  += new DragEventHandler(ICAConnection_DragDrop);
                iIcaClient.OnDisconnect         += new EventHandler(iIcaClient_OnDisconnect);
                iIcaClient.Dock = DockStyle.Fill;


                Controls.Add(iIcaClient);

                IGuardedSecurity resolved = this.ResolveFavoriteCredentials();

                //rd.SendSpecialKeys(VncSharp.SpecialKeys);
                iIcaClient.Parent = this.Parent;
                iIcaClient.Dock   = DockStyle.Fill;

                iIcaClient.Address = Favorite.ServerName;
                switch (Favorite.Display.Colors)
                {
                case Colors.Bit16:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                case Colors.Bits32:
                    iIcaClient.SetProp("DesiredColor", "32");
                    break;

                case Colors.Bits8:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                default:
                    iIcaClient.SetProp("DesiredColor", "24");
                    break;
                }
                //             iIcaClient.Application = "Terminals " + Program.TerminalsVersion.ToString();

                // This line causes the following misleading error.
                // To log on to this remote computer, you must have Terminal Server User Access permissions on this computer.
                // By default, members of the Remote Desktop Users group have these permissions. If you are not a member of the
                // Remote Desktop Users group or another group that has these permissions, or if the Remote Desktop User group
                // does not have these permissions, you must be granted these permissions manually."

                ICAOptions icaOptions = this.Favorite.ProtocolProperties as ICAOptions;
                iIcaClient.AppsrvIni   = icaOptions.ServerINI;
                iIcaClient.WfclientIni = icaOptions.ClientINI;
                iIcaClient.Encrypt     = icaOptions.EnableEncryption;
                string encryptLevel   = "Encrypt";
                string specifiedLevel = icaOptions.EncryptionLevel.Trim();
                if (specifiedLevel.Contains(" "))
                {
                    encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (encryptLevel != "")
                    {
                        iIcaClient.EncryptionLevelSession = encryptLevel;
                    }
                }



                iIcaClient.Domain   = resolved.Domain;
                iIcaClient.Address  = Favorite.ServerName;
                iIcaClient.Username = resolved.UserName;
                iIcaClient.SetProp("ClearPassword", resolved.Password);
                if (icaOptions.ApplicationName != "")
                {
                    iIcaClient.ConnectionEntry = icaOptions.ApplicationName;
                    iIcaClient.InitialProgram  = icaOptions.ApplicationName;
                    iIcaClient.Application     = icaOptions.ApplicationPath;
                    iIcaClient.WorkDirectory   = icaOptions.ApplicationWorkingFolder;
                }


                Text = "Connecting to ICA Server...";

                iIcaClient.Visible = true;

                iIcaClient.SetProp("ScalingMode", "3");
                iIcaClient.Launch          = false;
                iIcaClient.TransportDriver = "TCP/IP";
                iIcaClient.Connect();
                iIcaClient.Focus();


                return(true);
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to ICA", exc);
                return(false);
            }
        }
示例#15
0
 public ArgumentsBuilder(IGuardedSecurity credentials, IFavorite favorite)
 {
     this.credentials = credentials;
     this.favorite    = favorite;
 }