Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2018 00:10
What would you like to do?
import sys, zlib, re
def print_streams(bytes, start=0):
r = re.compile("BT.*?\((.*?)\)[\s]*?Tj.*?ET", re.DOTALL)
while True:
start = bytes.find("stream", bytes.find("FlateDecode", start)) + len("stream")
if start < len("stream"): return
end = bytes.find("endstream", start)
print "\n".join(r.findall(zlib.decompress(bytes[start:end].lstrip())))
if len(sys.argv) > 1: [print_streams(open(arg, "rb").read()) for arg in sys.argv[1:]]
else: print_streams(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment