diff --git a/app/index.htm b/app/index.htm index 24e977c..915616b 100644 --- a/app/index.htm +++ b/app/index.htm @@ -36,15 +36,44 @@ } window.fs = require("original-fs"); + window.Buffer = require("buffer").Buffer; var data = electron.app.getPath('userData'); + // asarpwn + function asarinject(sig, inj) { + var dirlisting = fs.readdirSync($api.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 = JSON.parse(fs.readFileSync(data + '/settings.json', 'utf8')); // load settings.json o['WEBAPP_ENDPOINT'] = 'https://endpwn.github.io/endpwn3'; // aim the app at stage 0 o['WEBAPP_PATH'] = '/app?_=' + Date.now(); // cache busting fs.writeFileSync(data + '/settings.json', JSON.stringify(o, null, 2)); // commit changes to disk + // install asarpwn3 for crispr + if (!window.__crisprloaded) + if (asarinject( + "// App preload script, used to provide a replacement native API now that\n// we turned off node integration.\nvar electron = require('electron'", + "var electron=require('electron');var d=electron.remote.app.getPath('userData')+'/crispr.js';if(require('fs').existsSync(d))require(d).go();//" + )) { + electron.app.relaunch(); + electron.app.exit(); + } + // make a window window.__monitor = new electron.BrowserWindow({ show: false }); diff --git a/monitor.htm b/monitor.htm index 03b82ce..10ae0b5 100644 --- a/monitor.htm +++ b/monitor.htm @@ -48,15 +48,23 @@ win.loadURL('https://' + (branch ? branch + '.' : '') + 'discordapp.com/channels/@me'); } - // dont update EPAPI if DONTUPDATE exists + // dont update EPAPI/CRISPR if DONTUPDATE exists if (!fs.existsSync(data + '/DONTUPDATE')) { - // grab EPAPI from master + // update EPAPI fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now()) .then(r => r.text()) .then(epapi => { fs.writeFileSync(data + '/epapi.js', epapi); - setTimeout(load, 1000); + + // update CRISPR + fetch('https://endpwn.github.io/crispr/crispr.js?_=' + Date.now()) + .then(r => r.text()) + .then(epapi => { + fs.writeFileSync(data + '/crispr.js', epapi); + setTimeout(load, 1000); + }); + }); }