-
Notifications
You must be signed in to change notification settings - Fork 1
/
RecoverNordVPN.cs
65 lines (56 loc) · 2.22 KB
/
RecoverNordVPN.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Xml;
namespace RecoverNordVPN
{
class Program
{
static void Main(string[] args)
{
string commonAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
DirectoryInfo nordFolder = new DirectoryInfo(Path.Combine(commonAppDataFolder, "NordVPN"));
if (!nordFolder.Exists)
{
Console.WriteLine("NordVPN directory not found!");
return;
}
foreach (DirectoryInfo d in nordFolder.GetDirectories("NordVpn.exe*"))
{
Console.WriteLine($"Searching in {d.Name}");
foreach (DirectoryInfo v in d.GetDirectories())
{
Console.WriteLine($"\tFound version {v.Name}");
string userConfigPath = Path.Combine(v.FullName, "user.config");
if (File.Exists(userConfigPath))
{
var doc = new XmlDocument();
doc.Load(userConfigPath);
string encodedUsername = doc.SelectSingleNode("//setting[@name='Username']/value").InnerText;
string encodedPassword = doc.SelectSingleNode("//setting[@name='Password']/value").InnerText;
if(encodedUsername != null && !string.IsNullOrEmpty(encodedUsername))
{
Console.WriteLine($"\t\tUsername: {nordDecode(encodedUsername)}");
}
if (encodedPassword != null && !string.IsNullOrEmpty(encodedPassword))
{
Console.WriteLine($"\t\tPassword: {nordDecode(encodedPassword)}");
}
}
}
}
}
static string nordDecode(string s)
{
try
{
return Encoding.UTF8.GetString(ProtectedData.Unprotect(Convert.FromBase64String(s), null, DataProtectionScope.LocalMachine));
}
catch
{
return "";
}
}
}
}