Created
January 2, 2017 05:51
-
-
Save lambda-fairy/2e08d772c48cc87f13dcb7763afed514 to your computer and use it in GitHub Desktop.
Script for extracting an SWF file from a projector executable
This file contains 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
#!/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