Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nlitsme's full-sized avatar

willem nlitsme

View GitHub Profile
@nlitsme
nlitsme / symexpr.py
Created February 13, 2024 22:57
symbolic solver
#!/usr/bin/python3
import sympy
import re
import keyword
"""
symbolic expression tool
- expression with '==' -> solves for all free variables, or for the var specified with '-x'
- expr without '==' -> simplify
- assignment: store resulting expr in var
@nlitsme
nlitsme / projectoranim.py
Created August 2, 2023 17:24
laserprojector animation
import math
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as a3
from matplotlib.animation import FuncAnimation
from dataclasses import dataclass
from collections import defaultdict
import numpy
"""
Author: Willem Hengeveld <itsme@xs4all.nl>
@nlitsme
nlitsme / idaallcpu.sh
Created March 13, 2023 12:14
scripts for doing bulk disasm / decompile in IDA
#!/bin/bash
# This script is useful when you are not sure about which processor your binary is.
# the script makes sure there are not more than 8 simultaneous ida processes active.
for cpu in ARMB ARM alphab alphal ad218x kr1878 arcmpct arc arcv2 AVR oakdsp PDP11 dalvik ebc F2MC16L F2MC16LX fr h8300a h8300 h8s300a h8s300 h8sxa h8sx h8sxm h8sxn h8368 h8500 s390 s390x 80196 80196NP 80251b 80251s 8051 8051mx 80930b 80930s athlon k62 80286p 80286r 80386p 80386r 80486p 80486r 8086 p4 p2 p3 80686p 80586p 80586r metapc 860xp 860xr i960b i960l i960 java octeonb octeonl mipsr mipsrl r5900b r5900l mipsb mipsl psp tx19ab tx19al m65816 m65c816 M6502 M65C02 PIC12Cxx PIC16Cxx PIC18Cxx PIC24 PIC30 PIC33 cli net m7700 m7750 m32r m32rx m740 m7900 dsp56k dsp561xx dsp563xx dsp566xx hcs08 6301 6303 68330 ColdFire HCS12 HCS12X 6800 68000 6801 68010 68020 68851 68882 68020EX 6803 68030 68040 6805 6808 6809 6811 6812 6816 68K 78k0s 78k0 V850 V850E V850E1 V850E2M RH850 hppa 51XA-G3 PPC PPCL QDSP6 SH2A SH3B SH3 SH4B SH4 RL78 m16c20 m

Volume I: RISC-V Unprivileged ISA V20191214-draft

Preface

This document describes the RISC-V unprivileged architecture.

The ISA modules marked Ratified have been ratified at this time. The modules marked Frozen are not expected to change significantly before being put up for ratification. The modules marked Draft are expected to change before ratification.

@nlitsme
nlitsme / r32.md
Last active January 11, 2023 22:38
riscv instruction tables in markdown ( converted using pandoc )

RV32I Base Integer Instruction Set, Version 2.1

This chapter describes the RV32I base integer instruction set.

RV32I was designed to be sufficient to form a compiler target and to support modern operating system environments. The ISA was also designed to reduce the hardware required in a minimal implementation. RV32I contains 40 unique instructions, though a simple implementation might

@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 / 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 / messagehash.md
Last active March 10, 2024 19:41
How to calculate the bitcoin messagehash

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 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)