Skip to content

Instantly share code, notes, and snippets.

@UserUnknownFactor
UserUnknownFactor / key_xor_files_by_ext.py
Created May 2, 2025 08:39
Tool to xor multiple files with multi-byte key at once by extension
import os
import numpy as np
import re
def xor_files(key_string, extension=".txt", prefix="dec_", bytes_required=6):
key_bytes = bytes([int(x, 16) for x in key_string.split()])
#assert len(key_bytes) == bytes_required, f"Key must be exactly {bytes_required} bytes"
# Get all files in the current directory
all_files = [f for f in os.listdir() if f.lower().endswith(extension)]
@UserUnknownFactor
UserUnknownFactor / ccd2iso.py
Created April 11, 2025 09:29
CCD to ISO legacy CD image converter
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
"""Tool to convert CloneCD .img files to ISO 9660 .iso files."""
from typing import Any
from io import BytesIO
import contextlib
import os
@UserUnknownFactor
UserUnknownFactor / srpg_dts.ksy
Last active March 15, 2025 14:18
SRPG extractor tool
meta:
id: srpg_studio_dts
file-extension: dts
endian: le
title: SRPG Studio Data Format
application: SRPG Studio
license: MIT
encoding: UTF-16LE
doc: |
@UserUnknownFactor
UserUnknownFactor / searchgists.md
Last active December 6, 2024 08:26
How to search gists (enter this in the search box along with your search terms)
  • Get all gists from the user UserUnknownFactor: user:UserUnknownFactor
  • Find all gists with a .yml extension: extension:yml
  • Find all gists with HTML files: language:html
  • Find all gists with a ".bash_profile" file: filename:.bash_profile
  • Excludes all results containing your search term. : NOT
  • Find gists with greater than 100 stars. : stars:>100
  • Include anonymous gists in your search. : anon:true
  • Search all forked gists for results. : fork:only
  • Find gists containing a file size larger than 1000kbs. : size:>1000
  • Find all gists with the word "fetch" by UserUnknownFactor updated or created recently. :
@UserUnknownFactor
UserUnknownFactor / pycryptojs.py
Last active August 27, 2024 15:28
Tool to decrypt/encrypt CryptoJS encrypted files in Python
# Tool to decrypt/encrypt CryptoJS encrypted files in Python
import os, base64, glob
from hashlib import md5
from Crypto.Cipher import AES # requires: pip install pycryptodome
from Crypto import Random
STREAM_PREFIX = b"Salted__"
def pad(s):
@UserUnknownFactor
UserUnknownFactor / animate_pngs.py
Last active August 22, 2024 15:37
Tool to find images named prefix_NN_postfix.png and convert them to APNGs
import os, re, glob
import numpy as np
from PIL import Image, ImageChops
from collections import defaultdict
# Finds sequences of images with common name part+_<frame#>_etc.png
# and merges them into a single animated PNG.
INITIAL_SPEED = 20
TYPE2 = True
@UserUnknownFactor
UserUnknownFactor / diff_pngs.py
Created August 22, 2024 12:00
Python script for automatic diffing of PNGs
# -*- coding: utf-8 -*-
# This script finds all PNGs of similar looks/size in the specified
# folder and produces a base image and a series of diffs with it.
import os
import sys
from PIL import Image
import numpy as np
from collections import defaultdict
DIFF_THRESHOLD = 0 # Adjust this based on diff sensitivity needed
@UserUnknownFactor
UserUnknownFactor / extract_exe.py
Last active May 18, 2025 09:08
Split a file into two by binary signature
import pefile
import sys
import os
import glob
def extract_exe_from_bundle(bundle_path, output_path=None, data_path=None):
if output_path is None:
output_path = os.path.splitext(bundle_path)[0] + "_real.exe"
if data_path is None:
data_path = os.path.splitext(bundle_path)[0] + "data.bin"
@UserUnknownFactor
UserUnknownFactor / apply_texts.py
Last active June 30, 2024 10:21
Tools for mass image translation (text applying tested on PGMMV with images of the same type/size that only differ in text area)
import os, csv, glob, re
from PIL import Image, ImageDraw, ImageFont
"""
This tool can read translations from:
`original→translation→image_without_extension[;text_pos_x,text_pos_y;overlay_path;overlay_x,overlay_y;custom_font;font_size;font_color]`
formatted .csv file and apply it to all images in the specified folder, after replacing
background to a specified image at specified coordinates. Text supports colored borders
and style tags like <b>, <i> (not enabled now) or <color="#ff0000"> in the text.
All stuff is only configurable in the code.
"""
@UserUnknownFactor
UserUnknownFactor / pymd5.py
Last active May 24, 2024 08:18
Pure Python implementation of MD5 algorithm for experiments and custom mods
#!/usr/bin/python3
# RSA Data Security, Inc., MD5 message-digest algorithm
# Copyright (C) 1991-1992, RSA Data Security, Inc.
"""
## pymd5 module
### The MD5 hash implementation in pure Python
The module exposes same methods as hashlib.md5 and a couple of
low-level methods to help with crypto experiments.