Skip to content

Instantly share code, notes, and snippets.

View whitequark's full-sized avatar
🐈‍⬛

Catherine whitequark

🐈‍⬛
View GitHub Profile
@whitequark
whitequark / nixos-bite.sh
Last active October 7, 2025 04:06
aiming at its succulent neck, NixOS sinks teeth into a pale and weak Debian 13 server, sucking out all the remaining life force out of it.
#!/bin/sh
# see https://codeberg.org/whitequark/nixos-bite
curl https://codeberg.org/whitequark/nixos-bite/raw/branch/main/nixos-bite.sh | bash -s "$@"
@whitequark
whitequark / amaranth_cobs.py
Last active May 25, 2025 15:25
Amaranth COBS encoder/decoder
from amaranth import *
from amaranth.lib import data, wiring, memory, stream
from amaranth.lib.stream import In, Out
__all__ = ["Encoder", "Decoder"]
class Encoder(wiring.Component):
"""`Consistent Overhead Byte Stuffing <cobs>`_ encoder combined with a FIFO.
# /// script
# requires-python = "~=3.11"
# dependencies = [
# "colored==2.3.0",
# "z3-solver==4.14.1.0"
# ]
# ///
import os
import sys
@whitequark
whitequark / log_func_rename.py
Last active October 4, 2025 22:51
Binary Ninja snippets
#Extract function name from log calls
#
logger = "LogFuncRename"
def log_func_rename(log_function, name_index):
func_votes = defaultdict(lambda: defaultdict(lambda: 0))
for call_site in log_function.caller_sites:
if not isinstance(call_site.hlil.operands[0], HighLevelILConstPtr):
continue
if call_site.hlil.operands[0].constant != log_function.start:
@whitequark
whitequark / meow.md
Last active October 10, 2025 19:11
reverse engineering tools

"%" means not tested by me personally.

Reference material

Disassemblers and decompilers

  • Binary Ninja: interactive native code disassembler, decompiler, and debugger
  • when building, replace the BN SDK it downloads with a path to BN API library
@whitequark
whitequark / x64_arm64_sysmain.sdb.xml.diff
Created July 26, 2024 05:05
Difference between (two random revisions of) c:\windows\appcompat\sysmain.sdb between x64 and arm64 platforms
This file has been truncated, but you can view the full file.
diff --git a/x64_sysmain.sdb.xml b/arm64_sysmain.sdb.xml
index 3fbe1b5..b978574 100644
--- a/x64_sysmain.sdb.xml
+++ b/arm64_sysmain.sdb.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<SDB xmlns:xs="http://www.w3.org/2001/XMLSchema" path=".\data\sysmain.sdb">
+<SDB xmlns:xs="http://www.w3.org/2001/XMLSchema" path=".\data_arm64\sysmain.sdb">
<INDEXES>
<INDEX>
@whitequark
whitequark / sysmain.sdb.xml.part
Created July 26, 2024 03:59
Every `GenericInstaller` in the Windows apppatch database (if your binary matches any of these you'll get an UAC prompt)
<EXE>
<NAME type="xs:string">*</NAME>
<WILDCARD_NAME type="xs:string">*</WILDCARD_NAME>
<APP_NAME type="xs:string">Tarma Installer</APP_NAME>
<VENDOR type="xs:string">Tarma</VENDOR>
<EXE_ID type="xs:string" baseType="xs:base64Binary">{22187a8c-2c98-41f6-8ed6-6f653fe134c7}</EXE_ID>
<APP_ID type="xs:base64Binary" />
<RUNTIME_PLATFORM type="xs:int">37</RUNTIME_PLATFORM>
<MATCHING_FILE>
<NAME type="xs:string">*</NAME>
@whitequark
whitequark / qspi_iostream.py
Last active May 14, 2025 18:48
Amaranth 0.5 demo with a pipelined QSPI core impemented using streams
from amaranth import *
from amaranth.lib import enum, data, wiring, stream, io
from amaranth.lib.wiring import In, Out, connect, flipped
from amaranth.sim import Simulator
class IOStream(wiring.Component):
def __init__(self, width, *, meta_layout=0, latency=0):
self._latency = latency
@whitequark
whitequark / spi_serdes.py
Created June 18, 2024 02:49
Amaranth 0.5 demo with a pipelined SPI core (easily extendable to QSPI) impemented using streams
from amaranth import *
from amaranth.lib import data, wiring, stream, io
from amaranth.lib.wiring import In, Out
from amaranth.sim import Simulator
class BitSerializer(wiring.Component):
def __init__(self, *, width, length):
self._length = length
@whitequark
whitequark / cxxrtl_debug_server_spec.md
Last active September 25, 2024 12:51
CXXRTL debug server protocol