Skip to content

Instantly share code, notes, and snippets.

View DavidBuchanan314's full-sized avatar
🌍
Hack the planet!

David Buchanan DavidBuchanan314

🌍
Hack the planet!
View GitHub Profile
import sys
import zlib
PNG_MAGIC = b"\x89PNG\r\n\x1a\n"
def parse_chunks(stream, out):
magic = stream.read(8)
assert(magic == PNG_MAGIC)
out.write(magic)
/*******************************************************************************
*
* (C) COPYRIGHT AUTHORS, 2016 - 2017
*
* TITLE: MAIN.C
*
* VERSION: 1.01
*
* DATE: 20 Apr 2017
*
# This code is very hacky, please excuse the nonsensical variable/function naming
# See https://twitter.com/David3141593/status/1442883432925773829 for context
# Derived from this implementation of XXHASH64: https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h
from xxhash import xxh64
XXH_PRIME64_1 = 0x9E3779B185EBCA87
XXH_PRIME64_2 = 0xC2B2AE3D27D4EB4F
XXH_PRIME64_3 = 0x165667B19E3779F9
XXH_PRIME64_4 = 0x85EBCA77C2B2AE63
@DavidBuchanan314
DavidBuchanan314 / accuweather_apis.txt
Created August 18, 2021 10:50
find . -type f -exec cat {} \;| grep "HashMap<String, String> hashMap = " | grep -Eo "\\([^\\(\\)]*\\)" | grep '", "' | cut -d '"' -f 2,4 --output-delimiter=" " | column -t
AllPartners locations/v1/partners?apikey={apikey}
PartnerByKey locations/v1/partners/{partnerId}?apikey={apikey}
Languages translations/v1/languages?apikey={apikey}
TranslationGroups translations/v1/groups?apikey={apikey}
TranslationsByGroup translations/v1/groups/{groupId}?apikey={apikey}&language={language}
IndexValuesByStationCode indices/v1/daily/{dayCount}/stations/{stationCode}/{indexId}.json?apikey={apikey}&locationOffset={locationOffset}&language={language}&details={details}&startDate={startDate}
GroupValuesByStationCode indices/v1/daily/{dayCount}/stations/{stationCode}/groups/{groupId}.json?apikey={apikey}&locationOffset={locationOffset}&language={language}&details={details}
AlertsByGeoposition alerts/v1/geoposition.json?apikey={apikey}&q={latitude},{longitude}&language={language}&details={deta
@DavidBuchanan314
DavidBuchanan314 / X25519.py
Last active March 9, 2022 23:23
Pure python Curve25519 scalar point multiplication, as defined in RFC7748
# https://datatracker.ietf.org/doc/html/rfc7748
# This code is based directly on the pseudocode in the RFC, translated into Python 3
# This implementation is NOT CONSTANT TIME (due to Python's underlying arithmetic ops not being guaranteed constant time)
# See also: https://en.wikipedia.org/wiki/Montgomery_curve
p = 2**255 - 19
def decodeScalar25519(k):
k = bytearray(k)
# https://github.com/Atmosphere-NX/Atmosphere/blob/master/libraries/libvapours/include/vapours/ams/ams_fatal_error_context.hpp
from ctypes import *
import subprocess
import string
import sys
MaxStackTrace = 0x20
MaxStackDumpSize = 0x100
ThreadLocalSize = 0x100
@DavidBuchanan314
DavidBuchanan314 / tinypng.py
Created March 16, 2021 09:47
You can use imagemagic's `convert` command to easily generate the raw RGB data file
import zlib
WIDTH = 570
HEIGHT = 453
IMG_RGB = open("source.rgb", "rb")
def pack_chunk(chunktype, chunkdata):
chunk = len(chunkdata).to_bytes(4, "big")
chunk += chunktype
chunk += chunkdata
@DavidBuchanan314
DavidBuchanan314 / rainbow_table.txt
Created February 24, 2021 14:13
4-digit pin code sha256 rainbow table
hash pin
00037f 1039
00039a 3633
000c15 5848
0013fa 8554
00150b 2650
0020a5 9940
0029f4 8536
002abd 9004
@DavidBuchanan314
DavidBuchanan314 / README.md
Last active January 21, 2024 04:03
Classic iPod software reinstall/restore without iTunes, on Linux

iTunes-less Classic iPod Restore Guide

I have tested this on a classic 4th-gen monochrome "clickwheel" iPod. I imagine this process works similarly for iPods of the same era. I'm not the first person to do this, but a lot of documentation is on dead wikis and is generally hard to come by.

Extract your firmware image from an .ipsw file, set the IPOD and FW_IMAGE variables in the bash script, and run it as root. Then cross your fingers.

If everything worked, the partition layout should look something like this:

Disk /dev/sdc: 119.08 GiB, 127865454080 bytes, 249737215 sectors
@DavidBuchanan314
DavidBuchanan314 / life.c
Last active August 9, 2023 23:12
Yet another reformatting of my tiny game of life implementation. Valid ANSI C with no (default) compiler warnings or UB
#define F\
for(i=l;i\
<l*4; i++)
main(){int
i,j,w=512,
n,l=w*w,o[
]={~w,-w,-
w+1,-1,1,w
-1,w,w+1},
b[l*5];F b