Skip to content

Instantly share code, notes, and snippets.

@lambda-fairy
Created January 2, 2017 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambda-fairy/2e08d772c48cc87f13dcb7763afed514 to your computer and use it in GitHub Desktop.
Save lambda-fairy/2e08d772c48cc87f13dcb7763afed514 to your computer and use it in GitHub Desktop.
Script for extracting an SWF file from a projector executable
#!/usr/bin/env python3
"""Extracts an SWF file from a projector executable"""
import os
import sys
def strip_exe_extension(path):
root, ext = os.path.splitext(path)
if ext.casefold() == '.exe':
return root
else:
return path
def main(path):
content = open(path, 'rb').read()
index = content.find(b'FWS')
if index >= 0:
output_path = strip_exe_extension(path) + '.swf'
with open(output_path, 'wb') as output:
output.write(content[index:])
else:
return 'could not find embedded Flash movie'
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit('Usage: {} FILE.EXE'.format(sys.argv[0]))
else:
sys.exit(main(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment