forked from Prodigy-Hacking/Redirector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
117 lines (105 loc) · 4.65 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// @ts-nocheck
import express from "express";
import fetch from "node-fetch";
import fs from "fs";
import path from "path";
import { transpile } from "typescript";
import Discord from "discord.js";
import cors from "cors";
import ms from "ms";
const app = express();
// should match https://github.com/Prodigy-Hacking/PHEx/blob/master/src/manifest.json
const SupportPHEXVersion = "2.0.2";
let lastVersion = "None";
interface GameStatus {
status: string;
data?: { gameClientVersion?: string; prodigyGameFlags: { gameDataVersion: number } };
}
const startDate = Date.now();
/*setInterval(async () => {
try {
const status: GameStatus = await (await fetch("https://api.prodigygame.com/game-api/status")).json();
console.log(status);
const version = status?.data?.gameClientVersion;
if (lastVersion === "None") return (lastVersion = version!);
// write modified gamefile to disk, in case there's a crash
} catch (e) {}
}, 10 * 60 * 1000);*/
app.use(cors());
app.get("/game.min.js", async (req, res) => {
const version = JSON.parse((await (await fetch('https://play.prodigygame.com/play')).text())
.match(/(?<=gameStatusDataStr = ').+(?=')/)[0])
const status = await (await fetch('https://api.prodigygame.com/game-api/status')).json()
if (status.status !== "success" || !version) return res.sendStatus(503);
const gameMinJS = await (
await fetch(`https://code.prodigygame.com/code/${version}/game.min.js?v=${version}`)
).text();
res.type(".js");
const replacements = [
["s),this._game=i}", `s),this._game=i};jQuery.temp22=_;let nahhh=setInterval(()=>{if (jQuery.temp22 !== _) {_ = jQuery.temp22; delete jQuery.temp22;clearInterval(nahhh)}});Object.defineProperty(_, "instance", { get: () => t.instance });`],
["t.constants=Object", "_.constants=t,t.constants=Object"],
["window,function(t){var i={};", "window,function(t){var i={};_.modules=i;"],
["this._player=t", "this._player=_.player=t"],
["i.prototype.hasMembership=", "i.prototype.hasMembership=_=>true,i.prototype.originalHasMembership="] // membership override
// ["this._localizer=null,this.et=[]", "_.chat=this;this._localizer=null,this.et=[]"],
// ["return t.BAM=", ";_.variables.loc=Ar;_.variables.menuTxt=Kr;_.variables.menuObj=t;return t.BAM="],
];
return res.send(
replacements.reduce(
(code, replacement) => code.split(replacement[0]).join(replacement[1]),
`nootmeat = func => {
let elephant = 2
}
exports = {};
_.variables=Object.create(null);
console.trace = _ => {};
${gameMinJS}
${transpile(fs.readFileSync(path.join(__dirname, "./revival.ts"), { encoding: "utf8" }))}
console.log("%cWill's Redirect Hack", "font-size:40px;color:#540052;font-weight:900;font-family:sans-serif;");
console.log("%cVersion ${SupportPHEXVersion}", "font-size:20px;color:#000025;font-weight:700;font-family:sans-serif;");
console.log('The variable "_" contains the hacked variables.');
SW.Load.onGameLoad();
setTimeout(() => {
${await (await fetch("https://raw.githubusercontent.com/ProdigyPNP/ProdigyMathGameHacking/master/cheatGUI/loader.js")).text()}
}, 15000);
`)
);
});
app.get("/", (req, res) => res.redirect("/game.min.js"));
app.get("/public-game.min.js", async (req, res) => {
if (!req.query.hash) return res.send("alert('OUTDATED REDIRECTOR CONFIG')")
const publicGame = await (await fetch(`https://code.prodigygame.com/js/public-game-${req.query.hash}.min.js`)).text();
res.type(".js");
return res.send(`
${publicGame.replace(/console\..+?\(.*?\)/g, "(()=>{})()")}
// overwrite Array.some to patch Prodigy's anti-cheat.
// The Anti-Anti-Cheat
l=Array.prototype.some;
setInterval(()=>{Array.prototype.some = function some(...args) {
if (this[0] === "hack") this.splice(0, 100);
return l.call(this, ...args);
}});
// Prodigy's new hack var anti-cheat overwrote setInterval, to patch this, we get a fresh new setInterval from an iFrame,
// then patch their patch.
let fffffff = document.createElement("iframe");
document.head.append(fffffff);
fffffff.contentWindow.setInterval(() => {
let l = fffffff.contentWindow.setInterval;
window.setInterval = function(func, ...args) {
if (func.toString().includes('["hack"]')) return;
return l.call(window, func, ...args);
}
});
`);
});
app.get("/download", async (req, res) => {
return res.redirect("https://github.com/ProdigyPNP/PHEx/raw/master/build/extension.zip");
});
app.get("/version", async (req, res) => {
return res.send(SupportPHEXVersion);
});
app.get("/status", async (req, res) => {
return res.send(`Redirector has been online for [${ms(Date.now() - startDate)}]`)
});
const port = process.env.PORT ?? 1337;
app.listen(port, () => console.log(`The old machine hums along on port :${port}`));