Skip to content

Instantly share code, notes, and snippets.

@jojonas
Last active February 21, 2026 14:39
Show Gist options
  • Select an option

  • Save jojonas/8a49555f479030b358ec to your computer and use it in GitHub Desktop.

Select an option

Save jojonas/8a49555f479030b358ec to your computer and use it in GitHub Desktop.
Love2d executable unpacker.
import argparse
import os, os.path
import zipfile
import io
def iterchunks(file, chunksize):
while True:
chunk = file.read(chunksize)
if not chunk:
break
else:
yield chunk
def unpack(executablename, unzip=None, lovefilename=True):
MAGIC = b'PK\x03\x04'
with open(executablename, 'rb') as executable:
for chunk in iterchunks(executable, 32):
if chunk.startswith(MAGIC):
break
else: # nobreak
raise ValueError("Magic bytes not found.")
data = chunk + executable.read()
if lovefilename:
with open(lovefilename, 'wb') as lovefile:
lovefile.write(data)
if unzip:
zipdata = io.BytesIO(data)
with zipfile.ZipFile(zipdata, 'r') as zip:
zip.extractall(unzip)
if __name__=="__main__":
parser = argparse.ArgumentParser(description='Unpack a love executable.')
parser.add_argument('-x', '--extract', type=str, help="Unzip files to this folder")
parser.add_argument('-l', '--love', 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, unzip=args.extract, lovefilename=args.love)
@TazyFoundSoup
Copy link

Nice, thanks! Could I use this in a project?

@glkdrlgkrlzflnjkgh
Copy link

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