Skip to content

Instantly share code, notes, and snippets.

@ottosch
ottosch / seed_picker.sh
Last active December 24, 2023 01:59
Find all possibilities for the last seed word
#! /usr/bin/env bash
function run() {
read_wordlist
local input
printf "Enter seed words: "
read -r input
local seed_words=()
@ottosch
ottosch / mempool-stats.js
Last active December 17, 2023 15:40
Mempool BRC-20 status
#! /usr/bin/env node
// To run, start a project and install the dependency with:
// `npm init` and `npm i node-bitcoin-rpc`.
const rpc = require("node-bitcoin-rpc");
const fs = require("fs");
const opMap = new Map();
const tickMap = new Map();
@ottosch
ottosch / augustana-college.js
Created December 14, 2023 13:56
Extracts JPEG from transaction 033d185d1a04c4bd6de9bb23985f8c15aa46234206ad29101c31f4b33f1a0e49
#! /usr/bin/env node
const { Transaction } = require("bitcoinjs-lib");
const fs = require("fs");
const inputFile = "txhex";
const outputFile = "output.bin";
let hex = fs.readFileSync(inputFile, "utf8");
let tx = Transaction.fromHex(Buffer.from(hex, "hex"));
@ottosch
ottosch / apk-cert-fingerprint.sh
Last active November 18, 2023 19:41
Outputs apk's signing certificate hash
unzip -o <apk_file> -d /tmp/ && keytool -printcert -file /tmp/META-INF/CERTIFIC.RSA 2>/dev/null | grep SHA256 | cut -f2- -d':' | tr -cd '[[:xdigit:]]'; echo
@ottosch
ottosch / lookup-btc.sh
Last active October 1, 2023 16:44
DNS lookup of Bitcoin peers
#! /bin/bash
hosts="bitcoin.jonasschnelli.ch \
seed.btc.petertodd.org \
bluematt.me \
bitcoin.schildbach.de"
if [[ "$1" == "testnet" ]]; then
hosts="testnet-seed.bitcoin.jonasschnelli.ch \
seed.tbtc.petertodd.org \
@ottosch
ottosch / sats-token.js
Created September 2, 2023 20:50
Identify BRC-20 sats in mempool
#! /usr/bin/env node
const rpc = require("node-bitcoin-rpc");
const fs = require("fs");
const inscriptionMark = Buffer.from("0063036f7264", "hex");
const keywords = ["brc-20", "op", "mint", "tick", "\"sats\"", "amt"];
const op_endif = 0x68;
async function run() {
@ottosch
ottosch / set-static-ip.sh
Last active May 26, 2023 02:17
Shell script to set a static ip address in the systemd network unit. Needs sudo to write the file
#! /usr/bin/env bash
if [ "$#" -eq "0" ]; then
echo "Usage: $0 <desired-ip-address>"
curr_ip="$(ip route get 1.1.1.1 | awk '{print$7}')"
echo "FYI your current IP address is: $curr_ip"
exit 1
fi
# TODO: check if input looks like an ip
@ottosch
ottosch / find_block.py
Last active May 8, 2023 16:02
Finds which .dat file contains the block
#! /usr/bin/env python
# Finds which .dat file contains the block.
# Warning: this will most likely corrupt the block index. You are strongly advised to copy the index (around 100MB) to a different location and
# run the script in that location (change path below).
#
# Path to index: $datadir/blocks/index
import sys
import plyvel
@ottosch
ottosch / otto-parser.py
Last active February 4, 2023 19:30
Simple Ordinals Inscriptions Parser (for context: ordinals.com)
#! /usr/bin/env python
import sys, os, base64, argparse
def get_cli_args():
ap = argparse.ArgumentParser(description="Parse and output the ordinal inscription inside transaction")
if sys.stdin.isatty():
ap.add_argument("tx_file", help="input raw transaction file")
ap.add_argument("-du", "--data-uri", action="store_true", help="print inscription as data-uri instead of writing to a file")
@ottosch
ottosch / dbeaver-pass.py
Created January 24, 2023 14:57
Decrypts a DBeaver pass
#! /usr/bin/env python
import base64, binascii, sys
key = bytearray("sdf@!#$verf^wv%6Fwe%$$#FFGwfsdefwfe135s$^H)dg", "utf8")
def main():
if len(sys.argv) < 2:
print(f"usage: {sys.argv[0]} <password>", file = sys.stderr)
sys.exit(1)