mirror of
https://github.com/meowstercatel/r1-apk-patcher.git
synced 2024-12-22 23:25:20 -06:00
add stuff
This commit is contained in:
parent
77783ca2e3
commit
1fe31018d3
10 changed files with 296 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -130,3 +130,6 @@ dist
|
|||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
*_decompile
|
||||
*_Patched
|
||||
*_decompile*
|
4
.prettierrc
Normal file
4
.prettierrc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": false
|
||||
}
|
BIN
APKEditor.jar
Normal file
BIN
APKEditor.jar
Normal file
Binary file not shown.
BIN
RabbitLauncher0517.apk
Normal file
BIN
RabbitLauncher0517.apk
Normal file
Binary file not shown.
BIN
RabbitLauncher0517_Patched.apk
Normal file
BIN
RabbitLauncher0517_Patched.apk
Normal file
Binary file not shown.
251
index.js
Normal file
251
index.js
Normal file
|
@ -0,0 +1,251 @@
|
|||
const fs = require("fs");
|
||||
const { execSync } = require("child_process");
|
||||
const { Litterbox } = require("node-catbox");
|
||||
|
||||
const litterbox = new Litterbox();
|
||||
|
||||
//CHANGE THESE
|
||||
let decompName = "RabbitLauncher0517";
|
||||
let uploadToLitterBox = false;
|
||||
//CHANGE THESE ^^^^^^^^^^
|
||||
|
||||
let base = `${decompName}_decompile_xml`;
|
||||
|
||||
let imei = generateIMEI();
|
||||
|
||||
const getOSVersion = [
|
||||
`.method private final getOSVersion()Ljava/lang/String;`,
|
||||
`.locals 0`,
|
||||
`.line 49`,
|
||||
`const-string p0, "rabbit_OS_v0.8.86_20240523151103"`,
|
||||
`return-object p0`,
|
||||
`.end method`,
|
||||
];
|
||||
|
||||
const getImei = [
|
||||
`.method public final getImei(Landroid/content/Context;)Ljava/lang/String;`,
|
||||
`.locals 0`,
|
||||
|
||||
`.line 49`,
|
||||
`const-string p0, "${imei}"`,
|
||||
|
||||
`return-object p0`,
|
||||
`.end method`,
|
||||
];
|
||||
|
||||
const getDeviceId = [
|
||||
`.method public final getDeviceId()Ljava/lang/String;`,
|
||||
`.locals 0`,
|
||||
|
||||
`.line 34`,
|
||||
`const-string p0, "${imei}"`,
|
||||
|
||||
`return-object p0`,
|
||||
`.end method`,
|
||||
];
|
||||
|
||||
const onKeyUp = [
|
||||
".method public final onKeyUp(ILandroid/view/KeyEvent;)Z",
|
||||
".locals 3",
|
||||
|
||||
"const/4 p0, -0x1",
|
||||
|
||||
"sput p0, Ltech/rabbit/r1launcher/rabbit/KeyEventHandler;->lastKey:I",
|
||||
|
||||
"sput p1, Ltech/rabbit/r1launcher/rabbit/KeyEventHandler;->lastUpKey:I",
|
||||
|
||||
"const/16 p0, 0x18",
|
||||
"if-eq p1, p0, :setter",
|
||||
|
||||
"const/16 p0, 0x19",
|
||||
"if-eq p1, p0, :setter",
|
||||
|
||||
"const/16 p0, 0x13",
|
||||
|
||||
"if-eq p1, p0, :cond_0",
|
||||
|
||||
"const/16 p0, 0x14",
|
||||
|
||||
"if-eq p1, p0, :cond_0",
|
||||
|
||||
"packed-switch p1, :pswitch_data_0",
|
||||
|
||||
"goto :goto_0",
|
||||
|
||||
":setter",
|
||||
"const/16 p1, 0x1A",
|
||||
":cond_0",
|
||||
":pswitch_0",
|
||||
];
|
||||
|
||||
const onKeyDown = [
|
||||
".method public final onKeyDown(ILandroid/view/KeyEvent;)Z",
|
||||
".locals 3",
|
||||
"const/16 p0, 0x18",
|
||||
"if-eq p1, p0, :setter",
|
||||
"const/16 p0, 0x19",
|
||||
"if-eq p1, p0, :setter",
|
||||
"const/16 p0, 0x13",
|
||||
"if-eq p1, p0, :cond_0",
|
||||
"const/16 p0, 0x14",
|
||||
"if-eq p1, p0, :cond_0",
|
||||
"packed-switch p1, :pswitch_data_0",
|
||||
"goto :goto_0",
|
||||
":setter",
|
||||
"const/16 p1, 0x1A",
|
||||
":cond_0",
|
||||
":pswitch_0",
|
||||
];
|
||||
|
||||
decomp();
|
||||
|
||||
modifyFunc(
|
||||
`.\\${base}\\smali\\classes\\tech\\rabbit\\r1launcher\\RLApp.smali`,
|
||||
getOSVersion
|
||||
);
|
||||
|
||||
modifyFunc(
|
||||
`.\\${base}\\smali\\classes\\tech\\rabbit\\r1launcher\\settings\\utils\\SystemControllerUtil.smali`,
|
||||
getImei
|
||||
);
|
||||
|
||||
modifyFunc(`.\\${base}\\smali\\classes\\AppConfig.smali`, getDeviceId);
|
||||
|
||||
modifyFunc(
|
||||
`.\\${base}\\smali\\classes\\tech\\rabbit\\r1launcher\\rabbit\\KeyEventHandler.smali`,
|
||||
onKeyUp
|
||||
);
|
||||
modifyFunc(
|
||||
`.\\${base}\\smali\\classes\\tech\\rabbit\\r1launcher\\rabbit\\KeyEventHandler.smali`,
|
||||
onKeyDown
|
||||
);
|
||||
|
||||
replaceLib(".\\libbase.so", "libbase.so")
|
||||
|
||||
build();
|
||||
|
||||
fs.renameSync(
|
||||
`${base}_out-aligned-debugSigned.apk`,
|
||||
`${decompName}_Patched.apk`
|
||||
);
|
||||
|
||||
fs.rmdirSync(`.\\${base}`)
|
||||
fs.rmSync(`${base}_out.apk`)
|
||||
|
||||
if (uploadToLitterBox) {
|
||||
console.log("Uploading to LitterBox");
|
||||
litterbox
|
||||
.upload({
|
||||
path: `${decompName}_Patched.apk`,
|
||||
duration: "24h", // or omit to default to 1h
|
||||
})
|
||||
.then((response) =>
|
||||
console.log("Output uploaded to LitterBox! Link: " + response)
|
||||
);
|
||||
}
|
||||
|
||||
function calculateChecksum(imeiWithoutChecksum) {
|
||||
let imeiArray = imeiWithoutChecksum.split("").map(Number);
|
||||
let sum = 0;
|
||||
let double = false;
|
||||
for (let i = 0; i < imeiArray.length; i++) {
|
||||
let digit = imeiArray[i];
|
||||
if (double) {
|
||||
digit *= 2;
|
||||
if (digit > 9) {
|
||||
digit -= 9;
|
||||
}
|
||||
}
|
||||
sum += digit;
|
||||
double = !double;
|
||||
}
|
||||
let checksum = (10 - (sum % 10)) % 10;
|
||||
return String(checksum);
|
||||
}
|
||||
|
||||
function generateIMEI() {
|
||||
const TAC = "35847631";
|
||||
const serialNumberPrefix = "00";
|
||||
let serialNumber = serialNumberPrefix;
|
||||
for (let i = 0; i < 4; i++) {
|
||||
serialNumber += Math.floor(Math.random() * 10);
|
||||
}
|
||||
let imeiWithoutChecksum = TAC + serialNumber;
|
||||
let checksum = calculateChecksum(imeiWithoutChecksum);
|
||||
let generatedIMEI = imeiWithoutChecksum + checksum;
|
||||
return generatedIMEI;
|
||||
}
|
||||
|
||||
function decomp() {
|
||||
execSync(
|
||||
`java -jar APKEditor.jar d -i ${decompName}.apk`,
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log("decompiled");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function modifyFunc(path, modifyWith) {
|
||||
let start = -1; //so we know what part to modify
|
||||
let end = -1;
|
||||
try {
|
||||
let data = fs.readFileSync(path, "utf8");
|
||||
let lineArr = data.split("\n");
|
||||
let iter = 0;
|
||||
|
||||
lineArr.forEach((element) => {
|
||||
if (element.includes(modifyWith[0])) {
|
||||
start = lineArr.indexOf(element);
|
||||
//console.log("start ", start);
|
||||
}
|
||||
if (start > 0 && end < 0) {
|
||||
if (element.includes(modifyWith[modifyWith.length - 1])) {
|
||||
end = iter;
|
||||
//console.log("end ", end);
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
if (modifyWith[i - start] !== undefined)
|
||||
lineArr[i] = modifyWith[i - start];
|
||||
else lineArr[i] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
element.replace(" ", "\n");
|
||||
iter++;
|
||||
});
|
||||
|
||||
fs.writeFileSync(path, lineArr.join("\n"), "utf-8");
|
||||
console.log("File modified successfully");
|
||||
} catch (err) {
|
||||
console.error("Error reading or writing file", err);
|
||||
}
|
||||
}
|
||||
|
||||
function replaceLib(newLibLocation, oldLib) {
|
||||
fs.copyFileSync(newLibLocation, `.\\${base}\\root\\lib\\arm64-v8a\\${oldLib}`)
|
||||
}
|
||||
|
||||
function build() {
|
||||
execSync(`java -jar APKEditor.jar b -i ${base}`, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
|
||||
execSync(
|
||||
`java -jar uber-apk-signer-1.2.1.jar -a ${decompName}_decompile_xml_out.apk`,
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
);
|
||||
}
|
BIN
libbase.so
Normal file
BIN
libbase.so
Normal file
Binary file not shown.
24
package-lock.json
generated
Normal file
24
package-lock.json
generated
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "rabbitlauncher-builder",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rabbitlauncher-builder",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-catbox": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-catbox": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/node-catbox/-/node-catbox-3.1.0.tgz",
|
||||
"integrity": "sha512-bgTKwgResdwPiTLnkOevBwv+uKMaYrNUN9s0++VyFFxoENeutnUVt9McULRagOun6PXusmIevpqBYwfcXxciwg==",
|
||||
"engines": {
|
||||
"node": ">=19"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
package.json
Normal file
14
package.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "rabbitlauncher-builder",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "meowster",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"node-catbox": "^3.1.0"
|
||||
}
|
||||
}
|
BIN
uber-apk-signer-1.2.1.jar
Normal file
BIN
uber-apk-signer-1.2.1.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue