Skip to content

Instantly share code, notes, and snippets.

View sethmlarson's full-sized avatar
🛡️

Seth Larson sethmlarson

🛡️
View GitHub Profile
@sethmlarson
sethmlarson / lan-party-calculator.py
Created March 24, 2026 03:36
LAN Party Calculator for Mario Kart, Kirby Air Riders, and F-Zero
# LAN Party Calculator for Mario Kart, Kirby Air Riders, and F-Zero
# Code License: MIT, Copyright 2026 Seth Larson
# Data License: CC-BY-SA 4.0, Wikipedia
import dataclasses
import enum
import math
from dataclasses import dataclass
from textwrap import dedent as d
@sethmlarson
sethmlarson / sugarcookie.py
Created December 31, 2025 18:05
Script for cutting spritesheets like cookies using Python and Pillow
#!/usr/bin/env python
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "Pillow",
# "tqdm"
# ]
# ///
# License: MIT
# Copyright 2025, Seth Larson
@sethmlarson
sethmlarson / dat2bin.cpp
Last active March 4, 2026 19:00
Convert .dat files from "Sonic Mega Collection" on GameCube to .md Genesis ROMs
#include <fstream>
#include <string>
int processdata(unsigned char *InData, unsigned char *OutData, int filedatasize) // OutData=0 to get size
{
int CurrIn = 0x4; //Skip size
int CurrOut = 0;
while (CurrIn < filedatasize)
{
int Code = InData[CurrIn++];
# License: MIT
import sys
import mmap
import hashlib
import struct
# MD5 hashes from https://datomatic.no-intro.org
# Headerless, as header is changed from non-AC releases.
known_roms = {
@sethmlarson
sethmlarson / cve-2025-8194.py
Created July 29, 2025 13:37
Mitigation for CVE-2025-8194
import tarfile
def _block_patched(self, count):
if count < 0:
raise tarfile.InvalidHeaderError("invalid offset")
return _block_patched._orig_block(self, count)
_block_patched._orig_block = tarfile.TarInfo._block
tarfile.TarInfo._block = _block_patched
@sethmlarson
sethmlarson / mitigation.py
Last active December 21, 2025 20:45
Mitigation for CVE-2025-4517, CVE-2025-4330, CVE-2025-4138, and CVE-2024-12718
import pathlib
# Avoid insecure segments in link names.
# 'tar' is a tarfile open for reading.
for member in tar.getmembers():
if member.linkname and '..' in pathlib.Path(member.linkname).parts:
raise OSError("Tarfile with insecure segment ('..') in linkname")
# Now safe to extract members with the data filter.
tar.extractall(filter="data")
@sethmlarson
sethmlarson / pikmin-2-treasure-hoard.py
Last active December 18, 2025 18:21
Generate a Pikmin 2 treasure hoard progress report across all regions from save data
import hashlib
import os
import re
# List of treasure names by regional name.
# Index in the list is their ID. 0=US, 1=JP, 2=PAL
# Key items are regionless and stored in another part
# of Pikmin 2 saves, so they get their own IDs.
TREASURE_IDS = [
["Rubber Ugly", "Rubber Ugly", "Rubber Ugly"],
@sethmlarson
sethmlarson / pycon-us-2025.md
Last active July 14, 2025 17:11
#PyConUS2025
Package Version Ecosystem
python 3.10.12 binary
adduser 3.118ubuntu5 deb
apt 2.4.11 deb
asymptote 2.78+ds-2 deb
base-files 12ubuntu4.4 deb
base-passwd 3.5.52build1 deb
bash 5.1-6ubuntu1 deb
biber 2.17-2 deb
bsdutils 1:2.37.2-4ubuntu3 deb
@sethmlarson
sethmlarson / xar-generator.py
Created January 29, 2024 17:09
Simple script for constructing small XAR files (License: CC0-1.0)
"""
Simple script for constructing small XAR files.
License: CC0-1.0
"""
import datetime
import gzip
import hashlib
import io
import struct