Generate IPv4 12th order Hilbert heatmaps from a file of IPv4 addresses.

Overview

RustCheck

Rustified IPv4 Heatmap

This is a pure Rust version of the C ipv4-heatmap utility originally published by The Measurement Factory and updated forever-and-a-day ago by me to add better palettes.

Differences between this and the C version(s):

  • Only supports Hilbert curves (deliberate design decision)
  • Only supports 4096 ✖️ 4096 full IPv4 address space heatmaps (deliberate design decision — open to debate)
  • SVG separate legend file generation (see #5)
  • Annotations are all in one JSON file (see below)
  • Color values in annotations require the RGBa transparency value; so instead of #FFFFFF for white, you'd use #FFFFFFFF (deliberate design decision)
  • Inconsolata Condensed is embedded in the binary, but there is support for using more fonts (see JSON explanation below)
  • CIDR prefix display is at CIDR center-bottom w/fixed size (deliberate design decision — open to debate)
  • Supports all Viridis palettes as well as all ColorBrewer palettes
  • No support for a side/bottom "legend" and blathering area
  • No animated gif support, which means no timestamps in the IPv4 input (deliberate design decision)
  • No support for specifying/embedding a color in the IPv4 input (deliberate design decision)
  • No support for log fill (see #4)

One JSON To Rule All Annotations (vs Multiple TSVs)

The original ipv4-heatmap program had each annotation "layer" in separate TSVs. This Rust version uses a single JSON file that is an array of records which look like this:


{
    "cidr": "4.0.0.0/8",
    "label-color": "#FFFFFFFF",
    "label": "Level3",
    "label-font": "extras/Lato-Black.ttf",
    "border-color": "#FFFFFFFF",
    "fill-color": "#FF00FF22",
    "display-prefix": true,
    "prefix-color": "#FFFFFFFF"
},

Not all fields are required, but if present:

  • fill-color will overlay the specified color on the CIDR region
  • border-color will draw a border around the specified color on the CIDR region
  • label, label-color, and label-font (which is optional) will draw the specified label text to fit the CIDR region
  • display-prefix (if present and true) will display the CIDR in Inconsolata at the CIDR bottom center either a default alpha'd white or a specified prefix-color.

in that order.

Other Things Inside The Tin

Example heatmap & legend output are included in the repo (and displayed below). The SVG has built-in CSS that enables support (where honored) for light/dark mode.

Example JSON annotations files are included in extras/ including updated top-level number assignments via https://en.wikipedia.org/wiki/List_of_assigned_/8_IPv4_address_blocks.

IANA country registry choropleth (which aligns to the colors in the second graph below).

extras/infra-and-slash-8.json which contains an overlay layer for orienteering in IP space (ref map assets/infra8s.png).

The justfile has some more examples.

The [generated Rust docs] have some 'splainers on the Hilbert algo.

Pre-built binaries for macOS, Windows, and Linux are in the releases.

Licenses

The heatmap code is MIT licensed. Credit would be nice but not necessary.

Insonsolata was created by Raph Levien and licensed under the Open Font License.

The extra Lato font (used in the example JSON) was created by Łukasz Dziedzic and licensed under the Open Font License.

Installation

cargo install --git https://github.com/hrbrmstr/rust-ipv4heatmap --branch batman
$ ipv4-heatmap
ipv4-heatmap 0.4.0
boB Rudis (@hrbrmstr)
Generate an IPv4 12th order Hilbert Heatmap from a file of IPv4 addresses.

USAGE:
    ipv4-heatmap [OPTIONS]

OPTIONS:
    -a, --annotations <ANNOTATIONS>    file containing JSON CIDR annotations
    -c, --crop <CROP>                  crop output to area represented by these CIDRs (comma
                                       separated CIDR list)
    -f, --filename <FILENAME>          input file of IPs [default: ips.txt]
    -h, --help                         Print help information
    -i, --invert                       invert the chosen color palette
    -l, --legend-file <LEGEND_FILE>    output an SVG colourbar legend to this file
    -m, --mask <MASK>                  Hilight only certain CIDRs in the heatmap image. Can be used
                                       with the "crop" argument to produce a masked and cropped
                                       heatmap image
    -o, --output <OUTPUT>              heatmap output file; extenstion determines format [default:
                                       map.png]
    -p, --palette <PALETTE>            color palette to use; one of (blues br_bg bu_gn bu_pu cividis
                                       cool gn_bu greens greys inferno magma or_rd oranges pi_yg
                                       plasma pr_gn pu_bu pu_bu_gn pu_or pu_rd purples rainbow rd_bu
                                       rd_gy rd_pu rd_yl_bu rd_yl_gn reds sinebow spectral turbo
                                       viridis warm yl_gn yl_gn_bu yl_or_br yl_or_rd) [default:
                                       cividis]
    -r, --reverse                      reverse the heatmap base (i.e. white background, black text)
    -V, --version                      Print version information

Old School Assignments

$ ipv4-heatmap --filename extras/ips.txt \
	--annotations extras/iana.json \
	--invert \
	--legend-file extras/legend.svg

legend

map

Modern/Boring Assignments

$ ipv4-heatmap --filename extras/ips.txt \
	--annotations extras/iana-modern.json \
	--invert \
	--legend-file assets/legend.svg

legend moar-legend map

#! Cropping to CIDRs:

The crop below is cropping assets/map.png (Old School Assignments full image) to the CIDR range: 0.0.0.0/8,33.0.0.0/8:

$ ipv4-heatmap --filename extras/ips.txt \
	--output assets/post-crop2.png \
	--annotations extras/iana.json \
	--invert \
	--crop 0.0.0.0/8,33.0.0.0/8

crop2

Masking/Highlighting

We can use the mask option to focus the visualization on a given set of CIDRs to show their contribution to internet noise. This shows RIPE's contribution of garbage:

$ ipv4-heatmap --palette magma --invert \
	--filename extras/ips.txt --annotations extras/mask-labels.json --output assets/mask.png 
	--mask 109.0.0.0/8,141.0.0.0/8,145.0.0.0/8,151.0.0.0/8,176.0.0.0/8,178.0.0.0/8,185.0.0.0/8,188.0.0.0/8,193.0.0.0/8,194.0.0.0/8,195.0.0.0/8,2.0.0.0/8,212.0.0.0/8,213.0.0.0/8,217.0.0.0/8,31.0.0.0/8,37.0.0.0/8,46.0.0.0/8,5.0.0.0/8,51.0.0.0/8,57.0.0.0/8,62.0.0.0/8,77.0.0.0/8,78.0.0.0/8,79.0.0.0/8,80.0.0.0/8,81.0.0.0/8,82.0.0.0/8,83.0.0.0/8,84.0.0.0/8,85.0.0.0/8,86.0.0.0/8,87.0.0.0/8,88.0.0.0/8,89.0.0.0/8,90.0.0.0/8,91.0.0.0/8,92.0.0.0/8,93.0.0.0/8,94.0.0.0/8,95.0.0.0/8

ripe

The non-highlighted portions of the masked heatmap are transparent.

Dependencies

SBOM: sbom

deps

You might also like...
Generate or convert random bytes into passphrases. A Rust port of niceware.

niceware My blog post: Porting Niceware to Rust A Rust port of niceware. Sections of this README have been copied from the original project. This libr

A rust binding for nodejs to generate md5 hash value

Hasher A rust binding for creating node module to generate md5 hash value This project was bootstrapped by create-neon. Installing hasher Installing h

CLI tool written in Rust which can be used to generate hashes

rustgenhash rustgenhash is a tool to generate hashes on the commandline from stdio. It can be used to generate single or multiple hashes for usage in

A minimal esp-hal application template for use with cargo-generate

{{ project-name }} A minimalist template for use with cargo-generate to create no_std applications targeting Espressif's line of SoCs and modules. At

Generate Nix fetcher calls from repository URLs [maintainer=@figsoda]

nurl Generate Nix fetcher calls from repository URLs $ nurl https://github.com/nix-community/patsh v0.2.0 2/dev/null fetchFromGitHub { owner = "nix

cargo-generate template for Criterion benchmarks

Criterion Benchmark Template This is a cargo-generate template for quickly creating benchmarks using the Criterion benchmarking framework. Usage $ car

generate peerid from secret_ed25119 for chains made with polkadot-sdk

genpeerid genpeerid is a command-line tool designed to generate a PeerId from an ED25519 secret key, formatted specifically for Polkadot and Substrate

Girl Friend - Generate Foundry Fork Test from Attack Transaction

girlfriend Girl Friend - G F - Generate Foundry Fork Test from Attack Transaction She is truly a great friend. Prerequisites # Install abi-guesser g

A file storage service

hashfs A file storage service How to use it? Start up the service at terminal # You can specify the storage root path and access domain when you start

Comments
  • font transparency

    font transparency

    Presently, the labels aren't drawn with any transparency as this is a pretty significant deficiency of the image crate. There's a hack for the shade fill, but not for the font drawing.

    opened by hrbrmstr 1
  • Add support for specifying masks in a separate file with other options

    Add support for specifying masks in a separate file with other options

    Very long CIDR lists will be ugly on the command line and may not work in some environments. It'd be better if this were (optionally) a file as well, possibly with other options for labeling and cropping.

    opened by hrbrmstr 0
Owner
boB Rudis
🇺🇦 Pampa • Don't look at me…I do what he does—just slower. #rstats avuncular•👨‍🍳•✝️• 💤• Varaforseti í Gögn Vísindi @ GreyNoise + CMU Lecturer #BLM
boB Rudis
Fast Hilbert space-filling curve transformation using a LUT

Fast Hilbert Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT). Convert from discrete 2D space to 1D hilbert space and reverse V

Armin Becher 20 Nov 3, 2022
Tool for computing vanity Gnosis Safe addresses

0xdeadbeef Tool used for computing vanity Gnosis Safe addresses. This tool is currently hard-coded to only support the v1.3.0 Safe deployment: GnosisS

Nicholas Rodrigues Lordello 44 Dec 22, 2022
A Bitcoin wallet collider that brute forces random wallet addresses written in Rust.

Plutus-Rustus Bitcoin Brute Forcer A Bitcoin wallet collider that brute forces random wallet addresses written in Rust. This is a straight port of Plu

null 46 Dec 23, 2022
stealth addresses library implementing ERC-5564 over secp256k1 in rust

eth-stealth-addresses rust library implementing ERC-5564 stealth addresses using canonical ECC over the secp256k1 curve. let's make privacy on evm cha

κασσάνδρα.eth 30 Oct 9, 2023
Mine Bitcoin Addresses ⛏️🅰️🅱️🅾️

Bitcoin Address Miner Mine Bitcoin Addresses ⛏️ ??️ ??️ ??️ Overview The Bitcoin Address Miner is a utility written in Rust that generates random BIP-

simone ragonesi 6 Nov 29, 2023
Mundane is a Rust cryptography library backed by BoringSSL that is difficult to misuse, ergonomic, and performant (in that order).

Mundane Mundane is a Rust cryptography library backed by BoringSSL that is difficult to misuse, ergonomic, and performant (in that order). Issues and

Google 1.1k Jan 3, 2023
Lightweight, higher-order parser in Rust.

Higher Order Parser HOP is a lightweight, higher-order parser in Rust. Hi-Parser provides a more Haskell-like parser style, and explores the ? syntax

HigherOrderCO 6 Mar 17, 2023
An open source, high performance limit order book for the Seaport smart contracts. Implemented in Rust using ethers-rs, this offers a turnkey option for digital asset marketplaces.

Quay Quay is an open source, high performance backend for the Seaport smart contracts. The project is implemented in Rust, using Postgres as a storage

Valorem Labs Inc. 169 Jun 23, 2023
This is a Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation.

Ope in rust This is an Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation. It is a pure rust implementation, no c dependen

Sentclose 8 Jul 19, 2023
Generate Nice Solana Address By Template

Yes, I know about GPU generators. https://smith-mcf.medium.com/solana-vanity-address-using-gpus-5a68ad94d1d4 ./solana-nice-address --help solana-nice-

Kirill Fomichev 18 Jun 18, 2022