Skip to content

Instantly share code, notes, and snippets.

@laanwj
laanwj / easyrpc.py
Last active April 5, 2024 12:53
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 / $v3_onions.py
Last active March 10, 2023 07:34
Get TorV3 addresses from a node and check if they are connectable
#!/usr/bin/env python3
import easyrpc
import socks
import sys
out = sys.stdout
log = sys.stderr
log.write(f"Getting addresses from local node…\n")
p = easyrpc.get_rpc_proxy(network='main')
@laanwj
laanwj / keys.txt
Last active January 5, 2024 18:52
keys.txt from Bitcoin Core, updated for gitian-verify.py
9D3CC86A72F8494342EA5FD10A41BDC3F4FAFF1C Aaron Clauson (sipsorcery)
617C90010B3BD370B0AC7D424BB42E31C79111B8 Akira Takizawa
E944AE667CF960B1004BC32FCA662BE18B877A60 Andreas Schildbach
152812300785C96444D3334D17565732E08E5E41 Andrew Chow (achow101)
590B7292695AFFA5B672CBB2E13FC145CD3F4304 Antoine Poinsot (darosior)
0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 Ben Carman (benthecarman)
912FD3228387123DC97E0E57D5566241A0295FA9 BtcDrak
C519EBCF3B926298946783EFF6430754120EC2F4 Christian Decker (cdecker)
18AE2F798E0D239755DA4FD24B79F986CBDF8736 Chun Kuan Le (ken2812221)
F20F56EF6A067F70E8A5C99FFF95FAA971697405 centaur
@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 / test.c
Last active November 5, 2019 15:23
Test fixed-point number formatting
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
void print_number_f(double x) {
double y = x;
int c = 0;
if (y < 0.0) {
y = -y;
udp://tracker.openbittorrent.com:80
udp://tracker.opentrackr.org:1337
udp://tracker.coppersurfer.tk:6969
udp://tracker.leechers-paradise.org:6969
udp://zer0day.ch:1337
udp://explodie.org:6969
@laanwj
laanwj / k210_memory_map.md
Last active May 4, 2019 09:23
Kendryte K210 / Maix Go memory map
@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 / options-including-debug.diff
Last active October 3, 2018 12:51
Difference between Bitcoin Core 0.16 and 0.17.0 options
aurora:~/projects/bitcoin$ bitcoin-0.16/build/src/bitcoind --help --help-debug|grep "^ -" | sort > /tmp/options-0.16.txt
aurora:~/projects/bitcoin$ bitcoin-0.17/build/src/bitcoind --help --help-debug|grep "^ -" | sort > /tmp/options-0.17.txt
aurora:~/projects/bitcoin$ diff -du /tmp/options-0.16.txt /tmp/options-0.17.txt
--- /tmp/options-0.16.txt 2018-10-03 14:35:57.661688575 +0200
+++ /tmp/options-0.17.txt 2018-10-03 14:36:03.789664725 +0200
@@ -2,8 +2,10 @@
-acceptnonstdtxn
-addnode=<ip>
-addresstype
+ -addrmantest
@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