Пример #1
0
        //class Hashes
        //{
        //    public string[] install;
        //    public string[] encoding;
        //}

        static void Main(string[] args)
        {
            //HashSet<string> data = new HashSet<string>();
            //HashSet<string> installs = new HashSet<string>();

            //using (StreamReader sr = new StreamReader("list.txt"))
            //{
            //    string line1;

            //    while((line1 = sr.ReadLine()) != null)
            //    {
            //        data.Add(line1.Substring(19, 32));

            //        if (line1.Contains("install"))
            //        {
            //            installs.Add(line1.Substring(93, 32));
            //        }
            //    }
            //}

            ////foreach (var cfg in data)
            ////{
            ////    string url = string.Format("https://bnet.marlam.in/tpr/wow/config/{0}/{1}/{2}", cfg.Substring(0, 2), cfg.Substring(2, 2), cfg);

            ////    var stream = CDNIndexHandler.OpenFileDirect(url);

            ////    using (var fileStream = File.Create("builds\\" + cfg))
            ////    {
            ////        stream.CopyTo(fileStream);
            ////    }
            ////}

            //Dictionary<string, Hashes> data2 = new Dictionary<string, Hashes>();

            //foreach (var file in Directory.GetFiles("builds"))
            //{
            //    using(var sr = new StreamReader(file))
            //    {
            //        string line;

            //        while ((line = sr.ReadLine()) != null)
            //        {
            //            if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) // skip empty lines and comments
            //                continue;

            //            string[] tokens = line.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);

            //            if (tokens.Length != 2)
            //                throw new Exception("KeyValueConfig: tokens.Length != 2");

            //            var values = tokens[1].Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            //            var valuesList = values.ToList();

            //            if (!data2.ContainsKey(file))
            //                data2[file] = new Hashes();

            //            if (values[0] == "install")
            //            {
            //                data2[file].install = values;
            //            }

            //            if (values[0] == "encoding")
            //            {
            //                data2[file].encoding = values;
            //            }

            //            //sr.Data.Add(tokens[0].Trim(), valuesList);
            //        }
            //    }
            //}

            //Dictionary<string, string> realInstalls = new Dictionary<string, string>();

            //foreach(var kv in data2)
            //{
            //    for(int i = 6; i < kv.Value.install.Length; i++)
            //    {
            //        if (installs.Contains(kv.Value.install[i]))
            //        {
            //            //Console.WriteLine("{0} {1}", kv.Value.install[i], kv.Value.encoding[i]);

            //            realInstalls[kv.Value.install[i]] = kv.Value.encoding[i];
            //        }
            //    }
            //}

            //CASCConfig.ValidateData = false;

            //int buildIndex = 0;

            //foreach (var kvinstall in realInstalls)
            //{
            //    string url1 = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", kvinstall.Key.Substring(0, 2), kvinstall.Key.Substring(2, 2), kvinstall.Key);

            //    BLTEStream instFile = new BLTEStream(CDNIndexHandler.OpenFileDirect(url1), new MD5Hash());

            //    InstallHandler install = new InstallHandler(new BinaryReader(instFile), null);

            //    //foreach(var ent  in install.GetEntries().Where(e => e.Name.Contains("MacOS")))
            //    //{
            //    //    Console.WriteLine(ent.Name);
            //    //}
            //    //continue;

            //    string url2 = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", kvinstall.Value.Substring(0, 2), kvinstall.Value.Substring(2, 2), kvinstall.Value);

            //    BLTEStream encFile = new BLTEStream(CDNIndexHandler.OpenFileDirect(url2), new MD5Hash());

            //    EncodingHandler encoding = new EncodingHandler(new BinaryReader(encFile), null);

            //    string[] files = new string[] { "WowB.exe", "WowT.exe", "Wow.exe", "WowB-64.exe", "WowT-64.exe", "Wow-64.exe", "RenderService.exe", "RenderService-64.exe",
            //        @"World of Warcraft Public Test.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Public Test.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Beta.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Beta.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Retail.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft Retail.app\Contents\MacOS\World of Warcraft 64",
            //        @"World of Warcraft Test.app\Contents\MacOS\World of Warcraft",
            //        @"World of Warcraft.app\Contents\MacOS\World of Warcraft"
            //    };

            //    string outFolder = "build_" + buildIndex++;

            //    foreach (var file in files)
            //    {
            //        var entries = install.GetEntriesByName(file);

            //        foreach (var entry in entries)
            //        {
            //            bool ok = encoding.GetEntry(entry.MD5, out var encEntry);

            //            if (ok)
            //            {
            //                string chash = encEntry.Key.ToHexString().ToLower();

            //                Console.WriteLine("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2} {3}", chash.Substring(0, 2), chash.Substring(2, 2), chash, file);

            //                string url = string.Format("http://blzddist1-a.akamaihd.net/tpr/wow/data/{0}/{1}/{2}", chash.Substring(0, 2), chash.Substring(2, 2), chash);
            //                //string url = string.Format("http://bnet.marlamin.com/tpr/wow/data/{0}/{1}/{2}", chash.Substring(0, 2), chash.Substring(2, 2), chash);

            //                try
            //                {
            //                    var stream = CDNIndexHandler.OpenFileDirect(url);

            //                    BLTEStream blte3 = new BLTEStream(stream, new MD5Hash());

            //                    string outFile = Path.Combine(outFolder, chash + "_" + file);
            //                    string outDir = Path.GetDirectoryName(outFile);

            //                    if (!Directory.Exists(outDir))
            //                        Directory.CreateDirectory(outDir);

            //                    using (var fileStream = File.Create(outFile))
            //                    {
            //                        blte3.CopyTo(fileStream);
            //                    }
            //                }
            //                catch(Exception exc)
            //                {
            //                    Console.WriteLine(exc.Message);
            //                }
            //            }
            //        }
            //    }
            //}

            //ArmadilloCrypt crypt = new ArmadilloCrypt("sc1Dev");

            //var decr = crypt.DecryptFile(@"c:\Users\TOM_RUS\Downloads\e32f46c7245bfc154e43924555a5cf9f");

            //File.WriteAllBytes("test", decr);

            //byte[] keyBytes = new byte[16];

            //ArmadilloCrypt crypt = new ArmadilloCrypt(keyBytes);

            //string buildconfigfile = "9f6048f8bd01f38ec0be83f4a9fe5a10";

            //byte[] data = File.ReadAllBytes(buildconfigfile);

            //byte[] IV = buildconfigfile.Substring(16).ToByteArray();

            //unsafe
            //{
            //    fixed (byte* ptr = keyBytes)
            //    {
            //        for (ulong i = 0; i < ulong.MaxValue; i++)
            //        {
            //            for (ulong j = 0; j < ulong.MaxValue; j++)
            //            {
            //                byte[] decrypted = crypt.DecryptFile(IV, data);

            //                if (decrypted[0] == 0x23 && decrypted[1] == 0x20 && decrypted[2] == 0x42 && decrypted[3] == 0x75)
            //                {
            //                    Console.WriteLine("key found: {0} {1} ?", i, j);
            //                }

            //                *(ulong*)ptr = j;

            //                if (j % 1000000 == 0)
            //                    Console.WriteLine("{0}/{1}", j, ulong.MaxValue);
            //            }

            //            *(ulong*)(ptr + 8) = i;
            //        }
            //    }
            //}

            if (args.Length != 5)
            {
                Console.WriteLine("Invalid arguments count!");
                Console.WriteLine("Usage: CASCConsole <mode> <pattern|listfile> <destination> <localeFlags> <overrideArchive>");
                return;
            }

            Console.WriteLine("Settings:");
            Console.WriteLine("    WowPath: {0}", Settings.Default.StoragePath);
            Console.WriteLine("    OnlineMode: {0}", Settings.Default.OnlineMode);

            Console.WriteLine("Loading...");

            BackgroundWorkerEx bgLoader = new BackgroundWorkerEx();

            bgLoader.ProgressChanged += BgLoader_ProgressChanged;

            //CASCConfig.LoadFlags |= LoadFlags.Install;

            CASCConfig config = Settings.Default.OnlineMode
                ? CASCConfig.LoadOnlineStorageConfig(Settings.Default.Product, "us")
                : CASCConfig.LoadLocalStorageConfig(Settings.Default.StoragePath, Settings.Default.Product);

            CASCHandler cascHandler = CASCHandler.OpenStorage(config, bgLoader);

            string      mode            = args[0];
            string      pattern         = args[1];
            string      dest            = args[2];
            LocaleFlags locale          = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), args[3]);
            bool        overrideArchive = bool.Parse(args[4]);

            cascHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.csv"), bgLoader);
            CASCFolder root = cascHandler.Root.SetFlags(locale, overrideArchive);

            //cascHandler.Root.MergeInstall(cascHandler.Install);

            Console.WriteLine("Loaded.");

            Console.WriteLine("Extract params:");
            Console.WriteLine("    Mode: {0}", mode);
            Console.WriteLine("    Pattern/Listfile: {0}", pattern);
            Console.WriteLine("    Destination: {0}", dest);
            Console.WriteLine("    LocaleFlags: {0}", locale);
            Console.WriteLine("    OverrideArchive: {0}", overrideArchive);

            if (mode == "pattern")
            {
                Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

                foreach (var file in CASCFolder.GetFiles(root.Entries.Select(kv => kv.Value)))
                {
                    if (wildcard.IsMatch(file.FullName))
                    {
                        ExtractFile(cascHandler, file.Hash, file.FullName, dest);
                    }
                }
            }
            else if (mode == "listfile")
            {
                if (cascHandler.Root is WowRootHandler wowRoot)
                {
                    char[] splitChar = new char[] { ';' };

                    var names = File.ReadLines(pattern).Select(s => s.Split(splitChar, 2)).Select(s => new { id = int.Parse(s[0]), name = s[1] });

                    foreach (var file in names)
                    {
                        ExtractFile(cascHandler, wowRoot.GetHashByFileDataId(file.id), file.name, dest);
                    }
                }
                else
                {
                    var names = File.ReadLines(pattern);

                    foreach (var file in names)
                    {
                        ExtractFile(cascHandler, 0, file, dest);
                    }
                }
            }

            Console.WriteLine("Extracted.");
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Invalid arguments count!");
                Console.WriteLine("Usage: CASCConsole <pattern> <destination> <localeFlags> <contentFlags>");
                return;
            }

            Console.WriteLine("Settings:");
            Console.WriteLine("    WowPath: {0}", Settings.Default.StoragePath);
            Console.WriteLine("    OnlineMode: {0}", Settings.Default.OnlineMode);

            Console.WriteLine("Loading...");

            BackgroundWorkerEx bgLoader = new BackgroundWorkerEx();

            bgLoader.ProgressChanged += BgLoader_ProgressChanged;

            CASCConfig config = Settings.Default.OnlineMode
                ? CASCConfig.LoadOnlineStorageConfig(Settings.Default.Product, "us")
                : CASCConfig.LoadLocalStorageConfig(Settings.Default.StoragePath);

            CASCHandler cascHandler = CASCHandler.OpenStorage(config, bgLoader);

            string       pattern = args[0];
            string       dest    = args[1];
            LocaleFlags  locale  = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), args[2]);
            ContentFlags content = (ContentFlags)Enum.Parse(typeof(ContentFlags), args[3]);

            cascHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.txt"), bgLoader);
            CASCFolder root = cascHandler.Root.SetFlags(locale, content);

            Console.WriteLine("Loaded.");

            Console.WriteLine("Extract params:", pattern, dest, locale);
            Console.WriteLine("    Pattern: {0}", pattern);
            Console.WriteLine("    Destination: {0}", dest);
            Console.WriteLine("    LocaleFlags: {0}", locale);
            Console.WriteLine("    ContentFlags: {0}", content);

            Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

            foreach (var file in root.GetFiles())
            {
                if (wildcard.IsMatch(file.FullName))
                {
                    Console.Write("Extracting '{0}'...", file.FullName);

                    try
                    {
                        cascHandler.SaveFileTo(file.FullName, dest);
                        Console.WriteLine(" Ok!");
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(" Error!");
                        Logger.WriteLine(exc.Message);
                    }
                }
            }

            Console.WriteLine("Extracted.");
        }
Пример #3
0
        static void Main(string[] args)
        {
            //byte[] keyBytes = new byte[16];

            //ArmadilloCrypt crypt = new ArmadilloCrypt(keyBytes);

            //string buildconfigfile = "9f6048f8bd01f38ec0be83f4a9fe5a10";

            //byte[] data = File.ReadAllBytes(buildconfigfile);

            //byte[] IV = buildconfigfile.Substring(16).ToByteArray();

            //unsafe
            //{
            //    fixed (byte* ptr = keyBytes)
            //    {
            //        for (ulong i = 0; i < ulong.MaxValue; i++)
            //        {
            //            for (ulong j = 0; j < ulong.MaxValue; j++)
            //            {
            //                byte[] decrypted = crypt.DecryptFile(IV, data);

            //                if (decrypted[0] == 0x23 && decrypted[1] == 0x20 && decrypted[2] == 0x42 && decrypted[3] == 0x75)
            //                {
            //                    Console.WriteLine("key found: {0} {1} ?", i, j);
            //                }

            //                *(ulong*)ptr = j;

            //                if (j % 1000000 == 0)
            //                    Console.WriteLine("{0}/{1}", j, ulong.MaxValue);
            //            }

            //            *(ulong*)(ptr + 8) = i;
            //        }
            //    }
            //}

            if (args.Length != 4)
            {
                Console.WriteLine("Invalid arguments count!");
                Console.WriteLine("Usage: CASCConsole <pattern> <destination> <localeFlags> <contentFlags>");
                return;
            }

            Console.WriteLine("Settings:");
            Console.WriteLine("    WowPath: {0}", Settings.Default.StoragePath);
            Console.WriteLine("    OnlineMode: {0}", Settings.Default.OnlineMode);

            Console.WriteLine("Loading...");

            BackgroundWorkerEx bgLoader = new BackgroundWorkerEx();

            bgLoader.ProgressChanged += BgLoader_ProgressChanged;

            //CASCConfig.LoadFlags |= LoadFlags.Install;

            CASCConfig config = Settings.Default.OnlineMode
                ? CASCConfig.LoadOnlineStorageConfig(Settings.Default.Product, "us")
                : CASCConfig.LoadLocalStorageConfig(Settings.Default.StoragePath);

            CASCHandler cascHandler = CASCHandler.OpenStorage(config, bgLoader);

            string       pattern = args[0];
            string       dest    = args[1];
            LocaleFlags  locale  = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), args[2]);
            ContentFlags content = (ContentFlags)Enum.Parse(typeof(ContentFlags), args[3]);

            cascHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.txt"), bgLoader);
            CASCFolder root = cascHandler.Root.SetFlags(locale, content);

            //cascHandler.Root.MergeInstall(cascHandler.Install);

            Console.WriteLine("Loaded.");

            Console.WriteLine("Extract params:");
            Console.WriteLine("    Pattern: {0}", pattern);
            Console.WriteLine("    Destination: {0}", dest);
            Console.WriteLine("    LocaleFlags: {0}", locale);
            Console.WriteLine("    ContentFlags: {0}", content);

            Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

            foreach (var file in CASCFolder.GetFiles(root.Entries.Select(kv => kv.Value)))
            {
                if (wildcard.IsMatch(file.FullName))
                {
                    Console.Write("Extracting '{0}'...", file.FullName);

                    try
                    {
                        cascHandler.SaveFileTo(file.FullName, dest);
                        Console.WriteLine(" Ok!");
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(" Error!");
                        Logger.WriteLine(exc.Message);
                    }
                }
            }

            Console.WriteLine("Extracted.");
        }