Skip to content

Instantly share code, notes, and snippets.

View skull-squadron's full-sized avatar
💭
*aaS unreleased project in Elixir, Rust, Typescript, Kafka, and k8s

🏴‍☠️ skull-squadron

💭
*aaS unreleased project in Elixir, Rust, Typescript, Kafka, and k8s
  • (stealth)
  • ATX
  • 04:28 (UTC -06:00)
View GitHub Profile
@skull-squadron
skull-squadron / collide.rb
Created July 5, 2024 08:02
Find a TOTP collision
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'openssl'
class Base32
ALPHABET = (('A'..'Z').to_a + ('2'..'7').to_a).map(&:freeze).freeze
PADDING_CHAR = '='
BITS_PER_BYTE = 8
@skull-squadron
skull-squadron / README.md
Created May 31, 2024 05:52
How to un/install an RPM without running scriplets

dnf --setopt=tsflags=noscripts install ...

@skull-squadron
skull-squadron / reinstall.md
Created May 31, 2024 02:13
Reinstall all packages on Linuxes

How to reinstall packages

DNF-/RPM-based

rpm -qa --qf '%{NAME}\n' | xargs dnf reinstall -y

APT-/DEB-based

TBD

#[macro_export]
macro_rules! new_lazy_static {
($(#[$a:meta])* $v:vis fn $i:ident() -> &$t:ty $b:block $($rest:tt)*) => {
__new_lazy_static_inner!($(#[$a])*, $v, $i, Box<&$t>, $t, Box::new($b));
new_lazy_static!($($rest)*);
};
($(#[$a:meta])* $v:vis fn $i:ident() -> $t:ty $b:block $($rest:tt)*) => {
__new_lazy_static_inner!($(#[$a])*, $v, $i, $t, $t, $b);
new_lazy_static!($($rest)*);
};
@skull-squadron
skull-squadron / mass-rename
Created May 30, 2024 02:36
mass-rename files and change contents with sed
#!/usr/bin/env bash
[[ "${BASH_VERSINFO[0]}" -ge 4 ]] || {
echo >&2 'Requires bash >= 4'
exit 1
}
set -Eeuo pipefail
[ -z "${DEBUG-}" ] || set -x
if [ "$#" = 0 ]; then
cat >&2 << 'USAGE'
@skull-squadron
skull-squadron / README.md
Last active May 10, 2024 00:30
C portable C99 byte deser of sized integer types (instead of BSD socket network functions)

Portable network-order deser for C sized integral types

Features

  • Zero dependencies
  • Zero heap allocations
  • Unrolled and inlineable
  • Sensibly debuggable using line-oriented breakpoints
  • Buffer-oriented functions usable in embedded and kernel development
  • Optional 128-bit integer support where __int128 and unsigned __int128 are available
@skull-squadron
skull-squadron / force-replace-docker-binaries-with-unsupported-generic-ones
Created April 9, 2024 05:57
Oracle Linux and Fedora: Replace docker YUM/RPM binaries with generic ones from the interwebs without hash/sig checking or confirmation
#!/usr/bin/env bash
# Needed for btrfs support on RH/Fedora-derived platforms
set -Eeuo pipefail
files=(containerd containerd-shim-runc-v2 ctr docker dockerd docker-init docker-proxy runc)
url_prefix="https://download.docker.com/linux/static/stable/$(/bin/arch)/"
ua='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'
tarball=$(/bin/curl -fsSL -A "$ua" "$url_prefix" | /bin/grep -Eo 'docker-[0-9.]+tgz' | /bin/sort -Vur | /bin/head -1)
url="${url_prefix}${tarball}"
@skull-squadron
skull-squadron / Makefile
Last active April 9, 2024 04:57
Find a crc32 hash collision to embed in a file (requires zlib)
CFLAGS ?= -std=c99 -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wpedantic -Wformat=2 -flto -O3 -DNEBUG
build: find-crc32-worker
find-crc32-worker: find-crc32-worker.c Makefile
$(CC) $(CFLAGS) -lz $< -o $@
clean:
rm -f find-crc32-worker
@skull-squadron
skull-squadron / figsample
Last active April 9, 2024 05:14
Figlet sample viewer (require crc32 from Perl)
#!/usr/bin/env bash
#
#
# _______ _____ ______ _______ _______ _______ _____ _______
# |______ | | ____ |______ |_____| | | | |_____] | |______
# | __|__ |_____| ______| | | | | | | |_____ |______
#
#
# ___ ___ ___
#
@skull-squadron
skull-squadron / ssh-regen-moduli
Last active April 8, 2024 10:39
Regenerate /etc/ssh/moduli for modern openssh
#!/usr/bin/env bash
set -euo pipefail
# This script supports openssh 8.2+
(( ! UID )) || exec /usr/bin/sudo "$0" "$@"
var=${0//[^a-zA-Z0-9_]/_}
eval [ "\${$var-}" ] || exec /usr/bin/env ${var}=1 /usr/bin/flock -en "$0" "$0" "$@"
bits=${1:-4096}
min_bits=$((bits - 1))
moduli::generate() {