Skip to content

Instantly share code, notes, and snippets.

View JonathonReinhart's full-sized avatar

Jonathon Reinhart JonathonReinhart

View GitHub Profile
@JonathonReinhart
JonathonReinhart / fetch_merge.py
Created May 4, 2026 06:15
This script fetches UEFI guids.csv files from multiple sources, then compares and merges them.
#!/usr/bin/env python3
"""
This script fetches UEFI guids.csv files from multiple sources, then compares and merges them.
"""
import csv
import io
import logging
import urllib.request
from typing import NewType, TypeAlias
@JonathonReinhart
JonathonReinhart / Breakpoints.c
Created January 12, 2025 20:33
Self-debugging on windows
// SPDX-FileCopyrightText: © 2012 Jonathon Reinhart <jonathon.reinhart@gmail.com>
// SPDX-License-Identifier: MIT
#include "Breakpoints.h"
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
// This causes UD2 opcodes to be used instead of INT3.
#define USE_UD2_BREAKPOINT 1
@JonathonReinhart
JonathonReinhart / nbdinfo.py
Last active August 23, 2022 06:54
Linux NBD (Network Block Device) info
#!/usr/bin/env python3
# Show Linux NBD (Network Block Device) info
# Requires Python 3.7+
# Author: Jonathon Reinhart
# License: MIT
from dataclasses import dataclass
from pathlib import Path
class NotConnected(Exception):
pass
@JonathonReinhart
JonathonReinhart / kvm_emulate.md
Created July 27, 2022 04:14
KVM Emulate Flowchart

When does Linux KVM emulate instructions?

Flow Chart

graph LR

x86_emulate_instruction --> x86_emulate_insn
emulate_instruction --> x86_emulate_instruction
@JonathonReinhart
JonathonReinhart / partclone
Created July 19, 2022 18:04
Magic file for partclone image format
# This is a magic(5) description for partclone(8) output files.
# References:
# https://github.com/Thomas-Tsai/partclone/blob/master/src/partclone.h
# Structure: `image_head_v2`
# magic (16)
0 string partclone-image Partclone image
################################################################################
# Version 1
@JonathonReinhart
JonathonReinhart / mouselog.html
Created July 19, 2022 13:39
Mouse click log
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>mousedown demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="trigger" style="border-style: solid">Click here to log.</div>
@JonathonReinhart
JonathonReinhart / gen-selfsign-cert.sh
Created July 11, 2022 06:39
Simply generate a self-signed certificate for a DNS name
#!/bin/bash
# Simply generate a self-signed certificate for a DNS name
# Options
NUMDAYS=3650 # 10 years
error() {
echo "Error: $1"
exit 1
}
@JonathonReinhart
JonathonReinhart / check-certkey.sh
Created July 11, 2022 06:38
Verify X.509 certificate and key match
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "Usage: $(basename $0) CERTFILE KEYFILE"
exit 1
fi
certpath="$1"
keypath="$2"
@JonathonReinhart
JonathonReinhart / svcwait.sh
Created February 11, 2022 22:19
Wait for service to accept connections, using bash /dev/tcp
#!/bin/bash
host="127.0.0.1"
port="13337"
maxwait=5
dur=0
while true; do
( echo -n "" > /dev/tcp/$host/$port ) 2>/dev/null
if [[ $? -eq 0 ]]; then
@JonathonReinhart
JonathonReinhart / parse_121.py
Created February 9, 2022 03:09
RFC3442 Classless Route Option (121) parser
#!/usr/bin/env python3
# https://www.rfc-editor.org/rfc/rfc3442.html
from binascii import unhexlify
from socket import inet_ntop, AF_INET
from io import BytesIO
import math
"""
Classless Route Option Format