Skip to content

Instantly share code, notes, and snippets.

View nlitsme's full-sized avatar

willem nlitsme

View GitHub Profile
@nlitsme
nlitsme / curve_example.py
Last active October 22, 2024 05:06
example of bitcoin curve calculations in python
from __future__ import print_function, division
"""
Example of how calculations on the secp256k1 curve work.
secp256k1 is the name of the elliptic curve used by bitcoin
see http://bitcoin.stackexchange.com/questions/25382
"""
## the prime modules used in the elliptic curve coordinate calculations
p = 2**256 - 2**32 - 977
@nlitsme
nlitsme / ecdsa_demo.py
Last active September 20, 2024 14:33
python implementation of ecdsa calculations, demonstrating how to recover a private key from two signatures with identical 'r', and demonstrating how to find the public key from a signature and message, or from two signatures.
from __future__ import print_function, division
"""
By Willem Hengeveld <[email protected]>
ecdsa implementation in python
demonstrating several 'unconventional' calculations,
like finding a public key from a signature,
and finding a private key from 2 signatures with identical 'r'
"""
@nlitsme
nlitsme / dumpwallet.py
Last active February 22, 2022 13:28
create readable hex dump of a bitcoin, litecoin, etc wallet.dat
from bsddb.db import *
import sys
import struct
# by Willem Hengeveld <[email protected]>
# usage: python dumpwallet path_to_your/wallet.dat
# note: you need to have the bsddb package installed
def getcompact(k, i):
b= ord(k[i]) ; i+=1
@nlitsme
nlitsme / decodesms.pl
Last active December 20, 2022 23:16
perl script for decoding raw hex sms PDU data
#!perl -w
# by Willem Hengeveld <[email protected]>
# license: http://en.wikipedia.org/wiki/Beerware
use strict;
$|=1;
# this script decodes raw smsses, as used with the
# AT+CMT, or AT+CMGR, or AT+CMGS commands
# either parses hex strings on the commandline, or from stdin.
@nlitsme
nlitsme / sendpgp.py
Last active August 29, 2015 14:08
send pgp mail from vim
#!/usr/local/bin/python
"""
Reads message from stdin, pgp encrypts, launch mailto: url to send with mail app.
I use this to send pgp messages from within vim.
First i type a message like this:
----
Subject: test
To: [email protected]
@nlitsme
nlitsme / lbk.sh
Last active August 29, 2015 14:08
list timemachine copies of a file
#!/bin/bash
bkdir=
while [[ -n "$1" ]]; do
cd $(dirname "$1")
realpath=$(pwd -P)
case "$realpath" in
/Volumes/*)
realpath=${realpath:9}
;;
@nlitsme
nlitsme / lsofdiff.sh
Last active August 29, 2015 14:08
view recent filesystem activity using lsof
#!/bin/bash
if [[ $(id -u) -ne 0 ]]; then
sudo $0 "$@"
exit $?
fi
diff <(sleep 1 ; lsof -n -P| grep -v "^\(sleep\|lsof\|grep\|diff\|bash\)" ) <(lsof -n -P| grep -v "^\(sleep\|lsof\|grep\|diff\|bash\)" )
@nlitsme
nlitsme / x0.sh
Last active August 29, 2015 14:08
simplify xargs -0
#!/bin/sh
tr -d "\r" | tr "\n\\" "\0/" | xargs -0 "$@"
@nlitsme
nlitsme / filetrace.d
Last active August 29, 2015 14:08
trace opened files for all processes in osx
#!/usr/sbin/dtrace -s
syscall::open*:entry {
this->exe= execname;
this->file= copyinstr(arg0);
this->mode= arg1;
}
syscall::open*:return {
printf("%4d (%4d) %-20s\tM%07o %s",arg0, errno, this->exe, this->mode, this->file);
}
@nlitsme
nlitsme / exectrace.d
Last active August 29, 2015 14:08
trace executed processes in osx
#!/usr/sbin/dtrace -s
#pragma D option quiet
syscall::exec*:entry
{
printf("exec %s -> %s\n", execname, copyinstr(arg0));
}
proc:::exec-failure