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 / 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 / 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 / urbit_sniffer.py
Created November 30, 2014 08:57
Urbit UDP sniffer
#!/usr/bin/python3
# Copyright (c) 2014 Wladimir J. van der Laan, Visucore
# Distributed under the MIT software license, see
# http://www.opensource.org/licenses/mit-license.php.
'''
urbit UDP sniffer
Usage: urbit_sniffer.py [-p <port1>-<port2>,<port3>,...] [-i <interface>]
'''
import socket, struct, sys, io, argparse
@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 / 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 / moonphase.py
Last active September 15, 2022 14:46
#!/usr/bin/python3
import datetime
import bisect
import ephem
DAY = 1.0/29.33
MOONPHASE = [
(0.0/4.0 + DAY, '🌑', 'New moon'),
(1.0/4.0 - DAY, '🌒', 'Waxing crescent moon'),
(1.0/4.0 + DAY, '🌓', 'First quarter moon'),
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 / run.gdbscript
Last active March 24, 2022 14:39
Start bitcoind in a screen in a debugger
set disable-randomization off
set $_exitcode = -999
set height 0
handle SIGTERM nostop print pass
handle SIGPIPE nostop
define hook-stop
if $_exitcode != -999
quit
else
shell echo | mail -s "NOTICE: app has stopped on unhandled signal" root