mirror of
				https://github.com/EndPwnArchive/endpwn3.git
				synced 2024-08-15 00:23:30 +00:00 
			
		
		
		
	a
This commit is contained in:
		
							parent
							
								
									13b4d93ca0
								
							
						
					
					
						commit
						d11c87ff88
					
				
					 1 changed files with 104 additions and 102 deletions
				
			
		
							
								
								
									
										206
									
								
								app/index.html
									
										
									
									
									
								
							
							
						
						
									
										206
									
								
								app/index.html
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -141,125 +141,127 @@
 | 
			
		|||
    <script>
 | 
			
		||||
 | 
			
		||||
        // wait until DOM is ready so that error messages can display properly
 | 
			
		||||
        window.onload = setTimeout(async () => {
 | 
			
		||||
        window.onload = () => {
 | 
			
		||||
 | 
			
		||||
            setTimeout(() => {
 | 
			
		||||
                init();
 | 
			
		||||
                if (gl) animate();
 | 
			
		||||
            }, 0);
 | 
			
		||||
            init();
 | 
			
		||||
            if (gl) animate();
 | 
			
		||||
 | 
			
		||||
            // dont try doing anything if running in a browser
 | 
			
		||||
            if (navigator.userAgent.indexOf('discord') == -1) return;
 | 
			
		||||
            setTimeout(async () => {
 | 
			
		||||
 | 
			
		||||
            var approot = location.href.split('/app/')[0];
 | 
			
		||||
                // dont try doing anything if running in a browser
 | 
			
		||||
                if (navigator.userAgent.indexOf('discord') == -1) return;
 | 
			
		||||
 | 
			
		||||
            try {
 | 
			
		||||
 | 
			
		||||
                // fix for recent canary update
 | 
			
		||||
                if (window.require === undefined) {
 | 
			
		||||
                    window.electron = DiscordNative.nativeModules.requireModule("discord_/../electron").remote;
 | 
			
		||||
                    window.require = electron.require;
 | 
			
		||||
                } else {
 | 
			
		||||
                    window.electron = require('electron').remote;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                window.fs = require("original-fs");
 | 
			
		||||
                window.Buffer = require("buffer").Buffer;
 | 
			
		||||
 | 
			
		||||
                var data = electron.app.getPath('userData');
 | 
			
		||||
                var branch = require('path').basename(data).substr(7);
 | 
			
		||||
 | 
			
		||||
                function load() {
 | 
			
		||||
                    electron.BrowserWindow.addExtension(data + '/crxpwn');
 | 
			
		||||
                    electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (window.betterDiscordIPC) {
 | 
			
		||||
                    alert('EndPwn3 is not compatible with BetterDiscord\n\nPress OK to return to Discord', 'EndPwn3: Framework Conflict');
 | 
			
		||||
                    electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // temporary
 | 
			
		||||
                if (branch != 'canary') {
 | 
			
		||||
                    alert('EndPwn3.1 Staging uses crxpwn which only works on Canary at the moment', 'Sorry');
 | 
			
		||||
                    electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // asarpwn (as a removal tool)
 | 
			
		||||
                function asarinject(sig, inj) {
 | 
			
		||||
                    var dirlisting = fs.readdirSync(data);
 | 
			
		||||
                    var latestver = dirlisting.filter(d => d.indexOf("0.0.") > -1);
 | 
			
		||||
 | 
			
		||||
                    if (sig.length != inj.length) {
 | 
			
		||||
                        throw 'signature and injection not same size'
 | 
			
		||||
                    }
 | 
			
		||||
                    var bdata = new Buffer(fs.readFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`));
 | 
			
		||||
                    var index = bdata.indexOf(sig);
 | 
			
		||||
                    if (index == -1) {
 | 
			
		||||
                        return 0;
 | 
			
		||||
                    }
 | 
			
		||||
                    bdata.write(inj, index);
 | 
			
		||||
                    fs.writeFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`, bdata);
 | 
			
		||||
                    return 1;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // install endpwn 
 | 
			
		||||
 | 
			
		||||
                var o = fs.existsSync(data + '/settings.json') ? JSON.parse(fs.readFileSync(data + '/settings.json', 'utf8')) : {}; // load settings.json
 | 
			
		||||
                o['WEBAPP_ENDPOINT'] = location.href.split('?')[0] + '?'; // aim the app at stage 0
 | 
			
		||||
                o['WEBAPP_PATH'] = undefined; // clear old WEBAPP_PATH
 | 
			
		||||
                fs.writeFileSync(data + '/settings.json', JSON.stringify(o, null, 2)); // commit changes to disk
 | 
			
		||||
                var approot = location.href.split('/app/')[0];
 | 
			
		||||
 | 
			
		||||
                try {
 | 
			
		||||
                    if (window.__crispr_load_attempted)
 | 
			
		||||
                        // reverse asarpwn3
 | 
			
		||||
                        if (asarinject(
 | 
			
		||||
                            "var electron=require('electron');var d=electron.remote.app.getPath('userData')+'/crispr.js';if(require('fs').existsSync(d))require(d).go();//",
 | 
			
		||||
                            "// App preload script, used to provide a replacement native API now that\n// we turned off node integration.\nvar electron = require('electron'"
 | 
			
		||||
                        )) {
 | 
			
		||||
                            electron.app.relaunch();
 | 
			
		||||
                            electron.app.exit();
 | 
			
		||||
 | 
			
		||||
                    // fix for recent canary update
 | 
			
		||||
                    if (window.require === undefined) {
 | 
			
		||||
                        window.electron = DiscordNative.nativeModules.requireModule("discord_/../electron").remote;
 | 
			
		||||
                        window.require = electron.require;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        window.electron = require('electron').remote;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    window.fs = require("original-fs");
 | 
			
		||||
                    window.Buffer = require("buffer").Buffer;
 | 
			
		||||
 | 
			
		||||
                    var data = electron.app.getPath('userData');
 | 
			
		||||
                    var branch = require('path').basename(data).substr(7);
 | 
			
		||||
 | 
			
		||||
                    function load() {
 | 
			
		||||
                        electron.BrowserWindow.addExtension(data + '/crxpwn');
 | 
			
		||||
                        electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (window.betterDiscordIPC) {
 | 
			
		||||
                        alert('EndPwn3 is not compatible with BetterDiscord\n\nPress OK to return to Discord', 'EndPwn3: Framework Conflict');
 | 
			
		||||
                        electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    // temporary
 | 
			
		||||
                    if (branch != 'canary') {
 | 
			
		||||
                        alert('EndPwn3.1 Staging uses crxpwn which only works on Canary at the moment', 'Sorry');
 | 
			
		||||
                        electron.getCurrentWindow().loadURL('https://' + (branch && branch != 'development' ? branch + '.' : '') + 'discordapp.com/channels/@me');
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    // asarpwn (as a removal tool)
 | 
			
		||||
                    function asarinject(sig, inj) {
 | 
			
		||||
                        var dirlisting = fs.readdirSync(data);
 | 
			
		||||
                        var latestver = dirlisting.filter(d => d.indexOf("0.0.") > -1);
 | 
			
		||||
 | 
			
		||||
                        if (sig.length != inj.length) {
 | 
			
		||||
                            throw 'signature and injection not same size'
 | 
			
		||||
                        }
 | 
			
		||||
                } catch (ex) {
 | 
			
		||||
                    alert(ex, 'asarpwn3');
 | 
			
		||||
                }
 | 
			
		||||
                        var bdata = new Buffer(fs.readFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`));
 | 
			
		||||
                        var index = bdata.indexOf(sig);
 | 
			
		||||
                        if (index == -1) {
 | 
			
		||||
                            return 0;
 | 
			
		||||
                        }
 | 
			
		||||
                        bdata.write(inj, index);
 | 
			
		||||
                        fs.writeFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`, bdata);
 | 
			
		||||
                        return 1;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                if (!fs.existsSync(data + '/crxpwn')) {
 | 
			
		||||
                    fs.mkdirSync(data + '/crxpwn');
 | 
			
		||||
                    fs.writeFileSync(data + '/crxpwn/manifest.json', '{"manifest_version":2,"name":"crxpwn","description":"asarpwn-less preload scripts for the masses ;)","version":"1.0","content_scripts":[{"js":["payload.js"],"matches":["*://*/*"],"run_at":"document_start","all_frames":true}]}');
 | 
			
		||||
                }
 | 
			
		||||
                    // install endpwn 
 | 
			
		||||
 | 
			
		||||
                if (!fs.existsSync(data + '/plugins')) fs.mkdirSync(data + '/plugins');
 | 
			
		||||
                if (!fs.existsSync(data + '/styles')) fs.mkdirSync(data + '/styles');
 | 
			
		||||
                    var o = fs.existsSync(data + '/settings.json') ? JSON.parse(fs.readFileSync(data + '/settings.json', 'utf8')) : {}; // load settings.json
 | 
			
		||||
                    o['WEBAPP_ENDPOINT'] = location.href.split('?')[0] + '?'; // aim the app at stage 0
 | 
			
		||||
                    o['WEBAPP_PATH'] = undefined; // clear old WEBAPP_PATH
 | 
			
		||||
                    fs.writeFileSync(data + '/settings.json', JSON.stringify(o, null, 2)); // commit changes to disk
 | 
			
		||||
 | 
			
		||||
                // dont update EPAPI/CRISPR if DONTUPDATE exists
 | 
			
		||||
                if (!fs.existsSync(data + '/DONTUPDATE')) {
 | 
			
		||||
                    try {
 | 
			
		||||
                        if (window.__crispr_load_attempted)
 | 
			
		||||
                            // reverse asarpwn3
 | 
			
		||||
                            if (asarinject(
 | 
			
		||||
                                "var electron=require('electron');var d=electron.remote.app.getPath('userData')+'/crispr.js';if(require('fs').existsSync(d))require(d).go();//",
 | 
			
		||||
                                "// App preload script, used to provide a replacement native API now that\n// we turned off node integration.\nvar electron = require('electron'"
 | 
			
		||||
                            )) {
 | 
			
		||||
                                electron.app.relaunch();
 | 
			
		||||
                                electron.app.exit();
 | 
			
		||||
                            }
 | 
			
		||||
                    } catch (ex) {
 | 
			
		||||
                        alert(ex, 'asarpwn3');
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    // get files 
 | 
			
		||||
                    fs.writeFileSync(data + '/crxpwn/payload.js', await (await fetch(approot + '/crxpwn.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/epapi.js', await (await fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/crispr.js', await (await fetch('https://endpwn.github.io/crispr/crispr.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/plugins/system.js', await (await fetch(approot + '/plugin/system.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/plugins/customizer.js', await (await fetch(approot + '/plugin/customizer.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/plugins/settings.js', await (await fetch(approot + '/plugin/settings.js?_=' + Date.now())).text());
 | 
			
		||||
                    fs.writeFileSync(data + '/styles/system.css', await (await fetch(approot + '/plugin/system.css?_=' + Date.now())).text());
 | 
			
		||||
                    if (!fs.existsSync(data + '/crxpwn')) {
 | 
			
		||||
                        fs.mkdirSync(data + '/crxpwn');
 | 
			
		||||
                        fs.writeFileSync(data + '/crxpwn/manifest.json', '{"manifest_version":2,"name":"crxpwn","description":"asarpwn-less preload scripts for the masses ;)","version":"1.0","content_scripts":[{"js":["payload.js"],"matches":["*://*/*"],"run_at":"document_start","all_frames":true}]}');
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    setTimeout(load, 1000);
 | 
			
		||||
                    if (!fs.existsSync(data + '/plugins')) fs.mkdirSync(data + '/plugins');
 | 
			
		||||
                    if (!fs.existsSync(data + '/styles')) fs.mkdirSync(data + '/styles');
 | 
			
		||||
 | 
			
		||||
                    // dont update EPAPI/CRISPR if DONTUPDATE exists
 | 
			
		||||
                    if (!fs.existsSync(data + '/DONTUPDATE')) {
 | 
			
		||||
 | 
			
		||||
                        // get files 
 | 
			
		||||
                        fs.writeFileSync(data + '/crxpwn/payload.js', await (await fetch(approot + '/crxpwn.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/epapi.js', await (await fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/crispr.js', await (await fetch('https://endpwn.github.io/crispr/crispr.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/plugins/system.js', await (await fetch(approot + '/plugin/system.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/plugins/customizer.js', await (await fetch(approot + '/plugin/customizer.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/plugins/settings.js', await (await fetch(approot + '/plugin/settings.js?_=' + Date.now())).text());
 | 
			
		||||
                        fs.writeFileSync(data + '/styles/system.css', await (await fetch(approot + '/plugin/system.css?_=' + Date.now())).text());
 | 
			
		||||
 | 
			
		||||
                        setTimeout(load, 1000);
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        setTimeout(load, 1000);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    setTimeout(load, 1000);
 | 
			
		||||
                catch (e) {
 | 
			
		||||
                    console.error(e);
 | 
			
		||||
                    document.querySelector('div').parentNode.innerHTML += '<span>Inititialization failure. Check the console for details.</span>';
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            catch (e) {
 | 
			
		||||
                console.error(e);
 | 
			
		||||
                document.querySelector('div').parentNode.innerHTML += '<span>Inititialization failure. Check the console for details.</span>';
 | 
			
		||||
            }
 | 
			
		||||
            }, 500);
 | 
			
		||||
 | 
			
		||||
        }, 500);
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
    </script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue