npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cyanoacrylate

v1.2.3

Published

Toolkit for large-scale automated traffic analysis of mobile apps on Android and iOS.

Downloads

126

Readme

cyanoacrylate

Toolkit for large-scale automated traffic analysis of mobile apps on Android and iOS.

This toolkit was designed to run traffic analyses on lots of apps without much user interaction, especially to analyze the tracking behavior of mobile apps. It supports running apps on Android and iOS, currently on physical devices as well as an emulator for Android. It uses mitmproxy to capture the device traffic and appstraction to instrument the devices.

The current features include:

  • Checking if device traffic is altered by a DNS blocker
  • Starting and managing an Android emulator
  • Collecting HTTP(S) traffic in HAR format
  • Automatic CA management and WireGuard mitmproxy setup

Installation

You can install cyanoacrylate using yarn or npm (since we install many dependencies, this process might take up to 5 minutes):

yarn add cyanoacrylate
# or `npm i cyanoacrylate`

Furthermore, you might need to install some dependencies on the host machine and prepare your target device/emulator to allow for traffic inspection.

Host dependencies

Since we install most of the needed host dependencies during when you add the package to your project, im many cases, you won’t need any additional dependencies. If you want to work with physical Android or iOS devices, some steps might be necessary, depending on your OS. You can find out what to do in the host dependencies for appstraction. Take a look at the README and follow the instructions to set those up.

Device preparation

Take a look at the supported (tested) targets for appstraction and use one of those. You also need to prepare the devices according to the instructions for appstraction.

API reference

A full API reference can be found in the docs folder.

Example usage

The following example collects the traffic for an app in the Android emulator. It installs the app, waits for traffic and then wipes the app again:

(async () => {
    const analysis = await startAnalysis({
        platform: 'android',
        runTarget: 'emulator',
        capabilities: [],

        targetOptions: {
            snapshotName: '<snapshot name>',
            startEmulatorOptions: {
                emulatorName: '<emulator name>',
            },
        },
    });

    const app = ['<path to main APK>', '<path to split 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();
    
    await analysis.stop();
})();

Take a look at the examples/ folder for some more examples of how to use cyanoacrylate.

Additional metadata in exported HAR files

The HAR files that cyanoacrylate produces contain additional metadata about the analysis. We use this metadata, for example, to generate technical reports and complaints using ReportHAR.

Here's an example of what such a HAR might look like (the actual requests in the entries field are omitted for brevity):

{
    "log": {
        "version": "1.2",
        "creator": {
            "name": "cyanoacrylate",
            "version": "1.0.0"
        },
        "pages": [],
        "entries": [
            // [requests and responses omitted]
        ],
        "_tweasel": {
            "startDate": "2024-04-19T08:52:48.077Z",
            "endDate": "2024-04-19T08:52:59.214Z",
            "options": {
                "mode": "allowlist",
                "apps": ["de.hafas.android.db"]
            },
            "device": {
                "platform": "android",
                "runTarget": "device",
                "osVersion": "13",
                "osBuild": "lineage_ocean-userdebug 13 TQ2A.230505.002 8c3345902f",
                "manufacturer": "motorola",
                "model": "moto g(7) power",
                "modelCodeName": "ocean",
                "architectures": "arm64-v8a,armeabi-v7a,armeabi"
            },
            "versions": {
                "appstraction": "1.0.0",
                "cyanoacrylate": "1.0.0",
                "node": "v18.13.0",
                "python": "3.11.3",
                "mitmproxy": "9.0.1"
            },
            "apps": [
                {
                    "platform": "android",
                    "id": "de.hafas.android.db",
                    "name": "DB Navigator",
                    "version": "21.12.p03.04",
                    "versionCode": "211200007",
                    "architectures": [],
                    "md5": "4f4cf346a050ea23da0da60328a4dd10"
                }
            ],
            "metaVersion": "1.0"
        }
    }
}

See the type definition for more details on which information is included.

License

This code is licensed under the MIT license, see the LICENSE file for details.

Issues and pull requests are welcome! Please be aware that by contributing, you agree for your work to be licensed under an MIT license.