Skip to content

Instantly share code, notes, and snippets.

@0xWDG
Forked from averagesecurityguy/pdf_flatedecode.py
Created April 30, 2019 09:51
Show Gist options
  • Save 0xWDG/3cc7a6b597df2617544cf9af8c055768 to your computer and use it in GitHub Desktop.
Save 0xWDG/3cc7a6b597df2617544cf9af8c055768 to your computer and use it in GitHub Desktop.
Decompress FlateDecode Objects in PDF
#!/bin/bash
import re
import zlib
pdf = open("some_doc.pdf", "rb").read()
stream = re.compile(r'.*?FlateDecode.*?stream(.*?)endstream', re.S)
for s in stream.findall(pdf):
s = s.strip('\r\n')
try:
print(zlib.decompress(s))
print("")
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment