private async Task <int> AsarExtract()
        {
            Append("Extracting core.asar");

            var asarArchive   = new AsarArchive($"{_asarPath}\\core.asar");
            var asarExtractor = new AsarExtractor();

            asarExtractor.FileExtracted += (s, e) => {
                _synchronizationContext.Post(o => {
                    pbStatus.Value = (int)((AsarExtractEvent)o).Progress;
                }, e);
                Append(e.File.Path, true);
            };

            asarExtractor.Finished += (s, e) => {
                Append($"Finished extracting core.asar");
            };

            try {
                if (!Directory.Exists($"{_asarPath}\\app"))
                {
                    Directory.CreateDirectory($"{_asarPath}\\core");
                }
                await asarExtractor.ExtractAll(asarArchive, $"{_asarPath}\\core\\");
            }
            catch (Exception e) {
                Debug.Print(e.Message);
            }

            return(1);
        }
Exemple #2
0
        private void DeleteDirs()
        {
            Thread t = new Thread(() =>
            {
                String dir = GetParent().DiscordPath + "\\resources\\app";

                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                dir = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord";


                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Moving BetterDiscord to resources\\node_modules\\");

                Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord");

                AppendLog("Extracting app.asar");

                AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar");

                AsarExtractor extractor = new AsarExtractor();
                extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\");

                Splice();
            });


            t.Start();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            AsarArchive   asarArhive = new AsarArchive("D:\\Downloads\\app.asar");
            AsarExtractor extractor  = new AsarExtractor();

            extractor.ExtractAll(asarArhive, "G:\\Asardotnet\\out\\");

            // extractor.Extract(asarArhive, "app/index.js", "G:\\Asardotnet\\out\\index.js");

            // AsarExtractor extractor = new AsarExtractor();
            // extractor.Extract(asarArhive, "NotificationWindow.js", "");

            // AsarExtractor asarExtractor = new AsarExtractor();

            //asarExtractor.Extract(asarArhive, "G:\\Asardotnet\\extract\\");

            // asarExtractor.ExtractFile(asarArhive, 8528, 6479);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var arch = new AsarArchive($"{TestPath}core.asar");

            var extractor = new AsarExtractor();

            extractor.FileExtracted += (s, e) => {
                Console.WriteLine(e.Progress);
            };

            extractor.Finished += (s, e) => {
                Console.WriteLine("ALL DONE!");
            };

            Task.Run(() => extractor.ExtractAll(arch, $"{TestPath}test\\", true));
            //extractor.ExtractAll(arch, TestPath + "hi\\");

            Console.ReadLine();
        }
        private void DeleteDirs()
        {
            int errors = 0;
            Thread t = new Thread(() =>
            {
                String dir = GetParent().DiscordPath + "\\resources\\app";

                if (Directory.Exists(dir))
                {
                    try
                    {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                    }
                    catch
                    {
                        AppendLog("Error Failed to Delete the '" + dir + "\\resources\\app' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                dir = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord";

                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Moving BetterDiscord to resources\\node_modules\\");

                Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord");

                try
                {
                    AppendLog("Extracting app.asar");
                    AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar");

                    AsarExtractor extractor = new AsarExtractor();
                    //Add extraoffset of 3
                    extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\", 3);

                    Splice();
                }
                catch
                {
                    AppendLog("Error Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }
            });

            t.Start();
        }
        private void PatchBTN_Click(object sender, EventArgs e)
        {
            if (File.Exists($"{AppPath}\\app.asar"))
            {
                try
                {
                    IO.CopyFolder($"{AppPath}\\app.asar.unpacked\\", $"{AppPath}\\app\\");
                    var asar      = new AsarArchive($"{AppPath}\\app.asar");
                    var extractor = new AsarExtractor();
                    extractor.ExtractAll(asar, $"{AppPath}\\app\\", true);
                }
                catch (IOException)
                {
                    MessageBox.Show("There seems to be a problem!");
                    return;
                }

                if (EasyListCB.Checked)
                {
                    new WebClient().DownloadFile("https://easylist.to/easylist/easylist.txt", $"{AppPath}\\app\\src\\easylist.txt");
                }
                if (EasyPrivacyCB.Checked)
                {
                    new WebClient().DownloadFile("https://easylist.to/easylist/easyprivacy.txt", $"{AppPath}\\app\\src\\easyprivacy.txt");
                }
                if (UBlockAdsCB.Checked)
                {
                    new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt", $"{AppPath}\\app\\src\\ublock-ads.txt");
                }
                if (UBlockPrivacyCB.Checked)
                {
                    new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt", $"{AppPath}\\app\\src\\ublock-privacy.txt");
                }
                if (PeterLoweCB.Checked)
                {
                    new WebClient().DownloadFile("https://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblock&showintro=1&mimetype=plaintext", $"{AppPath}\\app\\src\\peter-lowe-list.txt");
                }

                var fileToPatch = $"{AppPath}\\app\\src\\createWindow.js";
                //create a backup file
                File.Copy(fileToPatch, fileToPatch + ".bak");

                // copy adblocker lib to src
                File.WriteAllBytes($"{AppPath}\\app\\src\\adblocker.umd.min.js", Encoding.UTF8.GetBytes(Resources.adblocker_umd_min));

                // start writing our payload to createWindow.js
                IO.ModifyFileAtLine("session: true,", fileToPatch, 106);

                IO.ModifyFileAtLine(JS.FilterEngine, fileToPatch, 119);

                // optional features
                if (BlitzNoUpdateCB.Checked)
                {
                    IO.ModifyFileAtLine("if (false) {", $"{AppPath}\\app\\src\\index.js", 267);
                }
                if (BlitzAutoGuestCB.Checked)
                {
                    IO.ModifyFileAtLine(JS.AutoGuest, $"{AppPath}\\app\\src\\preload.js", 18);
                }

                MessageBox.Show("Patch Completed");
            }
            else
            {
                MessageBox.Show("app.asar not found!");
            }
        }
        static void Main(string[] args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            bool noupdate  = false;
            bool autoguest = false;

            foreach (string arg in args)
            {
                if (arg.ToLower() == "-noupdate")
                {
                    Console.WriteLine("Disabling Blitz auto update...");
                    noupdate = true;
                }
                if (arg.ToLower() == "-autoguest")
                {
                    Console.WriteLine("Enabling auto sign in as guest...");
                    autoguest = true;
                }
            }

            if (File.Exists($"{appPath}\\app.asar"))
            {
                Console.WriteLine("app.asar found!");

                try {
                    Console.WriteLine("Extracting...");
                    CopyFolder($"{appPath}\\app.asar.unpacked\\", $"{appPath}\\app\\");
                    var asar      = new AsarArchive($"{appPath}\\app.asar");
                    var extractor = new AsarExtractor();
                    extractor.ExtractAll(asar, $"{appPath}\\app\\", true);
                } catch (IOException) {
                    Console.WriteLine("Error extracting files! Make sure Blitz app is closed before trying again.");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("Downloading ad & tracking filters...");
                new WebClient().DownloadFile("https://easylist.to/easylist/easylist.txt", $"{appPath}\\app\\src\\easylist.txt");
                new WebClient().DownloadFile("https://easylist.to/easylist/easyprivacy.txt", $"{appPath}\\app\\src\\easyprivacy.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt", $"{appPath}\\app\\src\\ublock-ads.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt", $"{appPath}\\app\\src\\ublock-privacy.txt");
                new WebClient().DownloadFile("https://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblock&showintro=1&mimetype=plaintext", $"{appPath}\\app\\src\\peter-lowe-list.txt");

                Console.WriteLine("Patching...");
                string fileToPatch = $"{appPath}\\app\\src\\createWindow.js";

                // copy adblocker lib to src
                File.WriteAllBytes($"{appPath}\\app\\src\\adblocker.umd.min.js", Encoding.UTF8.GetBytes(Resources.adblocker_umd_min));

                // start writing our payload to createWindow.js
                ModifyFileAtLine("session: true,", fileToPatch, 106);
                ModifyFileAtLine(

                    "try {" +
                    "const fs = require('fs');" +
                    "const { FiltersEngine, Request} = require('./adblocker.umd.min.js');" +
                    "const filters = " +
                    "fs.readFileSync(require.resolve('./easylist.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./easyprivacy.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./ublock-ads.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./ublock-privacy.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./peter-lowe-list.txt'), 'utf-8') + '\\ngoogleoptimize.com\\n';" +
                    "const engine = FiltersEngine.parse(filters);" +

                    "windowInstance.webContents.session.webRequest.onBeforeRequest({ urls:['*://*/*']}, (details, callback) => {" +
                    "const { match } = engine.match(Request.fromRawDetails({ url: details.url}));" +
                    "if (match == true) {" +
                    "log.info('BLOCKED:', details.url);" +
                    "callback({cancel: true});" +
                    "} else {" +
                    "callback({cancel: false});" +
                    "}" +
                    "});" +
                    "} catch (error) {" +
                    "log.error(error);" +
                    "}"

                    , fileToPatch, 119);

                // optional features
                if (noupdate)
                {
                    ModifyFileAtLine("if (false) {", $"{appPath}\\app\\src\\index.js", 267);
                }
                if (autoguest)
                {
                    ModifyFileAtLine(

                        "autoGuest();" +
                        "function autoGuest() {" +
                        "var buttons = document.getElementsByTagName('button');" +
                        "for (var i = 0; i < buttons.length; i++) {" +
                        "if (buttons[i].getAttribute('label') == 'Login As Guest') {" +
                        "buttons[i].click();" +
                        "return;" +
                        "}" +
                        "}" +
                        "setTimeout(autoGuest, 1000);" +
                        "}"

                        , $"{appPath}\\app\\src\\preload.js", 18);
                }

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Patching complete! GLHF :)");
            }
            else
            {
                Console.WriteLine("app.asar not found!");
            }
            Console.ReadKey();
        }
Exemple #8
0
        private void DeleteDirs()
        {
            int    errors = 0;
            Thread t      = new Thread(() =>
            {
                String dir = GetParent().DiscordPath + "\\resources\\app";

                if (Directory.Exists(dir))
                {
                    try
                    {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                    }
                    catch
                    {
                        AppendLog("Error Failed to Delete the '" + dir + "\\resources\\app' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                dir = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord";


                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Moving BetterDiscord to resources\\node_modules\\");

                Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord");

                try
                {
                    AppendLog("Extracting app.asar");
                    AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar");

                    AsarExtractor extractor = new AsarExtractor();
                    extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\");

                    Splice();
                }
                catch
                {
                    AppendLog("Error Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }
            });


            t.Start();
        }
        static void Main(string[] args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            var noupdate  = false;
            var autoguest = false;

            foreach (var arg in args)
            {
                switch (arg.ToLower())
                {
                case "-noupdate":
                    Console.WriteLine("Disabling Blitz auto update...");
                    noupdate = true;
                    break;

                case "-autoguest":
                    Console.WriteLine("Enabling auto sign in as guest...");
                    autoguest = true;
                    break;
                }
            }

            if (File.Exists($"{AppPath}\\app.asar"))
            {
                Console.WriteLine("app.asar found!");

                try {
                    Console.WriteLine("Extracting...");
                    IO.CopyFolder($"{AppPath}\\app.asar.unpacked\\", $"{AppPath}\\app\\");
                    var asar      = new AsarArchive($"{AppPath}\\app.asar");
                    var extractor = new AsarExtractor();
                    extractor.ExtractAll(asar, $"{AppPath}\\app\\", true);
                } catch (IOException) {
                    Console.WriteLine("Error extracting files! Make sure Blitz app is closed before trying again.");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("Downloading ad & tracking filters...");
                new WebClient().DownloadFile("https://easylist.to/easylist/easylist.txt", $"{AppPath}\\app\\src\\easylist.txt");
                new WebClient().DownloadFile("https://easylist.to/easylist/easyprivacy.txt", $"{AppPath}\\app\\src\\easyprivacy.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt", $"{AppPath}\\app\\src\\ublock-ads.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt", $"{AppPath}\\app\\src\\ublock-privacy.txt");
                new WebClient().DownloadFile("https://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblock&showintro=1&mimetype=plaintext", $"{AppPath}\\app\\src\\peter-lowe-list.txt");

                Console.WriteLine("Patching...");
                var fileToPatch = $"{AppPath}\\app\\src\\createWindow.js";

                // copy adblocker lib to src
                File.WriteAllBytes($"{AppPath}\\app\\src\\adblocker.umd.min.js", Encoding.UTF8.GetBytes(Resources.adblocker_umd_min));

                // start writing our payload to createWindow.js
                IO.ModifyFileAtLine("session: true,", fileToPatch, 106);

                IO.ModifyFileAtLine(JS.FilterEngine, fileToPatch, 119);

                // optional features
                if (noupdate)
                {
                    IO.ModifyFileAtLine("if (false) {", $"{AppPath}\\app\\src\\index.js", 267);
                }
                if (autoguest)
                {
                    IO.ModifyFileAtLine(JS.AutoGuest, $"{AppPath}\\app\\src\\preload.js", 18);
                }

                Console.WriteLine("\r\n Patching complete! GLHF :)");
            }
            else
            {
                Console.WriteLine("app.asar not found!");
            }
            Console.ReadKey();
        }
Exemple #10
0
        private void DeleteDirs()
        {
            int errors = 0;
            Thread t = new Thread(() => {
                string dir = $"{GetParent().DiscordPath}\\resources\\app";

                if(Directory.Exists(dir)) {
                    try {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                    } catch {
                        AppendLog($"Error: Failed to Delete the '{dir}\\resources\\app' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }

                while(Directory.Exists(dir)) {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                if (!Directory.Exists($"{GetParent().DiscordPath}\\resources\\node_modules\\")) {
                    Debug.Print("node_modules doesn't exist, creating");
                    AppendLog("node_modules doesn't exist, creating");
                    Directory.CreateDirectory($"{GetParent().DiscordPath}\\resources\\node_modules\\");
                }

                dir = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";

                if(Directory.Exists(dir)) {
                    AppendLog($"Deleting {dir}");
                    Directory.Delete(dir, true);
                }

                while(Directory.Exists(dir)) {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Extracting app.asar");
                string appAsarPath = $"{GetParent().DiscordPath}\\resources\\app.asar";

                if(File.Exists(appAsarPath)) {
                    AsarArchive archive = new AsarArchive(appAsarPath);
                    AsarExtractor extractor = new AsarExtractor();
                    extractor.ExtractAll(archive, $"{GetParent().DiscordPath}\\resources\\app\\");
                } else {
                    AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }

                if(errors == 0) {
                    AppendLog("Moving BetterDiscord to resources\\node_modules\\");
                    Directory.Move($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\BetterDiscordApp-stable16", $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord");

                    try {
                        Splice();
                    } catch {
                        AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                        errors = 1;
                        Finalize(errors);
                    }
                }
            });

            t.Start();
        }
Exemple #11
0
        private void DeleteDirs()
        {
            Thread t = new Thread(() =>
            {
                String dir = GetParent().DiscordPath + "\\resources\\app";

                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                dir = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord";


                if (Directory.Exists(dir))
                {
                    AppendLog("Deleting " + dir);
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Moving BetterDiscord to resources\\node_modules\\");

                Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord");

                AppendLog("Extracting app.asar");

                AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar");

                AsarExtractor extractor = new AsarExtractor();
                extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\");

                Splice();
            });
            
            
            t.Start();
        }
Exemple #12
0
        private void DeleteDirs()
        {
            int    errors = 0;
            Thread t1     = new Thread(() => {
                string dir = $"{GetParent().DiscordPath}\\resources\\app";

                if (Directory.Exists(dir))
                {
                    try {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                    } catch {
                        AppendLog($"Error: Failed to Delete the '{dir}\\resources\\app' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }
                //C:\Users\Zack\AppData\Roaming\discordcanary
                if (!Directory.Exists($"{GetParent().DiscordPath}\\resources\\node_modules\\"))
                {
                    Debug.Print("node_modules doesn't exist, creating");
                    AppendLog("node_modules doesn't exist, creating");
                    Directory.CreateDirectory($"{GetParent().DiscordPath}\\resources\\node_modules\\");
                }

                dir = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";


                if (Directory.Exists(dir))
                {
                    AppendLog($"Deleting {dir}");
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Extracting app.asar");
                string appAsarPath = $"{GetParent().DiscordPath}\\resources\\app.asar";

                if (File.Exists(appAsarPath))
                {
                    AsarArchive archive     = new AsarArchive(appAsarPath);
                    AsarExtractor extractor = new AsarExtractor();
                    extractor.ExtractAll(archive, $"{GetParent().DiscordPath}\\resources\\app\\");
                }
                else
                {
                    AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }

                if (errors == 0)
                {
                    AppendLog("Moving BetterDiscord to resources\\node_modules\\");
                    Directory.Move($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\BetterDiscordApp-stable16", $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord");

                    try {
                        Splice();
                    } catch {
                        AppendLog("Error: Splicing index.js: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                        errors = 1;
                        Finalize(errors);
                    }
                }
            });

            Thread t2 = new Thread(() => {
                string dir = $"{GetParent().DiscordPath}\\index.js";

                if (File.Exists(dir + ".old") && File.Exists(dir))
                {
                    AppendLog($"Restoring original {dir}");
                    File.Delete(dir);
                    while (File.Exists(dir))
                    {
                        Debug.Print("Waiting for direl");
                        Thread.Sleep(100);
                    }
                    File.Move(dir + ".old", dir);
                }

                AppendLog($"Making backup of {dir}");
                File.Copy(dir, dir + ".old");

                File.WriteAllText(dir, "module.exports = require('./core');");

                dir = $"{GetParent().DiscordPath}\\core";

                if (Directory.Exists(dir))
                {
                    try
                    {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                        while (Directory.Exists(dir))
                        {
                            Debug.Print("Waiting for direl");
                            Thread.Sleep(100);
                        }
                    }
                    catch
                    {
                        AppendLog($"Error: Failed to Delete the '{dir}\\core' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }


                AppendLog("Extracting core.asar");
                string appAsarPath = $"{GetParent().DiscordPath}\\core.asar";

                if (File.Exists(appAsarPath))
                {
                    AsarArchive archive     = new AsarArchive(appAsarPath);
                    AsarExtractor extractor = new AsarExtractor();
                    extractor.ExtractAll(archive, $"{GetParent().DiscordPath}\\core\\");
                }
                else
                {
                    AppendLog("Error: core.asar file couldn't be found. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }


                dir = $"{GetParent().DiscordPath}\\core\\node_modules\\BetterDiscord";

                if (Directory.Exists(dir))
                {
                    AppendLog($"Deleting {dir}");
                    Directory.Delete(dir, true);
                    while (Directory.Exists(dir))
                    {
                        Debug.Print("Waiting for direl");
                        Thread.Sleep(100);
                    }
                }


                if (errors == 0)
                {
                    AppendLog("Moving BetterDiscord to node_modules");
                    Directory.Move($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\BetterDiscordApp-stable16", dir);

                    try
                    {
                        Splice();
                    }
                    catch
                    {
                        AppendLog("Error: Splicing mainScreen.js: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                        errors = 1;
                        Finalize(errors);
                    }
                }
            });

            if (GetParent().DesktopModule)
            {
                t2.Start();
            }
            else
            {
                t1.Start();
            }
        }
Exemple #13
0
        static void Main(string[] args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            bool noupdate  = true;
            bool autoguest = false;

            Console.WriteLine("Bienvenido a BlitzAdBlock V.0.3b");
            foreach (string arg in args)
            {
                if (arg.ToLower() == "-noupdate")
                {
                    Console.WriteLine("Deshabilitando Blitz auto update...");
                    noupdate = true;
                }
                if (arg.ToLower() == "-autoguest")
                {
                    Console.WriteLine("Enabling auto sign in as guest...");
                    autoguest = true;
                }
            }

            if (File.Exists($"{appPath}\\app.asar"))
            {
                Console.WriteLine("Blitz encontrado!");

                try {
                    Console.WriteLine("Extrayendo archivos de configuracion...");
                    CopyFolder($"{appPath}\\app.asar.unpacked\\", $"{appPath}\\app\\");
                    var asar      = new AsarArchive($"{appPath}\\app.asar");
                    var extractor = new AsarExtractor();
                    extractor.ExtractAll(asar, $"{appPath}\\app\\", true);
                } catch (IOException) {
                    Console.WriteLine("¡Error al extraer archivos! Asegúrese de que la aplicación Blitz esté cerrada antes de volver a intentarlo...");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("Descargando filtros para anuncios...");
                new WebClient().DownloadFile("https://easylist.to/easylist/easylist.txt", $"{appPath}\\app\\src\\easylist.txt");
                new WebClient().DownloadFile("https://easylist.to/easylist/easyprivacy.txt", $"{appPath}\\app\\src\\easyprivacy.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt", $"{appPath}\\app\\src\\ublock-ads.txt");
                new WebClient().DownloadFile("https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt", $"{appPath}\\app\\src\\ublock-privacy.txt");
                new WebClient().DownloadFile("https://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblock&showintro=1&mimetype=plaintext", $"{appPath}\\app\\src\\peter-lowe-list.txt");

                Console.WriteLine("Parchando...");
                string fileToPatch = $"{appPath}\\app\\src\\createWindow.js";

                // copy adblocker lib to src
                File.WriteAllBytes($"{appPath}\\app\\src\\adblocker.umd.min.js", Encoding.UTF8.GetBytes(Resources.adblocker_umd_min));

                // start writing our payload to createWindow.js
                ModifyFileAtLine("session: true,", fileToPatch, 106);
                ModifyFileAtLine(

                    "try {" +
                    "const fs = require('fs');" +
                    "const { FiltersEngine, Request} = require('./adblocker.umd.min.js');" +
                    "const filters = " +
                    "fs.readFileSync(require.resolve('./easylist.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./easyprivacy.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./ublock-ads.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./ublock-privacy.txt'), 'utf-8') + '\\n' + " +
                    "fs.readFileSync(require.resolve('./peter-lowe-list.txt'), 'utf-8') + '\\ngoogleoptimize.com\\n';" +
                    "const engine = FiltersEngine.parse(filters);" +

                    "windowInstance.webContents.session.webRequest.onBeforeRequest({ urls:['*://*/*']}, (details, callback) => {" +
                    "const { match } = engine.match(Request.fromRawDetails({ url: details.url}));" +
                    "if (match == true) {" +
                    "log.info('BLOCKED:', details.url);" +
                    "callback({cancel: true});" +
                    "} else {" +
                    "callback({cancel: false});" +
                    "}" +
                    "});" +
                    "} catch (error) {" +
                    "log.error(error);" +
                    "}"

                    , fileToPatch, 119);

                // optional features
                if (noupdate)
                {
                    Console.WriteLine("Deshabilitando Blitz auto update...");
                    ModifyFileAtLine("if (false) {", $"{appPath}\\app\\src\\index.js", 267);
                    Console.WriteLine("Busca dentro de opciones en blitz, para actualizar.");
                }
                if (autoguest)
                {
                    ModifyFileAtLine(

                        "autoGuest();" +
                        "function autoGuest() {" +
                        "var buttons = document.getElementsByTagName('button');" +
                        "for (var i = 0; i < buttons.length; i++) {" +
                        "if (buttons[i].getAttribute('label') == 'Login As Guest') {" +
                        "buttons[i].click();" +
                        "return;" +
                        "}" +
                        "}" +
                        "setTimeout(autoGuest, 1000);" +
                        "}"

                        , $"{appPath}\\app\\src\\preload.js", 18);
                }
                System.Threading.Thread.Sleep(1000);
                Console.Write("Un...");
                System.Threading.Thread.Sleep(1000);
                Console.Write("Dos...");
                System.Threading.Thread.Sleep(1000);
                Console.Write("Tres...");
                System.Threading.Thread.Sleep(1000);
                Console.Write("CUATRO!");
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("..::SUBLIME::.. Parche completo! <4");
                Console.WriteLine("MrBargz en lol para skins de agradecimientos");
                Console.WriteLine("Repositorio lulzsun: https://github.com/lulzsun/blitz-app-adblock");
                Console.WriteLine("Repositorio MrBargz: https://github.com/MrBargz/BlitzAdBlock");
                Console.WriteLine("Presiona cualquier tecla para salir");
            }
            else
            {
                Console.WriteLine("Blitz no esta instalado :(!");
            }
            Console.ReadKey();
        }
Exemple #14
0
        static async Task Main(string[] args)
        {
            Console.WriteLine($"请输入UnityHub目录的绝对路径:");
            var unityHubPath = Console.ReadLine();

            unityHubPath = unityHubPath.Trim('"');

            var isUnityHub = false;

            try
            {
                isUnityHub = File.Exists(Path.Combine(unityHubPath, "Unity Hub.exe"));
            }
            catch
            {
            }

            if (!isUnityHub)
            {
                LogAndPause($"不是 UnityHub 目录.");
                return;
            }

            unityHubPath = Path.Combine(unityHubPath, "resources");
            var exportFolder   = Path.Combine(unityHubPath, "app");
            var asarPath       = Path.Combine(unityHubPath, "app.asar");
            var asarUnpackPath = Path.Combine(unityHubPath, "app.asar.unpacked");

            if (Directory.Exists(exportFolder) || !File.Exists(asarPath))
            {
                LogAndPause($"已经破解或破解失败.");
                return;
            }

            var success = true;

            Console.WriteLine("开始破解");

            try
            {
                Directory.CreateDirectory(exportFolder);

                var archive   = new AsarArchive(asarPath);
                var extractor = new AsarExtractor();
                progressBar = new ProgressBar();

                extractor.FileExtracted += (sender, e) => progressBar.Report(e.Progress);
                await extractor.ExtractAll(archive, exportFolder + "/");

                var licenseClientPath = Path.Combine(exportFolder, "build/services/licenseService/licenseClient.js");
                var authPath          = Path.Combine(exportFolder, "build/services/localAuth/auth.js");

                var licenseClientContent = File.ReadAllText(licenseClientPath);
                var authContent          = File.ReadAllText(authPath);

                ReplaceMehthodBody(ref licenseClientContent, getLicenseInfoBody, @"getLicenseInfo\(\w+\)\s*{(?<body>.*?return.*?)}");
                ReplaceMehthodBody(ref authContent, getDefaultUserInfoBody, @"getDefaultUserInfo\(\)\s*{(?<body>.*?return.*?};.*?)}");

                File.WriteAllText(licenseClientPath, licenseClientContent);
                File.WriteAllText(authPath, authContent);

                if (Directory.Exists(asarUnpackPath))
                {
                    CopyDirectory(asarUnpackPath, exportFolder, true);
                }

                File.Move(asarPath, asarPath + ".bak");
            }
            catch (Exception ex)
            {
                success = false;
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine();
                progressBar.Dispose();
                LogAndPause(success ? "破解完成" : "破解失败");
            }
        }
Exemple #15
0
        private void DeleteDirs()
        {
            int    errors = 0;
            Thread t      = new Thread(() => {
                string dir = $"{GetParent().DiscordPath}\\resources\\app";

                if (Directory.Exists(dir))
                {
                    try {
                        AppendLog("Deleting " + dir);
                        Directory.Delete(dir, true);
                    } catch {
                        AppendLog($"Error: Failed to Delete the '{dir}\\resources\\app' Directory.");
                        errors = 1;
                        Finalize(errors);
                    }
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                dir = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";


                if (Directory.Exists(dir))
                {
                    AppendLog($"Deleting {dir}");
                    Directory.Delete(dir, true);
                }

                while (Directory.Exists(dir))
                {
                    Debug.Print("Waiting for direl");
                    Thread.Sleep(100);
                }

                AppendLog("Extracting app.asar");
                string appAsarPath = $"{GetParent().DiscordPath}\\resources\\app.asar";

                if (File.Exists(appAsarPath))
                {
                    AsarArchive archive     = new AsarArchive(appAsarPath);
                    AsarExtractor extractor = new AsarExtractor();
                    extractor.ExtractAll(archive, $"{GetParent().DiscordPath}\\resources\\app\\");
                }
                else
                {
                    AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue.");
                    errors = 1;
                    Finalize(errors);
                }

                if (errors == 0)
                {
                    AppendLog("Moving BetterDiscord to resources\\node_modules\\");
                    Directory.Move($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\BetterDiscordApp-stable16", $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord");

                    try {
                        Splice();
                    } catch {
                        AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
                        errors = 1;
                        Finalize(errors);
                    }
                }
            });


            t.Start();
        }