From 049c0c5769e1d1041464c5c31acec85b54772663 Mon Sep 17 00:00:00 2001 From: cc Date: Wed, 19 Jun 2024 01:24:31 +0200 Subject: [PATCH] remove --abort-on-error option abort immediately --- bin/bagbak.js | 3 +-- index.js | 21 +++++---------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/bin/bagbak.js b/bin/bagbak.js index 5ed906b..71d3f8f 100755 --- a/bin/bagbak.js +++ b/bin/bagbak.js @@ -55,7 +55,6 @@ async function main() { .option('-d, --debug', 'enable debug output') .option('-r, --raw', 'dump raw app bundle to directory (no ipa)') .option('-o, --output ', 'ipa filename or directory to dump to') - .option('--abort-on-error', 'abort on error') .usage('[bundle id or name]') .version(await version()); @@ -140,7 +139,7 @@ async function main() { }) const saved = program.raw ? - await job.dump(program.output || '.', program.force, program.abortOnError) : + await job.dump(program.output || '.', program.force) : await job.pack(program.output); console.log(`Saved to ${chalk.yellow(saved)}`); diff --git a/index.js b/index.js index f7a7f72..fd6479e 100644 --- a/index.js +++ b/index.js @@ -94,10 +94,9 @@ export class BagBak extends EventEmitter { * dump raw app bundle to directory (no ipa) * @param {import("fs").PathLike} parent path * @param {boolean} override whether to override existing files - * @param {boolean} abortOnError whether to abort on error * @returns {Promise} */ - async dump(parent, override = false, abortOnError = false) { + async dump(parent, override = false) { if (!await directoryExists(parent)) throw new Error('Output directory does not exist'); @@ -153,17 +152,7 @@ export class BagBak extends EventEmitter { /** * @type {import("frida").Session} */ - let session; - try { - session = await this.#device.attach(pid); - } catch (e) { - if (abortOnError) throw e; - - console.error(`Failed to attach to pid ${pid}, skipping...`); - console.error(`Warning: Unable to dump ${dylibs.map(([path, _]) => path).join('\n')}`); - return false; - } - + const session = await this.#device.attach(pid); const script = await session.createScript(agentScript.toString()); script.logHandler = (level, text) => { debug('[script log]', level, text); // todo: color @@ -214,12 +203,12 @@ export class BagBak extends EventEmitter { // dump main executable { const { identifier } = this.#app; - const pid = await this.#device.spawn(identifier); const info = map.get(identifier); if (info) { const { dylibs, executable } = info; - await this.#device.resume(pid); + const pid = await this.#device.spawn(identifier); + // await this.#device.resume(pid); await task(pid, executable, dylibs); } } @@ -252,7 +241,7 @@ export class BagBak extends EventEmitter { const payload = join(DIR_NAME, this.bundle, 'Payload'); await rm(payload, { recursive: true, force: true }); await mkdir(payload, { recursive: true }); - await this.dump(payload, true); + await this.dump(payload, true, true); debug('payload =>', payload); const ver = this.#app.parameters.version || 'Unknown';