Created
January 25, 2018 10:19
-
-
Save Tony3-sec/5443ee9757ab8caa65ea7f3df2c49db7 to your computer and use it in GitHub Desktop.
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 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