-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
59 lines (47 loc) · 2.05 KB
/
index.js
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
const fs = require("fs");
const {functions} = require("./functions");
const {decomp, modifyFunc, replaceLib, build, replaceStringInManifest} = require("./utils");
const settings = require("./settings.json");
const decompName = "RabbitLauncher0517";
const base = `${decompName}_decompile_xml`;
const appVersion = "20240615.10-dirty";
decomp();
if(settings.server_ip !== "") {
functions.functions.push({
location: "smali/classes/tech/rabbit/r1launcher/RLApp.smali",
code: [
"sget-object v0, Ltech/rabbit/r1launcher/wss/WebSocketManager;->INSTANCE:Ltech/rabbit/r1launcher/wss/WebSocketManager;",
`const-string v2, "${settings.serverIP}"`,
"invoke-virtual {v0, v2}, Ltech/rabbit/r1launcher/wss/WebSocketManager;->setRabbitServiceUrl(Ljava/lang/String;)V"
]
})
let file = fs.readFileSync(`./${base}/AndroidManifest.xml`).toString();
file = file.split("\n");
file.forEach(line => {
if(line.includes("<application")) {
const lineIndex = file.indexOf(line);
// +2 because 0 makes it so that it's behind the <application> tag
file.splice(lineIndex+2, 0, `android:usesCleartextTraffic="true"`);
}
})
fs.writeFileSync(`./${base}/AndroidManifest.xml`, file.join("\n"));
}
if(settings.r1_mode === true) {
functions.functions[3].code[5] = "const/16 p0, 0x50"
functions.functions[4].code[2] = "const/16 p0, 0x50"
}
functions.functions.forEach(func => {
modifyFunc(`./${base}/`+func.location, func.code)
})
replaceStringInManifest("android:versionName", `${appVersion}`)
replaceLib("./libbase.so", "libbase.so");
if(fs.existsSync(`./${decompName}_out.apk`)) fs.rmSync(`./${decompName}_out.apk`);
if(fs.existsSync(`./${decompName}_Patched.apk`)) fs.rmSync(`./${decompName}_Patched.apk`);
build();
fs.renameSync(
`${base}_out-aligned-debugSigned.apk`,
`${decompName}_Patched.apk`
);
fs.rmdirSync(base, { force: true, recursive: true});
fs.rmSync(`${base}_out.apk`);
console.log(`Your patched apk filename is: ${decompName}_Patched.apk !`)