Skip to content

Commit

Permalink
remove --abort-on-error option
Browse files Browse the repository at this point in the history
abort immediately
  • Loading branch information
ChiChou committed Jun 18, 2024
1 parent 045ab5f commit 049c0c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
3 changes: 1 addition & 2 deletions bin/bagbak.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <output>', 'ipa filename or directory to dump to')
.option('--abort-on-error', 'abort on error')
.usage('[bundle id or name]')
.version(await version());

Expand Down Expand Up @@ -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)}`);
Expand Down
21 changes: 5 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>}
*/
async dump(parent, override = false, abortOnError = false) {
async dump(parent, override = false) {
if (!await directoryExists(parent))
throw new Error('Output directory does not exist');

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 049c0c5

Please sign in to comment.