Skip to content

Instantly share code, notes, and snippets.

@Tony3-sec
Created January 25, 2018 10:19
Show Gist options
  • Save Tony3-sec/5443ee9757ab8caa65ea7f3df2c49db7 to your computer and use it in GitHub Desktop.
Save Tony3-sec/5443ee9757ab8caa65ea7f3df2c49db7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
zlib compress or decompress the payload
'''
import sys
import argparse
import zlib
import binascii
def decomp(hexstring):
d = binascii.unhexlify(hexstring)
decompressed = zlib.decompress(d)
print(decompressed)
def comp(plain_text):
c = zlib.compress(plain_text)
compressed = binascii.hexlify(c)
print(compressed)
parser = argparse.ArgumentParser(description="zlib compress or decompress the payload")
parser.add_argument("-d", "--decompress", action="store", help="hex string to decompress", dest="HEX")
parser.add_argument("-c", "--compress", action="store", help="plain text string to compress", dest="PLAIN")
args = parser.parse_args()
if args.HEX:
decomp(sys.argv[2])
elif args.PLAIN:
comp(sys.argv[2])
else:
parser.print_help()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment