Skip to content

Instantly share code, notes, and snippets.

@nilswiersma
nilswiersma / logtest.py
Created February 7, 2026 09:49
Rich logging and progress bars simple
import logging
import argparse
import time
import functools
import sys
from logging.handlers import RotatingFileHandler
from rich.console import Console
from rich.logging import RichHandler
from rich.progress import Progress
from rich import reconfigure
@nilswiersma
nilswiersma / deb..md
Created August 6, 2025 21:10
Unpack repack a deb

https://serverfault.com/a/383958

You can change the dependencies of a deb package like this:

  1. Unpack deb: ar x golden-linux.deb (will create i.e. three files: debian-binary control.tar.gz data.tar.gz, note that they can also use the newer xz compression)
  2. Unpack control archive: tar xf control.tar.gz (will create: postinst postrm preinst prerm md5sums control)
  3. Fix dependencies in control (use a text editor)
  4. Repack control.tar.gz: tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control
  5. Repack deb: ar rcs newpackage.deb debian-binary control.tar.gz data.tar.gz (order important! See [Note] )
@nilswiersma
nilswiersma / asn1.hexpat
Last active March 12, 2025 13:26
imhex hexpat for parsing ans1 files like a der encoded private key
import std.io;
import std.mem;
enum TagTypeEnum: u8 {
BER_RESERVED = 0,
BOOLEAN,
OCTET,
STRING,
NULL,
OBJECT,
@nilswiersma
nilswiersma / ghidracontrol.md
Last active July 17, 2024 16:33
Control Ghidra GUI externally with pyhidra and DeferredPyhidraLauncher
  • Install pyhidra
  • Use the deferred launcher to launch non-headless, and then interact with that instance
  • Obtain reference to currentProgram via the Code Browser window
  • TODO Cannot launch the Code Browser from this interface?
import pyhidra

launcher = pyhidra.DeferredPyhidraLauncher(verbose=True)
launcher.start()
@nilswiersma
nilswiersma / rsa_test.py
Last active December 1, 2023 20:21
RSA
# git clone https://github.com/sybrenstuvel/python-rsa/
# 0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff003031300d0609608648016503040201050004205ef9cae31784c7c67fdaa39e3cc6eec2b7fa2da751c13fd7fa4c305cf56eb1f7
# 5ef9cae31784c7c67fdaa39e3cc6eec2b7fa2da751c13fd7fa4c305cf56eb1f7
# 5ef9cae31784c7c67fdaa39e3cc6eec2b7fa2da751c13fd7fa4c305cf56eb1f7
import sys
sys.path.append('python-rsa')
from rsa import pkc
@nilswiersma
nilswiersma / FISIM.md
Last active September 21, 2023 17:41
Ghidra FISIM

Python script to perform instruction skipping on a binary.

fisim

Define START, NORMAL (for normal end) and FAULT (for fault success end) bookmarks, and run script!

image

Fault locations are added to bookmarks, make sure you enable the FI type to see them.

New version

Single script, output is csv values.

  1. Go to the fantasy overview page, for example https://www.hltv.org/fantasy/355/overview.

  2. Run the following:

    var e=document.querySelector(".textBox").querySelector("a").href;console.log(e);var t=document.querySelectorAll(".money-league")[1];"HLTV x Roobet league"!=t.innerText&&console.warn("Expected HLTV x Roobet league, found <"+t.innerText+">");var r=t.querySelector("a").href.replace("league","leagues")+"/join/json";console.log(r);var a=[];await fetch(e).then((function(e){return e.text()})).then((function(e){var t=(new DOMParser).parseFromString(e,"text/html");Array.from(t.querySelector(".teams-attending").children).forEach((function(e,t){var r=e.querySelector(".team-name").querySelector(".text").innerHTML,o=e.querySelector(".team-name").querySelector("a").href.replace("team/","stats/teams/players/");console.log(r+": "+o),a.push({team_name:r,team_link_stats:o})}))})),sessionStorage.setItem("team_links",JSON.stringify(a));va
// Single file sha256
// https://github.com/LekKit/sha256
#include <stdio.h>
#include <string.h>
struct sha256_buff {
unsigned long data_size;
unsigned int h[8];
unsigned char last_chunk[64];
@nilswiersma
nilswiersma / log_argparse_skeleton.py
Last active January 13, 2025 10:16
argparse and (color)log
import logging, argparse
class CustomFormatter(logging.Formatter):
grey = "\x1b[38;20m"
y = "\x1b[33;20m"
b = "\x1b[36;20m"
g = "\x1b[32;20m"
r = "\x1b[31;20m"
br = "\x1b[97;1m"
reset = "\x1b[0m"
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
sample_size = int(1e2)
data = {
'x': np.random.randint(0, 100, sample_size),
'y': np.random.randint(0, 100, sample_size),