Created
April 24, 2018 00:10
-
-
Save snosrap/c71c83a0b6aeb15d1b5f4d2e823f1f6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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(sys.stdin.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment