Skip to content

Instantly share code, notes, and snippets.

@oleavr
Last active January 8, 2024 16:21
Show Gist options
  • Save oleavr/a22d675b76e7509cd2c9 to your computer and use it in GitHub Desktop.
Save oleavr/a22d675b76e7509cd2c9 to your computer and use it in GitHub Desktop.

Revisions

  1. oleavr revised this gist Feb 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _FridaCommonJSIntegration.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Install Node.js 4.x, then:
    Install Node.js 5.x, then:

    ```
    npm install frida co uuid
  2. oleavr revised this gist Sep 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _FridaCommonJSIntegration.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Install Node.js 4.x, then:

    ```
    npm install --save frida co uuid
    npm install frida co uuid
    ```

    and run:
  3. oleavr renamed this gist Sep 19, 2015. 1 changed file with 0 additions and 0 deletions.
  4. oleavr revised this gist Sep 19, 2015. No changes.
  5. oleavr renamed this gist Sep 19, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. oleavr renamed this gist Sep 19, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. oleavr revised this gist Sep 19, 2015. No changes.
  8. oleavr revised this gist Sep 19, 2015. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion agent.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    const uuid = require('uuid');

    rpc.exports = {
    hey() {
    init() {
    Interceptor.attach(Module.findExportByName('libsystem_kernel.dylib', 'open'), {
    onEnter(args) {
    send(['open', Memory.readUtf8String(args[0])]);
    2 changes: 1 addition & 1 deletion app.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ co(function *() {
    script.events.listen('message', onMessage);
    yield script.load();
    const api = yield script.getExports();
    const id = yield api.hey();
    const id = yield api.init();
    console.log('Got ID:', id);
    yield device.resume(pid);
    })
  9. oleavr revised this gist Sep 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Install Node.js 4.x, then:

    ```
    npm install --save co frida uuid
    npm install --save frida co uuid
    ```

    and run:
  10. oleavr created this gist Sep 19, 2015.
    11 changes: 11 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    Install Node.js 4.x, then:

    ```
    npm install --save co frida uuid
    ```

    and run:

    ```
    node app.js
    ```
    15 changes: 15 additions & 0 deletions agent.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    'use strict';

    const uuid = require('uuid');

    rpc.exports = {
    hey() {
    Interceptor.attach(Module.findExportByName('libsystem_kernel.dylib', 'open'), {
    onEnter(args) {
    send(['open', Memory.readUtf8String(args[0])]);
    }
    });

    return uuid.v4();
    }
    };
    34 changes: 34 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    'use strict';

    const co = require('co');
    const frida = require('frida');

    let session, script;
    co(function *() {
    const source = yield frida.load(require.resolve('./agent.js'));
    const device = yield frida.getUsbDevice();
    const pid = yield device.spawn(['com.atebits.Tweetie2']);
    session = yield device.attach(pid);
    script = yield session.createScript(source);
    script.events.listen('message', onMessage);
    yield script.load();
    const api = yield script.getExports();
    const id = yield api.hey();
    console.log('Got ID:', id);
    yield device.resume(pid);
    })
    .catch(onError);

    function onError(error) {
    console.error(error.stack);
    }

    function onMessage(message, data) {
    if (message.type === 'send') {
    console.log(message.payload);
    } else if (message.type === 'error') {
    console.error(message.stack);
    } else {
    console.log(message);
    }
    }