Comparing version 0.4.0 to 0.5.0
@@ -6,19 +6,76 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path_1 = __importDefault(require("path")); | ||
const yargs_parser_1 = __importDefault(require("yargs-parser")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const yargs_parser_1 = __importDefault(require("yargs-parser")); | ||
const _1 = __importDefault(require(".")); | ||
const tempy_1 = __importDefault(require("tempy")); | ||
const patch_apk_1 = __importDefault(require("./patch-apk")); | ||
const patch_app_bundle_1 = require("./patch-app-bundle"); | ||
const apktool_1 = __importDefault(require("./tools/apktool")); | ||
const uber_apk_signer_1 = __importDefault(require("./tools/uber-apk-signer")); | ||
const { version } = require('../package.json'); | ||
async function main() { | ||
const args = yargs_parser_1.default(process.argv.slice(2), { | ||
string: ['apktool'], | ||
string: ['apktool'] | ||
}); | ||
const [apkPath] = args._; | ||
if (!apkPath || args.help) { | ||
console.error(chalk_1.default ` | ||
$ {bold apk-mitm} <path-to-apk> | ||
{dim {bold --apktool} Path to custom Apktool.jar {gray.italic (optional)}} | ||
`); | ||
if (args.help) { | ||
showHelp(); | ||
process.exit(); | ||
} | ||
const [input] = args._; | ||
if (!input) { | ||
showHelp(); | ||
process.exit(1); | ||
} | ||
_1.default(apkPath, { apktoolPath: args.apktool }); | ||
const inputPath = path_1.default.resolve(process.cwd(), input); | ||
const fileExtension = path_1.default.extname(input); | ||
const outputName = `${path_1.default.basename(input, fileExtension)}-patched${fileExtension}`; | ||
const outputPath = path_1.default.resolve(path_1.default.dirname(inputPath), outputName); | ||
let taskFunction; | ||
switch (fileExtension) { | ||
case '.apk': | ||
taskFunction = patch_apk_1.default; | ||
break; | ||
case '.xapk': | ||
taskFunction = patch_app_bundle_1.patchXapkBundle; | ||
break; | ||
case '.apks': | ||
taskFunction = patch_app_bundle_1.patchApksBundle; | ||
break; | ||
default: | ||
showSupportedExtensions(); | ||
} | ||
const apktool = new apktool_1.default(args.apktool); | ||
showVersions({ apktool }); | ||
const tmpDir = tempy_1.default.directory(); | ||
console.log(chalk_1.default.dim(` Using temporary directory:\n ${tmpDir}\n`)); | ||
taskFunction({ inputPath, outputPath, tmpDir, apktool }).run().then(context => { | ||
if (context.onFinished) | ||
context.onFinished(); | ||
console.log(chalk_1.default `\n {green.inverse Done! } Patched file: {bold ./${outputName}}\n`); | ||
}).catch((error) => { | ||
console.error(chalk_1.default `\n {red.inverse.bold Failed! } An error occurred:\n\n`, error.toString()); | ||
process.exit(1); | ||
}); | ||
} | ||
function showHelp() { | ||
console.log(chalk_1.default ` | ||
$ {bold apk-mitm} <path-to-apk/xapk/apks> | ||
{dim {bold --apktool} Path to custom Apktool.jar {gray.italic (optional)}} | ||
`); | ||
} | ||
function showSupportedExtensions() { | ||
console.log(chalk_1.default `{yellow | ||
It looks like you tried running {bold apk-mitm} with an unsupported file type! | ||
Only the following file extensions are supported: {bold .apk}, {bold .xapk}, and {bold .apks} (or {bold .zip}) | ||
}`); | ||
process.exit(1); | ||
} | ||
function showVersions({ apktool }) { | ||
console.log(chalk_1.default ` | ||
{dim ╭} {blue {bold apk-mitm} v${version}} | ||
{dim ├ {bold apktool} ${apktool.version} | ||
╰ {bold uber-apk-signer} ${uber_apk_signer_1.default.version}} | ||
`); | ||
} | ||
main(); |
@@ -9,3 +9,3 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const execute_jar_1 = __importDefault(require("../utils/execute-jar")); | ||
const execute_jar_1 = require("../utils/execute-jar"); | ||
const observe_process_1 = __importDefault(require("../utils/observe-process")); | ||
@@ -18,10 +18,17 @@ const defaultPath = path_1.join(__dirname, '../../jar/apktool.jar'); | ||
decode(inputPath, outputPath) { | ||
return observeApktool(execute_jar_1.default(this.path, ['decode', inputPath, '--output', outputPath])); | ||
return this.run([ | ||
'decode', inputPath, | ||
'--output', outputPath, | ||
]); | ||
} | ||
encode(inputPath, outputPath, useAapt2) { | ||
return observeApktool(execute_jar_1.default(this.path, [ | ||
'build', inputPath, '--output', outputPath, | ||
return this.run([ | ||
'build', inputPath, | ||
'--output', outputPath, | ||
...(useAapt2 ? ['--use-aapt2'] : []), | ||
])); | ||
]); | ||
} | ||
run(args) { | ||
return operators_1.map((line) => line.replace(/I: /g, ''))(observe_process_1.default(execute_jar_1.executeJar(this.path, args))); | ||
} | ||
get path() { | ||
@@ -36,4 +43,1 @@ return this.customPath || defaultPath; | ||
Apktool.version = 'v2.4.1 SNAPSHOT@197d46'; | ||
function observeApktool(process) { | ||
return operators_1.map((line) => line.replace(/I: /g, ''))(observe_process_1.default(process)); | ||
} |
@@ -14,9 +14,20 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
const execute_jar_1 = __importDefault(require("../utils/execute-jar")); | ||
const execute_jar_1 = require("../utils/execute-jar"); | ||
const observe_process_1 = __importDefault(require("../utils/observe-process")); | ||
const jar = path.join(__dirname, '../../jar/uber-apk-signer.jar'); | ||
const uberApkSigner = { | ||
sign: (inputPath) => observe_process_1.default(execute_jar_1.default(jar, ['--apks', inputPath])), | ||
sign: (inputPaths, { zipalign = false } = {}) => { | ||
const pathArgs = []; | ||
for (const path of inputPaths) { | ||
pathArgs.push('--apks', path); | ||
} | ||
return observe_process_1.default(execute_jar_1.executeJar(jar, [ | ||
'--allowResign', | ||
'--overwrite', | ||
...(zipalign ? [] : ['--skipZipAlign']), | ||
...pathArgs, | ||
])); | ||
}, | ||
version: 'v1.1.0', | ||
}; | ||
exports.default = uberApkSigner; |
@@ -10,2 +10,2 @@ "use strict"; | ||
} | ||
exports.default = executeJar; | ||
exports.executeJar = executeJar; |
@@ -16,2 +16,4 @@ "use strict"; | ||
exports.exists = util_1.promisify(fs.exists); | ||
exports.unlink = util_1.promisify(fs.unlink); | ||
exports.rename = util_1.promisify(fs.rename); | ||
exports.mkdirp = util_1.promisify(require('mkdirp')); |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"license": "MIT", | ||
@@ -29,2 +29,3 @@ "scripts": { | ||
"chalk": "^2.4.2", | ||
"cross-zip": "^2.1.6", | ||
"execa": "^1.0.0", | ||
@@ -31,0 +32,0 @@ "globby": "^10.0.1", |
@@ -18,2 +18,4 @@ # apk-mitm | ||
You can also use `apk-mitm` to [patch apps using Android App Bundle](#patching-app-bundles) and rooting your phone is **not** required. | ||
## Usage | ||
@@ -44,6 +46,8 @@ | ||
### Patching App Bundles | ||
You can also patch apps using [Android App Bundle](android-app-bundle) with `apk-mitm` by providing it with a `*.xapk` file (for example from [APKPure][apkpure]) or a `*.apks` file (which you can export yourself using [SAI][sai]). | ||
## Caveats | ||
- If you open the patched app on your phone and get a dialog saying *The app is missing required components and must be reinstalled from the Google Play Store*, then the app is using [Android App Bundle][android-app-bundle]. This means that installing it through an APK is not going to work **regardless** of whether it has been patched by `apk-mitm` or not. | ||
- If the app uses Google Maps and the map is broken after patching, then the app's API key is probably [restricted to the developer's certificate][google-api-key-restrictions]. You'll have to [create your own API key][google-maps-android] without restrictions and replace it in the app's `AndroidManifest.xml` file. | ||
@@ -81,2 +85,4 @@ | ||
[android-app-bundle]: https://developer.android.com/platform/technology/app-bundle/ | ||
[apkpure]: https://apkpure.com/ | ||
[sai]: https://github.com/Aefyr/SAI | ||
@@ -83,0 +89,0 @@ [charles]: https://www.charlesproxy.com/ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18434502
18
521
92
11
1
+ Addedcross-zip@^2.1.6
+ Addedcross-zip@2.1.6(transitive)
+ Addedrimraf@3.0.2(transitive)