public string Format(IHostPwEntry hostPwEntry)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("\"{0}\"", RemoteDesktopClientPath);
            sb.AppendFormat(" /v:{0}", hostPwEntry.IPAddress);

            if (this.FullScreen)
            {
                sb.Append(" /f");
            }
            if (this.UseConsole)
            {
                if (this.IsOlderVersion)
                {
                    sb.Append(" /console");
                }
                else
                {
                    sb.Append(" /admin");
                }
            }

            return(sb.ToString());
        }
Exemple #2
0
        public void ChangePassword(IHostPwEntry hostPwEntry, String newPassword)
        {
            var passwordChanger = passwordChangerFactory.Create(this.hostTypeMapper.Get(hostPwEntry));

            passwordChanger.ChangePassword(hostPwEntry, newPassword);
            hostPwEntry.UpdatePassword(newPassword);
        }
        public String Format(IHostPwEntry hostPwEntry)
        {
            PuttyOptions options = null;
            bool         success = PuttyOptions.TryParse(hostPwEntry.AdditionalOptions, out options);

            StringBuilder sb = new StringBuilder(String.Format("\"{0}\" scp://{1}", ExecutablePath, hostPwEntry.GetUsername()));

            if (!success || (success && !options.HasKeyFile()))
            {
                sb.AppendFormat(":\"{0}\"", hostPwEntry.GetPassword());
            }

            sb.AppendFormat("@{0}", hostPwEntry.IPAddress);

            if (success && options.Port.HasValue)
            {
                sb.AppendFormat(":{0}", options.Port);
            }

            // Starting with version 5.6 a passphrase for the private key file can be provided.
            // See: https://winscp.net/eng/docs/faq_passphrase
            if (success && options.HasKeyFile())
            {
                sb.AppendFormat(" -privatekey=\"{0}\" -passphrase=\"{1}\"", options.KeyFilePath, hostPwEntry.GetPassword());
            }

            return(sb.ToString());
        }
Exemple #4
0
        public void ChangePassword(IHostPwEntry hostPwEntry, string newPassword)
        {
            var passwordChanger = passwordChangerFactory.Create(this.hostTypeMapper.Get(hostPwEntry));

            passwordChanger.ChangePassword(hostPwEntry, newPassword);
            hostPwEntry.UpdatePassword(newPassword);
            hostPwEntry.LastModificationTime = this.clock.Now;
        }
Exemple #5
0
 public void ChangePassword(IHostPwEntry hostPwEntry, string newPassword)
 {
     this.passwordChanger.ChangePassword(
         hostPwEntry.IPAddress,
         hostPwEntry.GetUsername(),
         hostPwEntry.GetPassword(),
         newPassword
         );
 }
Exemple #6
0
        public void ChangePassword(IHostPwEntry hostPwEntry, string newPassword)
        {
            PuttyOptions options = null;
            bool         success = PuttyOptionsParser.TryParse(hostPwEntry.AdditionalOptions, out options);

            var passwordChanger = success && options.Port.HasValue ? this.passwordChangerFactory.Create(options.Port.Value) :
                                  this.passwordChangerFactory.Create();

            passwordChanger.ChangePassword(hostPwEntry.IPAddress, hostPwEntry.GetUsername(), hostPwEntry.GetPassword(), newPassword);
        }
Exemple #7
0
        public string Format(IHostPwEntry hostPwEntry)
        {
            StringBuilder sb = new StringBuilder();

            if (this.IncludePath)
            {
                sb.AppendFormat("\"{0}\" ", CmdKeyRegisterArgumentsFormatter.CmdKeyPath);
            }
            sb.AppendFormat("/delete:TERMSRV/{0}", hostPwEntry.IPAddress);
            return(sb.ToString());
        }
Exemple #8
0
 public HostType Get(IHostPwEntry hostPwEntry)
 {
     if (hostPwEntry.HasConnectionMethods)
     {
         return(this.converter.Convert(new List <ConnectionMethodType>(hostPwEntry.ConnectionMethods)[0]));
     }
     else
     {
         return(HostType.Unknown);
     }
 }
Exemple #9
0
        public string Format(IHostPwEntry hostPwEntry)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("\"{0}\"", this.ExecutablePath);
            sb.AppendFormat(" -s {0} -u {1} -p {2}",
                            hostPwEntry.IPAddress,
                            hostPwEntry.GetUsername(),
                            hostPwEntry.GetPassword()
                            );
            return(sb.ToString());
        }
        protected virtual void OnPasswordChangeError(IHostPwEntry hostPwEntry, Exception ex, int index)
        {
            PasswordChangeErrorEventHandler handler = Error;

            if (handler != null)
            {
                handler(this, new BatchPasswordChangerErrorEventArgs(hostPwEntry, ex)
                {
                    ProcessedEntries = index + 1,
                    TotalEntries     = this.entries.Count
                });
            }
        }
        protected virtual void OnPasswordChanged(IHostPwEntry hostPwEntry, int index)
        {
            PasswordChangedEventHandler handler = Changed;

            if (handler != null)
            {
                handler(this, new BatchPasswordChangerEventArgs(hostPwEntry)
                {
                    ProcessedEntries = index + 1,
                    TotalEntries     = this.entries.Count
                });
            }
        }
Exemple #12
0
        public string Format(IHostPwEntry hostPwEntry)
        {
            StringBuilder sb = new StringBuilder();

            if (this.IncludePath)
            {
                sb.AppendFormat("\"{0}\" ", CmdKeyPath);
            }
            sb.AppendFormat("/generic:TERMSRV/{0} /user:{1} /pass:{2}",
                            hostPwEntry.IPAddress,
                            hostPwEntry.GetUsername(),
                            hostPwEntry.GetPassword()
                            );
            return(sb.ToString());
        }
Exemple #13
0
        public FormPasswordChanger(IHostPwEntry hostPwEntry, IPasswordChangerService pwChangerService)
        {
            InitializeComponent();

            this.hostPwEntry      = hostPwEntry;
            this.pwChangerService = pwChangerService;

            this.Text = this.Text.Replace("{}", String.Format("{0}@{1}", hostPwEntry.GetUsername(), hostPwEntry.IPAddress));

            this.maskedTextBoxNewPassword.TextChanged       += new EventHandler(checkPasswords);
            this.maskedTextBoxRepeatNewPassword.TextChanged += new EventHandler(checkPasswords);
            this.maskedTextBoxNewPassword.TextChanged       += new EventHandler(checkControls);
            this.maskedTextBoxRepeatNewPassword.TextChanged += new EventHandler(checkControls);
            this.buttonChangePassword.Enabled = false;

            this.FormClosing += new FormClosingEventHandler(formClosing);
            this.KeyDown     += new KeyEventHandler(form_KeyPress);
        }
Exemple #14
0
        private DisposableList <ToolStripItem> createMenuItems(IHostPwEntry hostPwEntry)
        {
            var menuItems = new DisposableList <ToolStripItem>();

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.RemoteDesktop))
            {
                var menuItem = new ToolStripMenuItem()
                {
                    Text    = OpenRemoteDesktopMenuItemText,
                    Image   = (System.Drawing.Image)QuickConnectPlugin.Properties.Resources.remote,
                    Enabled = hostPwEntry.HasIPAddress
                };

                if (Settings.EnableShortcutKeys == true && Settings.RemoteDesktopShortcutKey != Keys.None)
                {
                    menuItem.ShortcutKeys     = Settings.RemoteDesktopShortcutKey;
                    menuItem.ShowShortcutKeys = true;
                }

                menuItem.Click += new EventHandler(
                    delegate(object obj, EventArgs ev) {
                    try {
                        ProcessUtils.Start(CmdKeyRegisterArgumentsFormatter.CmdKeyPath, new CmdKeyRegisterArgumentsFormatter().Format(hostPwEntry));
                        IArgumentsFormatter argsFormatter = new RemoteDesktopArgumentsFormatter()
                        {
                            FullScreen = true
                        };
                        ProcessUtils.StartDetached(argsFormatter.Format(hostPwEntry));
                        ProcessUtils.StartDetached(new CmdKeyUnregisterArgumentsFormatter()
                        {
                            IncludePath = true
                        }.Format(hostPwEntry), RemoveCredentialsDelay);
                    }
                    catch (Exception ex) {
                        log(ex);
                    }
                }
                    );
                menuItems.Add(menuItem);
            }
            ;

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.RemoteDesktopConsole))
            {
                var menuItem = new ToolStripMenuItem()
                {
                    Text    = OpenRemoteDesktopConsoleMenuItemText,
                    Image   = (System.Drawing.Image)QuickConnectPlugin.Properties.Resources.mycomputer,
                    Enabled = hostPwEntry.HasIPAddress
                };

                menuItem.Click += new EventHandler(
                    delegate(object obj, EventArgs ev) {
                    try {
                        ProcessUtils.Start(CmdKeyRegisterArgumentsFormatter.CmdKeyPath, new CmdKeyRegisterArgumentsFormatter()
                                           .Format(hostPwEntry));
                        IArgumentsFormatter argsFormatter = new RemoteDesktopArgumentsFormatter()
                        {
                            FullScreen     = true,
                            UseConsole     = true,
                            IsOlderVersion = RDCIsOlderVersion
                        };
                        ProcessUtils.StartDetached(argsFormatter.Format(hostPwEntry));
                        ProcessUtils.StartDetached(new CmdKeyUnregisterArgumentsFormatter()
                        {
                            IncludePath = true
                        }.Format(hostPwEntry), RemoveCredentialsDelay);
                    }
                    catch (Exception ex) {
                        log(ex);
                    }
                }
                    );
                menuItems.Add(menuItem);
            }
            ;

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.vSphereClient))
            {
                var vSphereClientPath = QuickConnectUtils.GetVSphereClientPath();
                var menuItem          = new ToolStripMenuItem()
                {
                    Text    = OpenVSphereClientMenuItemText,
                    Image   = (System.Drawing.Image)QuickConnectPlugin.Properties.Resources.vmware,
                    Enabled = hostPwEntry.HasIPAddress && !String.IsNullOrEmpty(vSphereClientPath)
                };
                menuItem.Click += new EventHandler(
                    delegate(object obj, EventArgs ev) {
                    try {
                        IArgumentsFormatter argsFormatter = new VSphereClientArgumentsFormatter(vSphereClientPath);
                        ProcessUtils.StartDetached(argsFormatter.Format(hostPwEntry));
                    }
                    catch (Exception ex) {
                        log(ex);
                    }
                }
                    );
                menuItems.Add(menuItem);
            }
            ;

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.PuttySSH) ||
                hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.PuttyTelnet))
            {
                string puttyPath = null;
                var    menuItem  = new ToolStripMenuItem()
                {
                    Text    = OpenPuttyMenuItemText,
                    Image   = (System.Drawing.Image)QuickConnectPlugin.Properties.Resources.konsole,
                    Enabled = QuickConnectUtils.CanOpenPutty(Settings, hostPwEntry, out puttyPath)
                };

                if (Settings.EnableShortcutKeys == true && Settings.PuttyShortcutKey != Keys.None)
                {
                    menuItem.ShortcutKeys     = Settings.PuttyShortcutKey;
                    menuItem.ShowShortcutKeys = true;
                }

                menuItem.Click += new EventHandler(
                    delegate(object obj, EventArgs ev) {
                    try {
                        var sessionFinder = new RegistryPuttySessionFinder(new WindowsRegistryService());
                        IArgumentsFormatter argsFormatter = new PuttyArgumentsFormatter(puttyPath, sessionFinder, !this.Settings.DisableCLIPasswordForPutty);
                        ProcessUtils.StartDetached(argsFormatter.Format(hostPwEntry));
                    }
                    catch (Exception ex) {
                        log(ex);
                    };
                }
                    );
                menuItems.Add(menuItem);
            }
            ;

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.WinSCP))
            {
                string winScpPath = null;
                var    menuItem   = new ToolStripMenuItem()
                {
                    Text    = OpenWinScpMenuItemText,
                    Image   = (System.Drawing.Image)QuickConnectPlugin.Properties.Resources.winscp,
                    Enabled = QuickConnectUtils.CanOpenWinScp(Settings, hostPwEntry, out winScpPath)
                };

                if (Settings.EnableShortcutKeys == true && Settings.WinScpShortcutKey != Keys.None)
                {
                    menuItem.ShortcutKeys     = Settings.WinScpShortcutKey;
                    menuItem.ShowShortcutKeys = true;
                }

                menuItem.Click += new EventHandler(
                    delegate(object obj, EventArgs ev) {
                    try {
                        IArgumentsFormatter argsFormatter = new WinScpArgumentsFormatter(winScpPath);
                        ProcessUtils.StartDetached(argsFormatter.Format(hostPwEntry));
                    }
                    catch (Exception ex) {
                        log(ex);
                    };
                }
                    );
                menuItems.Add(menuItem);
            }
            ;
            return(menuItems);
        }
 public HostType Get(IHostPwEntry hostPwEntry)
 {
     return(this.HostType);
 }
Exemple #16
0
        public String Format(IHostPwEntry hostPwEntry)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("\"{0}\"", this.ExecutablePath);

            string ipAddress = null;
            string port      = null;

            if (hostPwEntry.IPAddress.Contains(":"))
            {
                ipAddress = hostPwEntry.IPAddress.Substring(0, hostPwEntry.IPAddress.IndexOf(':'));
                port      = hostPwEntry.IPAddress.Substring(hostPwEntry.IPAddress.IndexOf(':') + 1);
            }
            else
            {
                ipAddress = hostPwEntry.IPAddress;
            }

            PuttyOptions options = null;
            bool         success = PuttyOptions.TryParse(hostPwEntry.AdditionalOptions, out options);

            if (success && options.HasKeyFile())
            {
                sb.AppendFormat(" -i \"{0}\"", options.KeyFilePath);
            }

            if (success && !String.IsNullOrEmpty(options.SessionName))
            {
                ICollection <String> sessionNames = this.PuttySessionFinder.Find(options.SessionName);

                if (sessionNames.Count > 0)
                {
                    sb.AppendFormat(" -load \"{0}\"", new List <String>(sessionNames)[0]);
                }
            }

            if (!success || (success && !options.CommandContainsPort))
            {
                if (port != null)
                {
                    sb.AppendFormat(" -P {0}", port);
                }

                if (port == null && success && options.Port.HasValue)
                {
                    sb.AppendFormat(" -P {0}", options.Port);
                }
            }

            if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.PuttySSH))
            {
                sb.Append(" -ssh");
            }
            else if (hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.PuttyTelnet))
            {
                sb.Append(" -telnet");
            }

            sb.AppendFormat(" {0}@{1}", hostPwEntry.GetUsername(), ipAddress);

            // Specifying the password via -pw switch only works with SSH protocol.
            // See: http://the.earth.li/~sgtatham/putty/0.65/htmldoc/Chapter3.html.
            if (this.AppendPassword && hostPwEntry.ConnectionMethods.Contains(ConnectionMethodType.PuttySSH))
            {
                // Allow passwords with white-spaces.
                if (!success || (success && !options.CommandContains("-pw ")))
                {
                    var password = hostPwEntry.GetPassword();

                    if (password.Contains(@""""))
                    {
                        sb.AppendFormat(" -pw \"{0}\"", password.Replace(@"""", @"\"""));
                    }
                    else
                    {
                        sb.AppendFormat(" -pw \"{0}\"", password);
                    }
                }
            }

            if (success && options.HasCommand())
            {
                sb.AppendFormat(" {0}", options.Command);
            }

            return(sb.ToString());
        }
Exemple #17
0
 public BatchPasswordChangerErrorEventArgs(IHostPwEntry hostPwEntry, Exception ex)
 {
     this.HostPwEntry = hostPwEntry;
     this.Exception   = ex;
 }
Exemple #18
0
 internal static bool CanOpenWinScp(IQuickConnectPluginSettings settings, IHostPwEntry hostPwEntry, out string winScpPath)
 {
     winScpPath = !String.IsNullOrEmpty(settings.WinScpPath) ? settings.WinScpPath : QuickConnectUtils.GetWinScpPath();
     return(hostPwEntry.HasIPAddress && !String.IsNullOrEmpty(winScpPath));
 }
Exemple #19
0
 internal static bool CanOpenPutty(IQuickConnectPluginSettings settings, IHostPwEntry hostPwEntry, out string puttyPath)
 {
     puttyPath = !String.IsNullOrEmpty(settings.PuttyPath) ? settings.PuttyPath : QuickConnectUtils.GetPuttyPath();
     return(hostPwEntry.HasIPAddress && !String.IsNullOrEmpty(puttyPath));
 }
 public void ChangePassword(IHostPwEntry hostPwEntry, string newPassword)
 {
     passwordChanger.ChangePassword(hostPwEntry.IPAddress, hostPwEntry.GetUsername(), hostPwEntry.GetPassword(), newPassword);
     hostPwEntry.UpdatePassword(newPassword);
     hostPwEntry.LastModificationTime = this.clock.Now;
 }
Exemple #21
0
 public BatchPasswordChangerEventArgs(IHostPwEntry hostPwEntry)
 {
     this.HostPwEntry = hostPwEntry;
 }
 public void ChangePassword(IHostPwEntry hostPwEntry, string newPassword)
 {
     this.ChangePasswordCount++;
 }