private void WriteVersion(string version)
        {
            var rc4 = new RC4(Encoding.UTF8.GetBytes(User.GetKoiId()));
            var buf = Encoding.UTF8.GetBytes(version);

            rc4.Crypt(buf, 0, buf.Length);
            File.WriteAllBytes(Path.Combine(privPath, "VERSION"), buf);
        }
        private void Pack()
        {
            logger.Info("Obfuscating...");

            var proj = new ConfuserProject();

            foreach (var file in Directory.GetFiles(privPath).OrderByDescending(x => x).Where(x => x.EndsWith(".exe") || x.EndsWith(".dll")))
            {
                proj.Add(new ProjectModule {
                    Path = file
                });
            }
#if DEBUG || __TRACE
            proj.OutputDirectory = Path.Combine(privPath.Trim('\\'), "Confused");
#else
            proj.OutputDirectory = privPath;
#endif
            proj.Debug         = true;
            proj.BaseDirectory = privPath;
            proj.ProbePaths.Add(binPath);
            proj.PluginPaths.Add(Path.Combine(binPath, "KoiVM.Confuser.exe"));

            var parameters = new Cr.ConfuserParameters();
            parameters.Project = proj;
            parameters.Logger  = logger;
            Cr.ConfuserEngine.Run(parameters).Wait();

            logger.Info("Packing...");
            using (var stream = new MemoryStream())
            {
                var rc4 = new RC4(Convert.FromBase64String("S29pVk0gaXMgYfD4Da3V0ZSEhIQ=="));//S29pVk0gaXMgY3V0ZSEhIQ==
                using (var deflate = new DeflateStream(stream, CompressionMode.Compress))
                    using (var writer = new BinaryWriter(deflate))
                    {
#if DEBUG || __TRACE
                        var fileList = Directory.GetFiles(@"C:\Users\Nybher\Desktop\koiVM\Debug\bin\pub\ann\");
#else
                        var fileList = Directory.GetFiles(privPath, "*.dll");
#endif

                        writer.Write(fileList.Length);
                        foreach (var file in fileList)
                        {
                            var fileBuf = File.ReadAllBytes(file);
                            writer.Write(fileBuf.Length);
                            writer.Write(fileBuf);
#if !DEBUG && !__TRACE
                            File.Delete(file);
#endif
                        }
                    }
                var buf = stream.ToArray();
                rc4.Crypt(buf, 0, buf.Length);
                File.WriteAllBytes(Path.Combine(privPath, "koi.pack"), buf);

                WriteVersion(version);
            }
        }
Exemplo n.º 3
0
        private void RefreshList()
        {
            lstUsers.Items.Clear();
            foreach (var user in userList)
            {
                var    verPath = Path.Combine(Path.Combine(txtPubPath.Text, user.GetKoiId()), "VERSION");
                string ver;
                if (File.Exists(verPath))
                {
                    var data = File.ReadAllBytes(verPath);
                    var rc4  = new RC4(Encoding.UTF8.GetBytes(user.GetKoiId()));
                    rc4.Crypt(data, 0, data.Length);
                    ver = Encoding.UTF8.GetString(data);
                }
                else
                {
                    ver = "<< Missing >>";
                }

                var item = new ListViewItem();
                item.Tag = user;
                item.UseItemStyleForSubItems = false;
                item.Text = user.Watermark.ToString("x8");
                item.SubItems.Add(user.ID.ToString("x8"));
                item.SubItems.Add(user.SubscriptionEnd.ToShortDateString());
                item.SubItems.Add(user.Status.ToString());
                item.SubItems.Add(ver);
                item.SubItems.Add(user.UserName);
                item.SubItems.Add(user.Email);
                item.SubItems.Add("");
                foreach (ListViewItem.ListViewSubItem subItem in item.SubItems)
                {
                    subItem.Font = monoFont;
                }

                lstUsers.Items.Add(item);
            }
            txtDep.Text = userList.DeployDir;
        }