Skip to content

Instantly share code, notes, and snippets.

View nlitsme's full-sized avatar

willem nlitsme

View GitHub Profile
@nlitsme
nlitsme / spellmaster.py
Last active July 29, 2022 17:22
spellmaster decryptor
"""
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 July 25, 2022 12:07
python script which I used to generate my mch2022 program overview
"""
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 / pyz3.py
Created October 14, 2020 13:27
example sudoku solver
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 / EdDSA vs secp256k1.md
Last active March 25, 2022 17:17
comparing EdDSA with Secp256k1 sigining
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 / 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 <itsme@xs4all.nl>
# 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 / README.md
Last active February 5, 2022 18:48
mpmp8 stackfolding

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 / mpmp12.md
Last active August 14, 2020 20:29
mpmp12 Marchingband solution

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 July 29, 2020 11:30
python scripts to show corona statistics
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 / kallsyms.py
Created June 6, 2017 18:43
idapython script decoding the linux kernel symbol table
# Linux kernel kallsyms unpacker
# Version 0.2
# Copyright (c) 2010-2013 Igor Skochinsky
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
@nlitsme
nlitsme / lbk
Created November 14, 2019 08:46
Search timemachine backups and apfs snapshots for a specific file
#!/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 $?