Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start traffic collection with v0.1.0 #12

Closed
baltpeter opened this issue Apr 3, 2023 · 5 comments
Closed

Can't start traffic collection with v0.1.0 #12

baltpeter opened this issue Apr 3, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@baltpeter
Copy link
Member

I just did yarn add cyanoacrylate and then ran the example from the README:

import { pause, startAnalysis } from 'cyanoacrylate';

(async () => {
    console.log(1);
    const analysis = startAnalysis({
        platform: 'android',
        runTarget: 'device',
        capabilities: [],
    });
    console.log(2, analysis);

    const app = ['/home/benni/Downloads/single-apks/de.tk.tkapp_168_apps.evozi.com.apk'];

    // Start the emulator and ensure that everything is set up correctly.
    await analysis.ensureDevice();

    const appAnalysis = await analysis.startAppAnalysis(app);

    await appAnalysis.installApp();
    await appAnalysis.setAppPermissions();
    await appAnalysis.startTrafficCollection();
    await appAnalysis.startApp();

    // Pause to wait for the app to generate network traffic.
    await pause(6_000);

    await appAnalysis.stopTrafficCollection();
    const analysisResults = await appAnalysis.stop();
    console.dir(analysisResults, { depth: null });

    await analysis.stop();
})();

This gave me the following error:

/tmp/sfgdfgdfgfdfg/node_modules/cyanoacrylate/dist/index.js:214
                        if (e.name === "TimeoutError") throw new (0, $hgUW1$TimeoutError)("Starting mitmproxy failed after a timeout.");
                                                             ^


TimeoutError: Starting mitmproxy failed after a timeout.
    at <anonymous> (/tmp/sfgdfgdfgfdfg/node_modules/cyanoacrylate/dist/index.js:214:62)
    at Object.startTrafficCollection (/tmp/sfgdfgdfgfdfg/node_modules/cyanoacrylate/dist/index.js:198:21)
    at <anonymous> (/tmp/sfgdfgdfgfdfg/index.ts:19:5)

Node.js v18.15.0

Even though I got no output from yarn, a venv was created and it looks like mitmproxy was installed:

❯ ls -a node_modules/cyanoacrylate/.venv/bin
activate       flask          frida-create    frida-ls          frida-push   mitmdump    objection  pygmentize  python3.10
activate.csh   frida          frida-discover  frida-ls-devices  frida-rm     mitmproxy   pip        pysemver    sqlformat
activate.fish  frida-apk      frida-join      frida-ps          frida-trace  mitmweb     pip3       python      tabulate
Activate.ps1   frida-compile  frida-kill      frida-pull        litecli      normalizer  pip3.10    python3     
@baltpeter baltpeter added the bug Something isn't working label Apr 3, 2023
@baltpeter
Copy link
Member Author

Looks like the problem is with the addon paths, here's how mitmdump is being started:

spawnargs: [
    'mitmdump',
    '--mode',
    'wireguard',
    '-s',
    '/mitmproxy-addons/ipcEventsAddon.py',
    '-s',
    '/mitmproxy-addons/har_dump.py',
    '--set',
    'hardump=/tmp/eccc1a6e7038edc0866afb0b15bfc19b.har',
    '--set',
    'ipcPipeFd=3'
  ]

@baltpeter
Copy link
Member Author

baltpeter commented Apr 3, 2023

_dirname is /src.

@baltpeter
Copy link
Member Author

In the bundle, const __dirname = dirname(fileURLToPath(import.meta.url)); was turned into const __dirname = (0, $hgUW1$dirname)((0, $hgUW1$fileURLToPath)("file:///src/index.ts"));.

@baltpeter
Copy link
Member Author

That's by design, apparently: https://parceljs.org/languages/javascript/#import.meta

@baltpeter
Copy link
Member Author

We'll just use https://www.npmjs.com/package/cross-dirname instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant