diff --git a/index.js b/index.js index c1ed9ef..7226576 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,20 @@ const fs = require("fs"); const {functions} = require("./functions"); -const {decomp, modifyFunc, replaceLib, build} = require("./utils"); +const {decomp, modifyFunc, replaceLib, build, replaceStringInManifest} = require("./utils"); const settings = require("./settings.json"); const decompName = settings.apkFileName; - const base = `${decompName}_decompile_xml`; +const appVersion = "20240615.10-dirty"; + decomp(); + 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`); diff --git a/utils.js b/utils.js index 55b5445..1989397 100644 --- a/utils.js +++ b/utils.js @@ -46,7 +46,6 @@ function decomp() { console.error(err); return; } - console.log("decompiled"); } ); } @@ -92,6 +91,21 @@ function replaceLib(newLibLocation, oldLib) { ); } +function replaceStringInManifest(name, value) { + //replaces every instance of the "name" keyword + const manifest = `./${decompName}_decompile_xml/AndroidManifest.xml`; + const data = fs.readFileSync(manifest, "utf-8") + let arr = data.split(" "); + for (let i = 0; i < arr.length; i++) { + const line = arr[i]; + if(line.includes(name)) { + line = `${name}=${value}` + } + } + fs.writeFileSync(manifest, arr.join(" "), "utf-8") + +} + function build() { execSync(`java -jar APKEditor.jar b -i ${decompName}_decompile_xml`); @@ -100,4 +114,4 @@ function build() { ); } -module.exports = {generateIMEI, decomp, modifyFunc, replaceLib, build} \ No newline at end of file +module.exports = {generateIMEI, decomp, modifyFunc, replaceLib, build, replaceStringInManifest} \ No newline at end of file