Last active
February 21, 2026 14:39
-
-
Save jojonas/8a49555f479030b358ec to your computer and use it in GitHub Desktop.
Love2d executable unpacker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import os, os.path | |
| import zipfile | |
| import io | |
| def readui32(file): | |
| bytes = file.read(4) | |
| number = bytes[0] | |
| number += bytes[1] << 8 | |
| number += bytes[2] << 16 | |
| number += bytes[3] << 24 | |
| return number | |
| def gotozipstart(file): | |
| SIGNATURE = b'PK\x05\x06' | |
| file.seek(0, 2) | |
| filesize = file.tell() | |
| # scan the last 65k (2^16) for the zip signature | |
| signature_position = filesize | |
| while signature_position > filesize - (2 << 16): | |
| file.seek(signature_position, 0) | |
| data = file.read(len(SIGNATURE)) | |
| if data == SIGNATURE: | |
| break | |
| signature_position -= 1 | |
| else: | |
| raise ValueError("Corrupted zip archive.") | |
| file.seek(8, 1) # skip 8 bytes | |
| size = readui32(file) | |
| offset = readui32(file) | |
| start = (signature_position - offset) - size | |
| file.seek(start, 0) | |
| def unpack(executablename, unzipdestination=None, lovefilename=True): | |
| with open(executablename, 'rb') as executable: | |
| gotozipstart(executable) | |
| data = executable.read() | |
| if lovefilename: | |
| with open(lovefilename, 'wb') as lovefile: | |
| lovefile.write(data) | |
| if unzipdestination: | |
| if not os.path.isdir(unzipdestination): | |
| os.makedirs(unzipdestination) | |
| zipdata = io.BytesIO(data) | |
| with zipfile.ZipFile(zipdata, 'r') as zip: | |
| zip.extractall(unzipdestination) | |
| if __name__=="__main__": | |
| parser = argparse.ArgumentParser(description='Unpack a love executable.') | |
| parser.add_argument('-x', '--extract', metavar="DESTINATION", type=str, help="Unzip files to this folder") | |
| parser.add_argument('-l', '--love', metavar="DESTINATION", type=str, help="Filename of the .love file to write.") | |
| parser.add_argument('executable', type=str, help='Executable to unpack') | |
| args = parser.parse_args() | |
| unpack(args.executable, unzipdestination=args.extract, lovefilename=args.love) | |
cool. i can see inside the code of snacktorio on itch.io thanks to this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks! Could I use this in a project?