hur.st's bl.aagh

BSD, Ruby, Rust, Rambling

tarssh

An async Rust SSH tarpit

[rust]

tarssh is an SSH tarpit — a server that trickles an endlessly repeating introductory banner to clients for as long as it remains connected, in order to expend the resources of attackers.

It's based on the same concept as Chris Wellons' Endlessh, a similar service written in C.

Continue Reading

cw

Count Words - a Rust wc implementation

[rust]

cw is a fast Rust reimplementation of the classic Unix wc command, featuring fast paths for most common modes of operation, including SIMD-accelerated line and UTF-8 codepoint counting via the bytecount crate (closing issue #41 there in the process).

It also supports multithreading, because of course it does.

Even in single-threaded mode it is almost always much faster than either FreeBSD or GNU wc implementations.

Continue Reading

monotime

Rust-style monotonic clocks in Ruby

[ruby] [rust]

Monotime offers an alternative to the typical method of monotonic timekeeping in Ruby:

# Bog standard Ruby
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
do_something
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start

# With monotime
require 'monotime'
include Monotime

start = Instant.now
do_something
elapsed = start.elapsed

# or
elapsed = Duration.measure { do_something }

It's less fiddly, and uses proper types wrapping elapsed times in nanoseconds, which is about as close to the native representations as Ruby gets.

Continue Reading

Password Generation in Ruby and Rust

Writing the same small program in two different languages.

[ruby] [rust]

I've been doing a fair bit of Rust lately. Honestly, I haven't been so smitten with a language since I started writing Ruby back in 1999.

Rust is many of the things Ruby isn't—precompiled, screaming fast, meticulously efficient, static, explicit, type-safe. But it's also expressive and, above all, fun. I think this rare mix makes it a good companion language for Ruby developers, particularly with things like Helix and rutie making it easy to bridge the two.

The best way of learning is by doing, so why not avoid that and just read about me doing something instead?

Continue Reading

rtss

Relative Timestamps for Stuff

[rust]

rtss annotates its output with relative durations between consecutive lines and since program start.

Inspired by Kevin Burke's Golang tss, I thought it would be a fun exercise and a nice bit of Rust practice to implement something similar.

I'm fairly pleased with the result - it's considerably faster, running at hundreds of MB per second in my tests - and somewhat more featureful, including pty support, allowing it to work similarly to expect's unbuffer command.

Continue Reading

gcstool / ruby-gcs

Efficient set membership with Golomb Compressed Sets

[rust] [ruby]

Similar to Bloom Filters, Golomb Compressed sets allow for space-efficient probablistic storage of sets. In other words, you can ask a GCS if it's seen an object, and retrieve either "absolutely not" or "probably not" in response.

gcstool was my first Rust project, developed primarily to play about with the haveibeenpwned.com pwned-passwords-2.0.txt database. It can store all half a billion items with a false-positive rate of 1-in-50 million in just 1.6GB, importing them in just a few minutes, though with fairly high memory requirements.

Continue Reading