mirror of
https://github.com/EndPwnArchive/endpwn3.2-lambda.git
synced 2024-08-14 23:49:56 +00:00
fix epapi to get a diff element to load from
This commit is contained in:
parent
d71cf3f140
commit
d182a7288d
4 changed files with 174 additions and 91 deletions
219
crispr/crispr.js
219
crispr/crispr.js
|
@ -25,34 +25,48 @@ function evaluate(str, exportsR) {
|
||||||
}
|
}
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
|
|
||||||
// log function
|
// log function
|
||||||
function __crprint(str) {
|
function __crprint(str) {
|
||||||
console.log(`%c[CRISPR]%c ` + str, 'font-weight:bold;color:#c080ff', '');
|
console.log(
|
||||||
|
`%c[CRISPR]%c ` + str,
|
||||||
|
"font-weight:bold;color:#c080ff",
|
||||||
|
""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
function __crwarn(str) {
|
function __crwarn(str) {
|
||||||
console.warn(`%c[CRISPR]%c ` + str, 'font-weight:bold;color:#c080ff', '');
|
console.warn(
|
||||||
|
`%c[CRISPR]%c ` + str,
|
||||||
|
"font-weight:bold;color:#c080ff",
|
||||||
|
""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.go = (() => {
|
exports.go = () => {
|
||||||
|
|
||||||
window.__crispr_load_attempted = true;
|
window.__crispr_load_attempted = true;
|
||||||
|
|
||||||
if (location.hostname.indexOf('discordapp') == -1 && location.hostname.indexOf('dr1ft.xyz') == -1) return;
|
const dataDir = require("electron")
|
||||||
|
.remote.app.getPath("userData")
|
||||||
|
.replace(/\\/g, "/");
|
||||||
|
const settings = require(dataDir + "/settings.json");
|
||||||
|
|
||||||
|
if (
|
||||||
|
location.hostname.indexOf(settings.WEBAPP_ENDPOINT) == -1 &&
|
||||||
|
location.hostname.indexOf("discordapp") == -1 &&
|
||||||
|
location.hostname.indexOf("dr1ft.xyz") == -1
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
__crprint("starting up...");
|
||||||
__crprint('starting up...');
|
|
||||||
|
|
||||||
var _localStorage = window.localStorage;
|
var _localStorage = window.localStorage;
|
||||||
window.crispr = {
|
window.crispr = {
|
||||||
|
|
||||||
version: {
|
version: {
|
||||||
major: 1,
|
major: 1,
|
||||||
minor: 2,
|
minor: 2,
|
||||||
revision: 7,
|
revision: 7,
|
||||||
|
|
||||||
toString: function () {
|
toString: function() {
|
||||||
return `v${this.major}.${this.minor}.${this.revision}`;
|
return `v${this.major}.${this.minor}.${this.revision}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -62,24 +76,17 @@ function evaluate(str, exportsR) {
|
||||||
webpackJsonpTransformations: []
|
webpackJsonpTransformations: []
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {},
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
functions: {
|
functions: {
|
||||||
|
|
||||||
patch: mod => {
|
patch: mod => {
|
||||||
|
|
||||||
// make sure it's an array before trying to process it
|
// make sure it's an array before trying to process it
|
||||||
if (Array.isArray(mod)) {
|
if (Array.isArray(mod)) {
|
||||||
|
|
||||||
// iterate over every module
|
// iterate over every module
|
||||||
__crprint(`processing ${mod.length} modules...`);
|
__crprint(`processing ${mod.length} modules...`);
|
||||||
for (i in mod) {
|
for (i in mod) {
|
||||||
|
|
||||||
// iterate over the replacement dictionary
|
// iterate over the replacement dictionary
|
||||||
snippets.forEach(pair => {
|
snippets.forEach(pair => {
|
||||||
|
|
||||||
// convert the module constructor into a string
|
// convert the module constructor into a string
|
||||||
var orig = mod[i].toString();
|
var orig = mod[i].toString();
|
||||||
|
|
||||||
|
@ -87,87 +94,111 @@ function evaluate(str, exportsR) {
|
||||||
var signature = pair.signature;
|
var signature = pair.signature;
|
||||||
|
|
||||||
// check if it's an old shitty regex replacement
|
// check if it's an old shitty regex replacement
|
||||||
signature = typeof signature == 'string' ? signature.startsWith('/') && signature.endsWith('/') ? new RegExp(signature.substr(1, signature.length - 2)) : signature : signature;
|
signature =
|
||||||
|
typeof signature == "string"
|
||||||
|
? signature.startsWith("/") &&
|
||||||
|
signature.endsWith("/")
|
||||||
|
? new RegExp(
|
||||||
|
signature.substr(
|
||||||
|
1,
|
||||||
|
signature.length - 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
: signature
|
||||||
|
: signature;
|
||||||
|
|
||||||
// if the constructor contains our signature, patch it
|
// if the constructor contains our signature, patch it
|
||||||
if (typeof signature == 'string' ? orig.indexOf(signature) != -1 : orig.match(signature)) {
|
if (
|
||||||
|
typeof signature == "string"
|
||||||
|
? orig.indexOf(signature) != -1
|
||||||
|
: orig.match(signature)
|
||||||
|
) {
|
||||||
// replace the function with our new one
|
// replace the function with our new one
|
||||||
__crprint(`patching module ${i}... (${signature})`);
|
__crprint(
|
||||||
mod[i] = eval('(' + orig.replace(signature, pair.payload) + ')');
|
`patching module ${i}... (${signature})`
|
||||||
|
);
|
||||||
|
mod[i] = eval(
|
||||||
|
"(" +
|
||||||
|
orig.replace(
|
||||||
|
signature,
|
||||||
|
pair.payload
|
||||||
|
) +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pushHookOld: (x, mod, main) => {
|
pushHookOld: (x, mod, main) => {
|
||||||
|
|
||||||
// disable safemode keystroke listener
|
// disable safemode keystroke listener
|
||||||
document.removeEventListener('keydown', goSafe);
|
document.removeEventListener("keydown", goSafe);
|
||||||
|
|
||||||
// check if safemode
|
// check if safemode
|
||||||
if (!_localStorage['safemode'])
|
if (!_localStorage["safemode"])
|
||||||
crispr.functions.patch(mod);
|
crispr.functions.patch(mod);
|
||||||
|
|
||||||
// call webpack proper with our modified modules
|
// call webpack proper with our modified modules
|
||||||
return crispr.data.webpackPush(x, mod, main);
|
return crispr.data.webpackPush(x, mod, main);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pushHookNew: (x,mod,main) => {
|
pushHookNew: (x, mod, main) => {
|
||||||
|
|
||||||
// disable safemode keystroke listener
|
// disable safemode keystroke listener
|
||||||
document.removeEventListener('keydown', goSafe);
|
document.removeEventListener("keydown", goSafe);
|
||||||
|
|
||||||
// check if safemode
|
// check if safemode
|
||||||
if (!_localStorage['safemode'])
|
if (!_localStorage["safemode"])
|
||||||
crispr.functions.patch(mod);
|
crispr.functions.patch(mod);
|
||||||
|
|
||||||
// call webpack proper with our modified modules
|
// call webpack proper with our modified modules
|
||||||
return mod;
|
return mod;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// safemode stuff
|
// safemode stuff
|
||||||
__crprint('press left shift to start up in safemode');
|
__crprint("press left shift to start up in safemode");
|
||||||
|
|
||||||
function goSafe(e) {
|
function goSafe(e) {
|
||||||
if (e.keyCode == 16)
|
if (e.keyCode == 16) _localStorage["safemode"] = 1;
|
||||||
_localStorage['safemode'] = 1;
|
__crwarn("ok, starting up in safe mode");
|
||||||
__crwarn('ok, starting up in safe mode');
|
document.removeEventListener("keydown", goSafe);
|
||||||
document.removeEventListener('keydown', goSafe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('keydown', goSafe);
|
document.addEventListener("keydown", goSafe);
|
||||||
document.addEventListener('ep-ready', () => document.removeEventListener('keydown', goSafe)); // crispr expects epapi to reset safemode and fire ep-ready
|
document.addEventListener("ep-ready", () =>
|
||||||
|
document.removeEventListener("keydown", goSafe)
|
||||||
|
); // crispr expects epapi to reset safemode and fire ep-ready
|
||||||
|
|
||||||
// with crxpwn, it's no longer safe to assume we have access to require()
|
// with crxpwn, it's no longer safe to assume we have access to require()
|
||||||
var electron;
|
var electron;
|
||||||
if (window.DiscordNative !== undefined) {
|
if (window.DiscordNative !== undefined) {
|
||||||
electron = DiscordNative.nativeModules.requireModule("discord_/../electron");
|
electron = DiscordNative.nativeModules.requireModule(
|
||||||
|
"discord_/../electron"
|
||||||
|
);
|
||||||
window.require = electron.remote.require;
|
window.require = electron.remote.require;
|
||||||
}
|
} else {
|
||||||
else {
|
electron = require("electron");
|
||||||
electron = require('electron');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// crispr runs far before epapi is ready, so we need to define these for ourself
|
// crispr runs far before epapi is ready, so we need to define these for ourself
|
||||||
const fs = require('original-fs');
|
const fs = require("original-fs");
|
||||||
const data = electron.remote.app.getPath('userData');
|
const data = electron.remote.app.getPath("userData");
|
||||||
|
|
||||||
function krequire(p) {
|
function krequire(p) {
|
||||||
var exports = {};
|
var exports = {};
|
||||||
eval(fs.readFileSync(data + '/plugins/' + p + (p.endsWith('.js') ? '' : '.js'), 'utf8').toString());
|
eval(
|
||||||
|
fs
|
||||||
|
.readFileSync(
|
||||||
|
data +
|
||||||
|
"/plugins/" +
|
||||||
|
p +
|
||||||
|
(p.endsWith(".js") ? "" : ".js"),
|
||||||
|
"utf8"
|
||||||
|
)
|
||||||
|
.toString()
|
||||||
|
);
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,44 +206,58 @@ function evaluate(str, exportsR) {
|
||||||
var snippets = [];
|
var snippets = [];
|
||||||
|
|
||||||
// plugin iterator, taken from epapi
|
// plugin iterator, taken from epapi
|
||||||
if (fs.existsSync(data + '/plugins')) {
|
if (fs.existsSync(data + "/plugins")) {
|
||||||
fs.readdirSync(data + '/plugins').forEach(x => {
|
fs.readdirSync(data + "/plugins").forEach(x => {
|
||||||
if (x.endsWith('.js')) {
|
if (x.endsWith(".js")) {
|
||||||
try {
|
try {
|
||||||
var plugin = krequire(x);
|
var plugin = krequire(x);
|
||||||
if (plugin.preload !== undefined) {
|
if (plugin.preload !== undefined) {
|
||||||
|
|
||||||
// plugin has a preload function
|
// plugin has a preload function
|
||||||
__crprint('executing /plugins/' + x);
|
__crprint("executing /plugins/" + x);
|
||||||
plugin.preload();
|
plugin.preload();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plugin.replacements !== undefined) {
|
if (plugin.replacements !== undefined) {
|
||||||
|
|
||||||
// add the plugin's replacements to the dictionary
|
// add the plugin's replacements to the dictionary
|
||||||
__crprint('adding replacements from /plugins/' + x);
|
__crprint(
|
||||||
__crwarn('exports.replacements is deprecated, please use exports.manifest.replacements');
|
"adding replacements from /plugins/" + x
|
||||||
Object.keys(plugin.replacements).map(key => { return { signature: key, payload: plugin.replacements[key] } }).forEach(x => snippets.push(x));
|
);
|
||||||
|
__crwarn(
|
||||||
|
"exports.replacements is deprecated, please use exports.manifest.replacements"
|
||||||
|
);
|
||||||
|
Object.keys(plugin.replacements)
|
||||||
|
.map(key => {
|
||||||
|
return {
|
||||||
|
signature: key,
|
||||||
|
payload: plugin.replacements[key]
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.forEach(x => snippets.push(x));
|
||||||
}
|
}
|
||||||
if (plugin.manifest !== undefined && plugin.manifest.replacements !== undefined) {
|
if (
|
||||||
|
plugin.manifest !== undefined &&
|
||||||
|
plugin.manifest.replacements !== undefined
|
||||||
|
) {
|
||||||
// add the plugin's replacements to the dictionary
|
// add the plugin's replacements to the dictionary
|
||||||
__crprint('adding replacements from /plugins/' + x);
|
__crprint(
|
||||||
plugin.manifest.replacements.forEach(x => snippets.push(x));
|
"adding replacements from /plugins/" + x
|
||||||
|
);
|
||||||
|
plugin.manifest.replacements.forEach(x =>
|
||||||
|
snippets.push(x)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('/plugins/' + x + ' contains errors\n\n', e);
|
console.warn(
|
||||||
|
"/plugins/" + x + " contains errors\n\n",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// hook webpackJsonp so that we can play with the constructors
|
// hook webpackJsonp so that we can play with the constructors
|
||||||
__crprint('hooking webpackJsonp...');
|
__crprint("hooking webpackJsonp...");
|
||||||
Object.defineProperty(window, "webpackJsonp", {
|
Object.defineProperty(window, "webpackJsonp", {
|
||||||
|
|
||||||
// return crispr's function instead of webpack proper
|
// return crispr's function instead of webpack proper
|
||||||
get: () => window.crispr.hook,
|
get: () => window.crispr.hook,
|
||||||
|
|
||||||
|
@ -224,21 +269,26 @@ function evaluate(str, exportsR) {
|
||||||
//__crprint('something is trying to define webpackJsonp...');
|
//__crprint('something is trying to define webpackJsonp...');
|
||||||
|
|
||||||
window.crispr.webpackJsonp = webpack;
|
window.crispr.webpackJsonp = webpack;
|
||||||
if (typeof webpack == 'function') {
|
if (typeof webpack == "function") {
|
||||||
window.crispr.data.webpackPush = webpack;
|
window.crispr.data.webpackPush = webpack;
|
||||||
window.crispr.hook = window.crispr.functions.pushHookOld;
|
window.crispr.hook =
|
||||||
|
window.crispr.functions.pushHookOld;
|
||||||
} else {
|
} else {
|
||||||
const newPush = function(e,t,o){
|
const newPush = function(e, t, o) {
|
||||||
const modules = t || e[1];
|
const modules = t || e[1];
|
||||||
const main = o ? o : e[2];
|
const main = o ? o : e[2];
|
||||||
const _ = t ? e : e[0];
|
const _ = t ? e : e[0];
|
||||||
|
|
||||||
const patched = window.crispr.functions.pushHookNew(_,modules,main);
|
const patched = window.crispr.functions.pushHookNew(
|
||||||
|
_,
|
||||||
|
modules,
|
||||||
|
main
|
||||||
|
);
|
||||||
|
|
||||||
const args = [_,patched,main];
|
const args = [_, patched, main];
|
||||||
|
|
||||||
push_original.apply(webpack, [args])
|
push_original.apply(webpack, [args]);
|
||||||
}
|
};
|
||||||
|
|
||||||
webpack.push = newPush;
|
webpack.push = newPush;
|
||||||
window.crispr.hook = webpack;
|
window.crispr.hook = webpack;
|
||||||
|
@ -247,13 +297,10 @@ function evaluate(str, exportsR) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
__crprint('ready!');
|
__crprint("ready!");
|
||||||
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// something bad happened -- if we dont catch this exception it will break discord!!!
|
// something bad happened -- if we dont catch this exception it will break discord!!!
|
||||||
console.error('CRISPR init failure!\n\n', ex);
|
console.error("CRISPR init failure!\n\n", ex);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -329,11 +329,7 @@ function evaluate(str, exportsR) {
|
||||||
|
|
||||||
// set everything up and load plugins
|
// set everything up and load plugins
|
||||||
init: function() {
|
init: function() {
|
||||||
if (
|
if ($(".app") != null ? $(".app").children.length > 0 : 0) {
|
||||||
$(".guilds-wrapper .guilds") != null
|
|
||||||
? $(".guilds-wrapper .guilds").children.length > 0
|
|
||||||
: 0
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
if (exports.localStorage.get("safemode")) {
|
if (exports.localStorage.get("safemode")) {
|
||||||
internal.print(
|
internal.print(
|
||||||
|
|
18
plugin/csp.js
Normal file
18
plugin/csp.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
exports.manifest = {
|
||||||
|
author: "Cynosphere",
|
||||||
|
name: "CSP",
|
||||||
|
description: "heck off policies"
|
||||||
|
};
|
||||||
|
exports.preload = function() {
|
||||||
|
require("electron").remote.session.defaultSession.webRequest.onHeadersReceived(
|
||||||
|
function(details, callback) {
|
||||||
|
details.responseHeaders["content-security-policy-report-only"] = "";
|
||||||
|
details.responseHeaders["content-security-policy"] = "";
|
||||||
|
delete details.responseHeaders[
|
||||||
|
"content-security-policy-report-only"
|
||||||
|
];
|
||||||
|
|
||||||
|
callback({ responseHeaders: details.responseHeaders });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
22
plugin/dnt.js
Normal file
22
plugin/dnt.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
exports.manifest = {
|
||||||
|
author: "Cynosphere",
|
||||||
|
name: "DNT",
|
||||||
|
description: "heck off trackers",
|
||||||
|
replacements:[
|
||||||
|
{
|
||||||
|
signature:"t.default=o({},u.default,{track:_})}",
|
||||||
|
payload:`t.default=o({},u.default,{track:function(){console.debug("[dnt] tracking: science")}})}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
signature:/_postReports=function\([a-zA-Z]\){.+},([a-zA-Z])\.prototype\._sendQualityReports`/,
|
||||||
|
payload:`_postReports=function(){console.debug("[dnt] rtc: quality report")},$1.prototype._sendQualityReports`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
exports.start = function(){
|
||||||
|
/*var sentry = wc.findFunc("_originalConsoleMethods")[0].exports;
|
||||||
|
window.console = Object.assign(window.console, sentry._originalConsoleMethods); // console
|
||||||
|
sentry._wrappedBuiltIns.forEach(x => x[0][x[1]] = x[2]); // other stuff
|
||||||
|
sentry._breadcrumbEventHandler = () => () => { }; // break most event logging
|
||||||
|
sentry.captureBreadcrumb = () => { }; // disable breadcrumb logging*/
|
||||||
|
}
|
Loading…
Reference in a new issue