Skip to content

Instantly share code, notes, and snippets.

@levisre
Created February 16, 2016 03:03
Show Gist options
  • Save levisre/6ddebd47c1a26bba6b8f to your computer and use it in GitHub Desktop.
Save levisre/6ddebd47c1a26bba6b8f to your computer and use it in GitHub Desktop.
Launch4j Unpacker
import pefile
import sys
def main(argv):
try:
fileNameInput = argv
print "Parsing file : " + argv
FileHandle = open(fileNameInput,"rb")
inputStream = FileHandle.read()
peHandle = pefile.PE(fileNameInput)
overlayOffset = peHandle.get_overlay_data_start_offset()
if(overlayOffset):
print "Found overlay Data at offset " + hex(overlayOffset) + ", extracting..."
fileOutput = open(fileNameInput+"-extracted.jar", "wb")
fileOutput.write(inputStream[overlayOffset:])
peHandle.close()
fileOutput.close()
FileHandle.close()
print "file saved to " + fileNameInput + "-extracted.jar"
except:
print "Error: %s" % sys.exc_info()[0]
print "Could not extract embeded JAR file. Existing..."
if __name__=="__main__":
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment