Skip to content

Instantly share code, notes, and snippets.

@UserUnknownFactor
UserUnknownFactor / dump_rbr_strings.py
Last active February 25, 2025 09:52
Bakin resource extractor
import os, re, argparse, glob
from unicodedata import category
from filetranslate.service_fn import write_csv_list, read_csv_list, read_csv_dict
from filetranslate.language_fn import tag_hash
# NOTE: This should work for both Bakin RPG Maker and Smile Game Builder files
def write_7bit_encoded_int(stream, value):
result = bytearray()
while True:
@UserUnknownFactor
UserUnknownFactor / dump_unreal_strings.py
Last active December 21, 2023 13:02
Python tool to dump all strings from Unreal .uexp file of unknown format
# coding: utf-8
# Python tool to dump all strings from Unreal .uexp files of unknown format
import argparse, sys, os, glob, re, struct, csv, hashlib, math, zlib
from multiprocessing import Pool
DUMP_ALL_STRINGS = False
DATA_NAMES = list(glob.glob('.\\**\\*.uexp', recursive=True)) + list(glob.glob('.\\**\\*.uasset', recursive=True))
ESCAPE_CHAR = '¶'
DELIMITER_CHAR = '→'
@UserUnknownFactor
UserUnknownFactor / consomeriyo.ttf
Last active January 2, 2024 03:55
Consolas+Meiryo hybrid font for showing Japanese characters in windows console with chcp 65001 (utf-8) encoding.
This file has been truncated, but you can view the full file.
@UserUnknownFactor
UserUnknownFactor / config-dnsquery.xml
Last active May 5, 2023 04:22
Sysmon config to only check DNS requests from a specific source
<Sysmon schemaversion="4.83">
<!--
Sysmon (https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon)
config to only monitor DNS requests from specific processes.
Install it like this:
sysmon -accepteula -i config-dnsquery.xml
or reconfigure, if it's already installed before:
sysmon -c config-dnsquery.xml
To check events run:
mmc eventvwr.msc
@UserUnknownFactor
UserUnknownFactor / revert_kblayout.cmd
Last active January 19, 2023 18:35
Kill that windows language switcher floaty thingy (Windows 10)
@echo off
cd /d "%~dp0"
Title "Reverting input layout popup to Windows 10 default..."
::filedll
set filedll=%windir%\system32\InputSwitch.dll
takeown /F %filedll% /A
icacls %filedll% /grant:r "*S-1-5-32-544":f
icacls %filedll% /setowner "*S-1-5-32-544" /C /L /Q
@UserUnknownFactor
UserUnknownFactor / unity_typetree_to_kaitai_conv.py
Last active February 24, 2024 07:59
Converts TypeTree generated by UnityPy reflection generator to .ksy format of KaitaiStruct for parsing analysys
from sys import argv
import json, re
from ctypes import c_uint32
from tqdm import tqdm
# For usage with KaitaiStruct visualisers
# (like https://userunknownfactor.github.io/ for example)
extract_class = "ClassName"
@UserUnknownFactor
UserUnknownFactor / patch_binary.cmd
Last active March 15, 2025 14:53
Example patching script for binary executables written in PowerShell and running from a cmd batch file
@powershell.exe -ExecutionPolicy Bypass -Command "$_=((Get-Content \"%~f0\") -join \"`n\");$script=$_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9); &([ScriptBlock]::Create($script)) %*"
@goto :EOF
# PowerShell script starts here, we can also pass parameters like this since they are passed to the script block
param($parameter1, $parameter2, $parameter3)
$fileName = "game.exe" // game file
$fileHashString = "abcdef12345678901111111111111111" // the file's MD5 hash
function To-Utf16 {
@UserUnknownFactor
UserUnknownFactor / check_disk_errors.py
Last active March 3, 2025 13:09
Python Windows utility to check what NTFS files correspond to what bad sectors on disk that showed up as failed in System Log (also corresponds to bad physical sector reads in low-level disk checking tools that use native Windows API).
import win32evtlog # requires pywin32 preinstalled: pip install pywin32
import os, sys, platform, tempfile, subprocess, base64, hashlib
from struct import unpack
import ctypes
from ctypes.wintypes import HANDLE
from ctypes.wintypes import BOOL
from ctypes.wintypes import HWND
from ctypes.wintypes import DWORD
from ctypes.wintypes import ULONG
from ctypes.wintypes import USHORT
@UserUnknownFactor
UserUnknownFactor / textutf16y.py
Last active September 16, 2023 02:10
Convert a group of files with unknown encodings to UTF-16 (Python)
import os, sys
from glob import iglob
work_dir = os.getcwd()
file_list = (
[f for f in iglob(os.path.join(work_dir, '**/*.ks'), recursive=True) if os.path.isfile(f)] +
[f for f in iglob(os.path.join(work_dir, '**/*.tjs'), recursive=True) if os.path.isfile(f)]
)
all_codecs = ['utf_16', 'utf_8_sig', 'ascii', 'cp932', 'utf_8', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213']
@UserUnknownFactor
UserUnknownFactor / pck_unpack.py
Last active April 8, 2023 15:10
Godot Engine 3 .pck file unpacker/repacker (unencrypted only)
import io, os, argparse, sys, textwrap, re, enum
from struct import unpack, pack
# NOTE: Repacking mode adds file to the end of the previous archive if it's
# larger than old or replaces old one if less.
# WARNING: It MODIFIES ORIGINAL FILE on repack so BACKUP it BEFORE REPACKING!!!
class EndianBinaryReader:
endian: str
Length: int