Skip to content

Instantly share code, notes, and snippets.

View laanwj's full-sized avatar

Mara van der Laan laanwj

View GitHub Profile
@laanwj
laanwj / check-joinmarket-dirnodes.py
Created April 22, 2025 01:19
Check and report status of joinmarket directory nodes.
#!/usr/bin/python3
# Check and report status of joinmarket directory nodes.
# SPDX-License-Identifier: MIT
import socket
import subprocess
PROXY = ('127.0.0.1', 9050)
GLYPH = ['❌', '🆗']
# Nodes to check
@laanwj
laanwj / guix.md
Last active October 4, 2024 06:17
Getting guix to work with apparmor on Ubuntu 24.04

The standard assumption up to now has been that applications that don't have a specific apparmor profile run in the "unconfined" profile, which essentially doesn't forbid anything. However, in 24.04, everything using unprivileged namespaces automatically ends up in the "unprivileged_userns" profile, which does add rules. Disabling this profile doesn't work, because that seems to block use of unprivileged namespaces completely.

What does work is to create a specifc apparmor profile for guix, that is really unconfined and allows user namespaces:

Create a file /etc/apparmor.d/guix:

abi <abi/4.0>,
include <tunables/global>

profile guix /usr/bin/guix flags=(unconfined) {
@laanwj
laanwj / easyrpc.py
Last active August 18, 2024 09:21
Bitcoind RPC example from Python
'''
Convenience utility for connecting to a bitcoind instance through RPC.
'''
# W.J. van der Laan 2021 :: SPDX-License-Identifier: MIT
import base64
import decimal
from http import HTTPStatus
import http.client
import json
import logging
@laanwj
laanwj / validate_macho_sig.py
Last active January 10, 2023 17:44
Validate cryptographic signature on macos macho binary
#!/usr/bin/env python3
import io
import struct
import sys
import pprint
import macholib.MachO
from macholib.mach_o import LC_CODE_SIGNATURE
import asn1crypto.x509
from asn1crypto.cms import ContentInfo, SignedData, CMSAttributes
@laanwj
laanwj / alphanumeric.md
Last active February 4, 2021 09:37
Alphanumeric instructions on RISC-V

Alphanumeric shellcode on RISC-V

Although common on x86, it was initially believed that it was not possible to make alphanumeric shellcode for ARM. Later it turned out it was.

Similar to that, I wondered if it was possible to make alphanumeric shell-code for RISC-V.

(Basic shellcode in RISC-V Linux provides a good introduction to shellcode for RISC-V, including how to avoid NUL bytes.)

First, I enumerated all the possible instructions that could be formed from these characters with a little Rust program and generated some statistics.

@laanwj
laanwj / 99-aithra-serial.rules
Last active January 11, 2021 16:54
udev rules example for lots of serial devices (put in /etc/udev/rules.d)
# serial devices
# get attributes using: udevadm info -a -n /dev/ttyUSBn
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{product}=="Flyswatter2", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="serial/flyswatter-jtag"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{product}=="Flyswatter2", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="serial/flyswatter-tty"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{product}=="Dual RS232-HS", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="serial/unleashed-jtag"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{product}=="Dual RS232-HS", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="serial/unleashed-tty"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ATTRS{product}=="Quad RS232-HS", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="serial/zodiac-jtag0"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ATTRS{product}=="Quad RS232-HS", ENV{ID_USB_IN
@laanwj
laanwj / blocktoimg.py
Last active January 31, 2024 11:06
tools to write (block) data to png files and vice versa
#!/usr/bin/env python3
# Distributed under the MIT software license
import binascii, struct, sys, io, argparse
from PIL import Image
IMG_WIDTH = 512 # could be made adaptive...
MIN_HEIGHT = 4 # minimum height of image; twitter won't let us upload anything smaller
BYTES_PER_PIXEL = 4 # RGBA, 8 bit
def div_roundup(x,y):
@laanwj
laanwj / c++14.patch
Created May 31, 2018 07:50
Patch for buiding Bitcoin Core with C++14
diff --git a/configure.ac b/configure.ac
index 1ffef1527bdb556dff79338f4052d1b49ae6bc42..5f324894bd861fe92ec7fad24b6687876b0e1919 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,8 +60,8 @@ case $host in
lt_cv_deplibs_check_method="pass_all"
;;
esac
-dnl Require C++11 compiler (no GNU extensions)
-AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault])