Skip to content

Instantly share code, notes, and snippets.

Avatar

Wladimir J. van der Laan laanwj

  • The Netherlands
View GitHub Profile
@laanwj
laanwj / stats_bitcoin.py
Last active Jul 17, 2020
Bitcoin network stats script
View stats_bitcoin.py
#!/usr/bin/env python3
import sys
sys.path.append('./bitcoin/test/functional')
from test_framework.authproxy import AuthServiceProxy, JSONRPCException
import time
import os
datadir = os.getenv("DATADIR", os.path.join(os.getenv('HOME'), '.bitcoin'))
with open(os.path.join(datadir,'.cookie'),'r') as f:
cookie = f.read()
View differences.diff
|| main
testnet=1 || test
testnet=0 || main
notestnet=1 || main
regtest=1 || regtest
regtest=0 || main
noregtest=1 || main
- testnet=0 testnet=1 || main
+ testnet=0 testnet=1 || test
- notestnet=1 testnet=1 || main
@laanwj
laanwj / test.c
Last active Nov 5, 2019
Test fixed-point number formatting
View test.c
#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;
View gist:dcc0f30d52fdeeed57689e1edf6cc7f5
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 / alphanumeric.md
Last active Jun 27, 2019
Alphanumeric instructions on RISC-V
View alphanumeric.md

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 Oct 3, 2018
Difference between Bitcoin Core 0.16 and 0.17.0 options
View options-including-debug.diff
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 Oct 9, 2019
udev rules example for lots of serial devices (put in /etc/udev/rules.d)
View 99-aithra-serial.rules
# 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 / gitian.md
Last active Sep 23, 2020
gitian buildling on debian 9.5
View gitian.md

Some changes are needed to build on debian because of the switch of the guest OS to bionic.

lxc that comes with debian is not high enough version to support bionic (the minimum is 2.1.1), so need to build from scratch.

debootstrap that comes with debian will give the following error:

    $ bin/make-base-vm --lxc --suite bionic --arch amd64                                                                                              
    E: No such script: /usr/share/debootstrap/scripts/bionic
@laanwj
laanwj / blocktoimg.py
Last active Aug 10, 2020
tools to write (block) data to png files and vice versa
View blocktoimg.py
#!/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):
You can’t perform that action at this time.