Skip to content

Instantly share code, notes, and snippets.

Avatar

willem nlitsme

View GitHub Profile
@nlitsme
nlitsme / spellmaster.py
Last active Jul 29, 2022
spellmaster decryptor
View spellmaster.py
"""
PT/CT pairs
Key expanded Plaintext Ciphertext
AAAAAAAA AAAAAAAA AAAAAAAAAA VTPL?DL?HV
AAAAAAAA AAAAAAAA ABCDEFGHIJKLMNOPQRSTUVWXY VMHTL?QFPCBKSZCJGRZM-EEEZ
AAAA AAAAAAAA BBBB OTBZ
AAAAAAAA AAAAAAAA BBBBBBBBBB OTBZNRZNVA
AAAAAAAA AAAAAAAA BBBBBBBBBBBBBBBB OTBZNRZNVAJRJFVR
AAA AAAAAAAA BBBBBBBBBBBBBBBBBBBBBBBBB OTBZNRZNVAJRJFVRVVOTVBBJB
@nlitsme
nlitsme / genmchpgm.py
Last active Jul 25, 2022
python script which I used to generate my mch2022 program overview
View genmchpgm.py
"""
Author: itsme@xs4all.nl
"""
import html.parser
import html
import urllib.request
import json
from datetime import datetime, timedelta
import re
import os
@nlitsme
nlitsme / EdDSA vs secp256k1.md
Last active Mar 25, 2022
comparing EdDSA with Secp256k1 sigining
View EdDSA vs secp256k1.md
Secp256k1 EdDSA
message m = hash(M) M, given
privkey . given
private-key x, given x = low32(sha512(privkey))
signing-secret k, given k = sha512(high32(sha512(privkey)) // M)
privkey-to-pubkey Y = G * x Y = G * x
calc-R R = G * k R = G * k
r-value r = R.x r = SHA512(R // Y // M)
s-value s = (m + x * r) / k s = k + x * r
@nlitsme
nlitsme / messagehash.md
Last active Mar 6, 2022
How to calculate the bitcoin messagehash
View messagehash.md

Demonstrate how to calculate the messagehash for the two signatures in this transaction

See ecdsa_demo.py for code showing how to use this to crack the bitcoin secret key.

These are the values extracted from the example transaction below:

pk="04 db d0 c6 15 32 27 9c f7 29 81 c3 58 4f c3 22 16 e0 12 76 99 63 5c 27 89 f5 49 e0 73 0c 05 9b 81 ae 13 30 16 a6 9c 21 e2 3f 18 59 a9 5f 06 d5 2b 7b f1 49 a8 f2 fe 4e 85 35 c8 a8 29 b4 49 c5 ff"
r="d4 7c e4 c0 25 c3 5e c4 40 bc 81 d9 98 34 a6 24 87 51 61 a2 6b f5 6e f7 fd c0 f5 d5 2f 84 3a d1"
s1="44 e1 ff 2d fd 81 02 cf 7a 47 c2 1d 5c 9f d5 70 16 10 d0 49 53 c6 83 65 96 b4 fe 9d d2 f5 3e 3e"
@nlitsme
nlitsme / pyz3.py
Created Oct 14, 2020
example sudoku solver
View pyz3.py
from z3 import *
# https://www.youtube.com/watch?v=9ATC_uBF8ow
# Normal sudoku rules apply.
# - ALL horizontally and vertically neighbouring digits with the sum 10 are marked with X;
# - ALL horizontally and vertically neighbouring digits with the sum 5 are marked with V.
# these pairs sum to 10:
# (0,2) + (1,2), (0,4) + (1,4), (0,6) + (1,6)
# (1,1) + (2,1), (1,3) + (2,3), (1,5) + (2,5), (1,7) + (2,7)
# (2,2) + (3,2), (2,4) + (3,4), (2,6) + (3,6)
@nlitsme
nlitsme / mpmp12.md
Last active Aug 14, 2020
mpmp12 Marchingband solution
View mpmp12.md

Marching Band problem

In this document I describe a solution to the 'marchingband' problem as stated on think-maths:

What is the fewest number of performers you require for your marching band to
have 64 marching options? (Only whole positive numbers will be accepted)

Where a 'marchingband' can march only in a rectangular shape.

@nlitsme
nlitsme / countries.txt
Created Jul 29, 2020
python scripts to show corona statistics
View countries.txt
EMRO AF Afghanistan 647500 37171921 World;Asia;NonCKIR
EURO AL Albania 28748 2876591 World;Europe;NonEU
AFRO DZ Algeria 2381740 34178188 World;Africa;North Africa
WPRO AS American Samoa (United States) 199 55465 World;Oceania;Polynesia
EURO AD Andorra 468 77281 World;Europe;NonEU
AFRO AO Angola 1246700 12799293 World;Africa;Central Africa
AMRO AI Anguilla (United Kingdom) 91 14731 World;North America
AMRO AG Antigua and Barbuda 442 96286 World;North America
AMRO AR Argentina 2766890 44361150 World;South America
EURO AM Armenia 29743 2951745 World;Europe;NonEU
@nlitsme
nlitsme / README.md
Last active Feb 5, 2022
mpmp8 stackfolding
View README.md

This gist describes my solution to Matt Parker's puzzle #8:

My solution involves looking at the pattern of folds when viewing the folded stack from the sides. And then using some python code to generate all possible ways the folds can match up in a way that you will still end up with two rows of 4 sheets.

The list below shows all ways to fold a piece of paper, including ways where the top-left ends up on the inside of the folded stack.

@nlitsme
nlitsme / lbk
Created Nov 14, 2019
Search timemachine backups and apfs snapshots for a specific file
View lbk
#!/bin/bash
#
# Script which scans all your mounted timemachine volumes, and apfs snapshots for a specific file.
#
# Willem Hengeveld <itsme@xs4all.nl>
#
if [[ $(id -u) -ne 0 ]]; then
sudo $0 "$@"
exit $?
@nlitsme
nlitsme / breachquery.sh
Created Dec 14, 2017
query.sh for older bash versions - from magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
View breachquery.sh
#!/bin/bash
# query.sh from BreachCompilation - magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
# works with older bash versions.
# patch by Willem <itsme@xs4all.nl>
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "$1" != "" ]; then
word1=$(echo $1 | tr A-Z a-z)
letter1=$(echo $word1|cut -b1)
if [[ $letter1 == [a-zA-Z0-9] ]]; then