Exemplo n.º 1
0
        public static void AutoSearch(Archive archive, FsTree tree)
        {
            ILookup <int, string> lookup = Hash.AllHashStrings.Values.ToLookup(x => x.Length, x => x);

            FsNode[] unknownNodes = tree.EnumerateEntries().Where(x => x.NameText == null).ToArray();

            using (var progress = new ProgressBar())
            {
                progress.SetTotal(unknownNodes.Length);

                foreach (var node in unknownNodes)
                {
                    int length = GetHashLength(node.NameHash);
                    if (node.Type == EntryType.File)
                    {
                        length -= GetHashLength(node.ExtensionHash) + 1;
                    }

                    string text = $"{node.ParentText}/%s{(node.Type == EntryType.File ? $".{node.ExtensionText}" : "")}";

                    //progress.LogMessage($"{length}, {text}");
                    foreach (var str in lookup[length])
                    {
                        Hash.AddHashIfExists(text.Replace("%s", str), false, progress);
                    }

                    progress.ReportAdd(1);
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: program.exe data.arc");
                return;
            }

            if (!File.Exists("hashstrings.txt"))
            {
                Console.WriteLine("Could not find hashstrings.txt in the current directory");
                return;
            }

            using (var file = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                // string[] subs = File.ReadAllLines("sub.txt");

                Hash.LoadHashes("hashstrings.txt");
                var archive = new Archive(file);

                //ExtractAll(archive);

                //using (var progress = new ProgressBar())
                //{
                //    archive.ExtractFile(args[1], "files", progress);
                //}

                var tree = new FsTree(archive);
                //var entries = tree.EnumerateEntries().Select(x => x.NameText).Where(x => x != null).Distinct().OrderBy(x => x).ToArray();
                var entries = tree.EnumerateEntries().Select(x => x.DisplayPathText).ToArray();
                // var unkHashes = tree.EnumerateEntries().Where(x => x.NameText == null).Select(x => x.NameHash).Distinct().OrderBy(x => x).Select(FsTree.GetHashText).ToArray();
                File.WriteAllLines("file list.txt", entries);
                //File.WriteAllLines("unknown hashes.txt", unkHashes);
                // tree.ValidateNames();

                // File.WriteAllLines("search_stringsF.txt", tree.GetSearchStrings());

                // LoadDump3("hashstrings.txt");
                //LoadDump3("toimport.txt");
                //LoadDump3("new hashes.txt");

                // LoadDump3("comparcstrings2.txt");
                //LoadDump3("comparcstrings67.txt");
                //LoadDump3("dump.txt");
                // SearchTreeStrings(tree);
                // GetDecimalFormatStrings();
                //GetStringFormatStrings(archive);
                //GetStringFormatStringsFromFile(archive, "search_strings.txt");

                // FindArcStrings(archive);

                //AutoSearch(archive, tree);
                // FindNewStrings(archive);
                // RemoveBadHashes(archive);
                // ExportHashes(archive);
                ExtractAll(archive);
            }
        }
Exemplo n.º 3
0
        public static void SearchTreeStrings(FsTree tree)
        {
            var strings       = Hash.AllHashStrings.Values.ToLookup(x => x.Length);
            var formatStrings = tree.GetSearchStrings().ToArray();

            using (var progress = new ProgressBar())
            {
                progress.SetTotal(formatStrings.Length);

                foreach ((string text, int length) in formatStrings)
                {
                    foreach (string str2 in strings[length])
                    {
                        Hash.AddHashIfExists(text.Replace("%s", str2), false, progress);
                    }

                    progress.ReportAdd(1);
                }
            }
        }