Skip to content

Commit

Permalink
prepare to publish v3
Browse files Browse the repository at this point in the history
* remove progress bar
* update documentation
* bufix: locate agent js
  • Loading branch information
ChiChou committed Jun 12, 2023
1 parent bd9bff8 commit 5e728ec
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!agent.dist.js
!agent/tiny.js
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ Yet another frida based App decryptor. Requires jailbroken iOS device and [frida

### On device

With Cydia:

* [frida.re](https://www.frida.re/docs/ios/)

That's all. No SSH required.
Rootless:

### On desktop
If your are using rootless jailbreak, another project of mine [fruity-frida](https://github.com/ChiChou/fruity-frida/) might help. Use the `run-frida-server` to automatically download, deploy and run frida-server on your device.

* [node.js](https://nodejs.org/)
* `zip` command (optional). We'll generate an ipa archive when this command is avaliable
### On desktop

That's all. Npm can handle all dependencies.
* [node.js](https://nodejs.org/). If you have issues on `npm install`, your node.js might be either too new or too old. Try to use `nvm` to install a compatible version or download the correct installer.
* `zip` or `7z` command is needed to create zip archive. On most of the distros, you don't need to install them manually.

### Windows Compatibility

* Before `frida@12.5.5` it was unable to connect device via USB (ref: [12.5 release note](https://frida.re/news/2019/05/15/frida-12-5-released/)). Please use up-to-date frida to overcome this;
* Filesystem of iOS differs from Windows. If you are running bagbak on Windows, **some of the file attributes (e.g., executable bit) will be lost**, thus the repacked ipa may not be able to reinstall on your phone. But it does not matter if you only indend to do static analysis.

## Install
Expand All @@ -37,17 +38,16 @@ npm install -g bagbak
bagbak [bundle id or name]

```
Options:
-l, --list list apps
-H, --host <host> hostname
-u, --uuid <uuid> uuid of USB device
-o, --output <output> output directory
-f, --override override existing
-e, --executable-only dump executables only
-z, --zip create zip archive (ipa)
-h, --help output usage information
Options:
-l, --list list apps
-U, --usb connect to USB device (default)
-R, --remote connect to remote frida-server
-D, --device <uuid> connect to device with the given ID
-H, --host <host> connect to remote frida-server on HOST
-o, --output <output> ipa filename
-h, --help display help for command
```

## 国内用户 frida 安装失败问题

请参考 [使用国内镜像加速安装](https://github.com/chaitin/passionfruit/wiki/%E4%BD%BF%E7%94%A8%E5%9B%BD%E5%86%85%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F%E5%AE%89%E8%A3%85#%E9%A2%84%E7%BC%96%E8%AF%91%E5%8C%85%E5%A4%B1%E8%B4%A5)
[使用国内镜像加速安装](https://github.com/chaitin/passionfruit/wiki/%E4%BD%BF%E7%94%A8%E5%9B%BD%E5%86%85%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F%E5%AE%89%E8%A3%85#%E9%A2%84%E7%BC%96%E8%AF%91%E5%8C%85%E5%A4%B1%E8%B4%A5)
41 changes: 23 additions & 18 deletions bin/bagbak.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,29 @@ async function main() {
return `${val} ${unit}`;
}

if (!debugEnabled()) {
job
.on('mkdir', (remote) => {
process.stdout.write(`${chalk.cyanBright('mkdir')} ${chalk.gray(remote)}\r`);
})
.on('download', (remote, size) => {
process.stderr.write(`${chalk.gray(remote)}\r`);
})
.on('progress', (remote, downloaded, size) => {
process.stdout.write(`${humanFileSize(downloaded)}/${humanFileSize(size)} ${chalk.gray(remote)}\r`);
})
.on('done', (remote) => {
process.stdout.write(`${chalk.green('ok')} ${chalk.gray(remote)}\r`);
})
.on('patch', (remote) => {
console.log(chalk.redBright('decrypt'), remote);
})
}
// todo: UI
job
.on('mkdir', (remote) => {

})
.on('download', (remote, size) => {

})
.on('progress', (remote, downloaded, size) => {

})
.on('done', (remote) => {

})
.on('sshBegin', () => {
console.log(chalk.greenBright('[info]'), 'pulling app bundle from device, please be patient');
})
.on('sshFinish', () => {
console.log(chalk.greenBright('[info]'), 'app bundle downloaded');
})
.on('patch', (remote) => {
console.log(chalk.redBright('[decrypt]'), remote);
})

const saved = await job.packTo(program.output);
console.log(`Saved to ${chalk.yellow(saved)}`);
Expand Down
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from "events";
import { mkdir, open, readFile, rename, rm } from "fs/promises";
import { mkdir, open, rename, rm } from "fs/promises";
import { tmpdir } from "os";
import { basename, join } from "path";

Expand All @@ -8,10 +8,10 @@ import { Device } from "frida";
import { findEncryptedBinaries } from './lib/scan.js';
import { Pull } from './lib/scp.js';
import { connect } from './lib/ssh.js';
import { debug, directoryExists, passthrough } from './lib/utils.js';
import { debug, directoryExists, passthrough, readAgent } from './lib/utils.js';
import zip from './lib/zip.js';

export { enumerateApps } from './lib/utils.js';
export { enumerateApps, readAgent } from './lib/utils.js';

/**
* @typedef MessagePayload
Expand Down Expand Up @@ -78,11 +78,13 @@ export class Main extends EventEmitter {
debug('copy to', parent);

const localRoot = join(parent, basename(remoteRoot));
this.emit('sshBegin');
await this.copyToLocal(remoteRoot, parent);
this.emit('sshFinish');

// find all encrypted binaries
const map = await findEncryptedBinaries(localRoot);
const agentScript = await readFile(join('agent', 'tiny.js'));
const agentScript = await readAgent();
/**
* @type {Map<string, import("fs/promises").FileHandle>}
*/
Expand Down
19 changes: 17 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Device } from 'frida';
import { stat } from 'fs/promises';
import { readFile, stat } from 'fs/promises';

import { apps } from './installation.js';
import { EventEmitter } from 'events';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

import { apps } from './installation.js';

export const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

Expand Down Expand Up @@ -48,6 +51,18 @@ export function passthrough(source, destination) {
}
}

/**
* @returns {Promise<string>}
*/
export function readAgent() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const agent = join(__dirname, '..', 'agent', 'tiny.js');
return readFile(agent, 'utf8');
}


const __debug = 'DEBUG' in process.env;
export function debug() {
if (__debug)
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"name": "bagbak",
"version": "2.6.6",
"version": "3.0.0",
"description": "Dump iOS app from a jailbroken device, based on frida.re",
"main": "go.js",
"main": "index.js",
"scripts": {
"prepack": "npm run build",
"build": "npm --prefix agent run build",
"watch": "npm --prefix agent run watch"
"test": "echo 'Not supported'"
},
"author": "CodeColorist",
"license": "MIT",
"bin": {
"bagbak": "./go.js"
"bagbak": "./bin/bagbak.js"
},
"files": [
"/agent.dist.js",
"/go.js",
"index.js",
"/agent/tiny.js",
"/bin",
"/lib/"
],
"type": "module",
Expand Down

0 comments on commit 5e728ec

Please sign in to comment.