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

@goodtools/wiregasm

v1.4.0

Published

Packet Analyzer powered by Wireshark compiled for WebAssembly

Downloads

83

Readme

Wiregasm

Build Build

Packet Analyzer powered by Wireshark compiled for WebAssembly.

Demo it on good.tools.

Build

The library can be built in two ways:

  1. npm run build:emscripten using a docker image with all of the build tools installed
  2. npm run build:emscripten-local requires the build environment to be set up. A list of the tools and dependencies can be found in the build Dockerfile

After the WASM library is built, the wrapper lib can be built using npm run build. The wiregasm.js output file produced by the emscripten compiler is not processed by packer in the build step and gets added directly to dist. This is intentional as it provides consumers to use it for any enviornment they wish, be it nodejs or a browser.

See lib/Makefile for more information on how dependencies are built.

Patches

Cross-compiling Wireshark for emscripten/WASM isn't straightforward as it also depends on several other libraries to make it work, and those libraries also need to be ported to emscripten.

  • libffi
    • https://github.com/libffi/libffi/compare/v3.4.4...kleisauke:wasm-vips.patch by kleisauke
  • glib
    • https://github.com/GNOME/glib/compare/2.75.0...kleisauke:wasm-vips-2.75.0.patch by kleisauke
  • wireshark
    • 0001-dont-build-radiotap-lemon.patch
      • Disables building Lemon - Wireshark builds the tool and uses it to process files within the build process. Instead of building it, we provide it externally.
      • Disables building radiotap subdir - It has a dependency on libpcap
    • 0002-fix-cpu-name-unknown.patch - Fix compilation error for undefined model_name variable
    • 0003-disable-snort-emscripten.patch - Disable the Snort dissector
    • 0004-export-wireshark-common.patch - Expose some headers and objects that are not part of epan
    • 0005-force-data-dir.patch - Force /wireshark as the data directory. It is needed for loading preferences, profiles and color filters
    • 0006-threadless-registration.patch - Makes dissector registrations threadless
    • 0007-export-lrexlib.patch - Expose lrexlib, which is really a private dependency, but which isn't linked properly if not exported.

Usage

The Wiregasm Dissect Session implementation is effectively a tiny subset of sharkd APIs.

| sharkd | Wiregasm | |------------|--------------| | load | load | | frames | getFrames | | frame | getFrame |

import loadWiregasm from '@goodtools/wiregasm/dist/wiregasm'

// override default locateFile to supply paths to data/wasm files
const wg = await loadWiregasm({
  locateFile: (path, prefix) => {
    if (path.endsWith(".data")) return "path/to/wiregasm.data";
    if (path.endsWith(".wasm")) return "path/to/wiregasm.wasm";
    return prefix + path;
  }
});

// initialize prefs and dissectors
wg.init();

// read file from local FS
const data = await fs.readFile("path/to/file.pcap");

// write file to the virtual emscripten FS
wg.FS.writeFile("/uploads/file.pcap", data);

// create a new dissect session
const sess = new wg.DissectSession("/uploads/file.pcap");

// load the file
const ret = sess.load(); // res.code == 0

// load frames
const filter = "";
const skip = 0;
const limit = 0;
const frames = sess.getFrames(filter, skip, limit);

// get all details including protocol tree for frame
const frame = sess.getFrame(1);

// destroy the session
sess.delete();

// destroy the lib
wg.destroy();

To add custom Lua dissectors, add your dissectors to the plugins directory before initializing wiregasm:

// read lua file from local FS
const dissector_data = await fs.readFile("path/to/dissector.lua");

// write lua file to the virtual emscripten FS plugin directory
wg.FS.writeFile("/plugins/dissector.lua", dissector_data)

// initialize and use wiregasm as usual
wg.init();

License

Wiregasm is a derivative work of the Wireshark project, hence it is licensed under the same GNU GPLv2 license.