Skip to content

Instantly share code, notes, and snippets.

@averagesecurityguy
Last active March 24, 2024 02:44
Show Gist options
  • Star 42 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save averagesecurityguy/ba8d9ed3c59c1deffbd1390dafa5a3c2 to your computer and use it in GitHub Desktop.
Save averagesecurityguy/ba8d9ed3c59c1deffbd1390dafa5a3c2 to your computer and use it in GitHub Desktop.
Decompress FlateDecode Objects in PDF
#!/usr/bin/env python3
# This script is designed to do one thing and one thing only. It will find each
# of the FlateDecode streams in a PDF document using a regular expression,
# unzip them, and print out the unzipped data. You can do the same in any
# programming language you choose.
#
# This is NOT a generic PDF decoder, if you need a generic PDF decoder, please
# take a look at pdf-parser by Didier Stevens, which is included in Kali linux.
# https://tools.kali.org/forensics/pdf-parser.
#
# Any requests to decode a PDF will be ignored.
import re
import zlib
pdf = open("some_doc.pdf", "rb").read()
stream = re.compile(rb'.*?FlateDecode.*?stream(.*?)endstream', re.S)
for s in stream.findall(pdf):
s = s.strip(b'\r\n')
try:
print(zlib.decompress(s))
print("")
except:
pass
@ShankeyTayal
Copy link

above script it returning below output and how can i decode it?

"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00EBCLIJ#\x1f \xac\xab\xab\xa5\xa4\xa4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00zwx?;<#\x1f \x9e\x9d\x9d\xa5\xa4\xa4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\xc7\xc7\xc8\xc7\xc7\xcc\xcb\xcb\xcf\xce\xce\xd6\xd5\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\xf1\xf1\xdc\xdc\xdc\xd5\xd5\xd5\xd1\xd0\xd0\xd5\xd5\xd5\xe3\xe3\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x91\x8f\x8f\xe3\xe3\xe3\xc8\xc7\xc7\x83\x81\x81\x9e\x9d\x9d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\xf1\xf1\xb3\xb2\xb2\x83\x81\x81a^^\xc8\xc7\xc7\xc8\xc7\xc7\xd6\xd5\xd5nlla^^\x91\x8f\x8f\x00\x00\x00\x91\x8f\x8fusslijuss\x83\x81\x81qnoC?@'#$PMNgee\x97\x96\x96a^^LII'#$C?@spq\x84\x81\x82\x00\x00\x00\x00\x00\x00\xd6\xd5\xd5\x98\x96\x96\x91\x8f\x8f\xf1\xf1\xf1\xc8\xc7\xc7\xc8\xc7\xc7\xe3\xe3\xe3\x7f}~|zz\xba\xb9\xb9\x00\x00\x00hefEBC:67#\x1f #\x1f #\x1f #\x1f #\x1f :67EBChef\x00\x00\x00\x9e\x9d\x9dnllURS,()'#$HDE\x8c\x8a\x8b\xba\xb9\xb9\xf1\xf1\xf1\xe3\xe3\xe3\x9e\x9d\x9d\x87\x85\x86ZWX\x8c\x8a\x8b\x8c\x8a\x8bzwx512,()hee\x8a\x88\x88\xd6\xd5\xd5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xba\xb9\xb9\xa5\xa4\xa4\xaf\xad\xae\xa8\xa6\xa6\xb3\xb2\xb2uss\x9a\x98\x98\x95\x93\x94\x83\x81\x81C?@'#$LIIa^^\x91\x8f\x8f\xb5\xb4\xb4\xf1\xf1\xf1vst#\x1f #\x1f #\x1f #\x1f 1-.\x91\x8f\x8flij\x91\x8f\x8fuss\x91\x8f\x8fZWXZWX\xac\xab\xab\x84\x81\x82#\x1f #\x1f 1-.\x9e\x9d\x9db_\x91\x8f\x8f1-.#\x1f #\x1f \x84\x81\x82hee\x91\x8f\x8f\xc8\xc7\xc7\x95\x93\x94\xd6\xd5\xd5ZWX#\x1f #\x1f #\x1f #\x1f ?;<\xba\xb9\xb9\x8c\x8a\x8a\xc8\xc7\xc7a^_hef#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f hefa^_vstgee\x9e\x9d\x9d?;<#\x1f #\x1f 1-.\x84\x81\x82\xf1\xf1\xf1\xba\xb9\xb9\xe3\xe3\xe3\xe3\xe3\xe3ZWXZWXZWX\xf1\xf1\xf1ZWX#\x1f #\x1f ?;<\xd6\xd5\xd5\xa8\xa6\xa6\xf1\xf1\xf1\x00\x00\x00\x00\x00\x00uss\x91\x8f\x8fZWX\xd6\xd5\xd5\xa2\xa0\xa0\x91\x8f\x8fZWX\xe3\xe3\xe3\x84\x81\x82#\x1f #\x1f 1-.\x91\x8f\x8fuss\xf1\xf1\xf1?;<#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \x91\x8f\x8fheelijZWX#\x1f #\x1f ?;<#\x1f #\x1f #\x1f #\x1f #\x1f vst#\x1f #\x1f #\x1f #\x1f #\x1f \x91\x8f\x8fuss\x91\x8f\x8f\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \xc8\xc7\xc7\x9f\x9d\x9dqnoZWX#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f ZWX|zzussvst#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f LIJ\xf1\xf1\xf1\xce\xce\xce\xd6\xd5\xd5#\x1f #\x1f #\x1f ZWX#\x1f #\x1f #\x1f #\x1f 1-.\xf1\xf1\xf1\xdc\xdc\xdc\x00\x00\x00\x00\x00\x00lijZWX#\x1f \xc8\xc7\xc7\x9c\x9a\x9bZWX#\x1f LIJ#\x1f #\x1f ?;<#\x1f #\x1f \xac\xab\xab\x91\x8f\x8f#\x1f #\x1f #\x1f \x84\x81\x82\x84\x81\x821-.#\x1f #\x1f ?;<QMNZWXZWX#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f ZWXZWWqnoZWX#\x1f #\x1f 1-.\x91\x8f\x8fvst#\x1f #\x1f #\x1f vst\x88\x85\x86uss\x91\x8f\x8fZWXZWXZWX?;<#\x1f #\x1f #\x1f hef\x91\x8f\x8f\xc8\xc7\xc7#\x1f #\x1f #\x1f ZWX\x84\x81\x82#\x1f #\x1f #\x1f \x91\x8f\x8f\xa2\xa0\xa0OLM#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \xc8\xc7\xc7\xc3\xc2\xc2\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f #\x1f hef\xf1\xf1\xf1usshef#\x1f LIJhef#\x1f #\x1f \x91\x8f\x8f\x93\x91\x91\x7f|}\x84\x81\x82#\x1f #\x1f #\x1f ,()ZWXZWX#\x1f #\x1f #\x1f \xba\xb9\xb9\xf1\xf1\xf1?;<#\x1f #\x1f #\x1f \x9e\x9d\x9d\xf1\xf1\xf1LIJ#\x1f #\x1f #\x1f 512EBC1-.#\x1f #\x1f \xc8\xc7\xc7\x9e\x9d\x9d\x7f}}LIJ#\x1f #\x1f ZWXca\x91\x8f\x8fusslijxuv\xf1\xf1\xf11-.#\x1f #\x1f 1-.\xe3\xe3\xe3\x88\x86\x87hef#\x1f #\x1f ?;<ZWXspq\x84\x81\x82#\x1f #\x1f 1-.khiLII#\x1f #\x1f #\x1f ?;<\xe3\xe3\xe3\xac\xab\xab#\x1f #\x1f #\x1f \x91\x8f\x8f\xa3\xa1\xa1\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f 1-.\xf1\xf1\xf1\xc3\xc2\xc2\xbe\xbd\xbe\xe3\xe3\xe3#\x1f #\x1f zwxwuv\xc8\xc7\xc7\xf1\xf1\xf1wuu\xc8\xc7\xc7vst#\x1f #\x1f #\x1f #\x1f ZWXZWX#\x1f #\x1f LIJ}{|\x99\x97\x97\x84\x81\x82#\x1f #\x1f 1-.rpp\x99\x97\x97\x91\x8f\x8f#\x1f #\x1f #\x1f #\x1f 1-.\x83\x81\x81\xf1\xf1\xf1\xc8\xc7\xc7{yy\xf1\xf1\xf1\xc8\xc7\xc7LIJ#\x1f #\x1f ZWXZWX\x00\x00\x00\x00\x00\x00\x9e\x9d\x9d\x83\x81\x81ZWX#\x1f #\x1f #\x1f \xac\xab\xab\x95\x93\x94gee1-.#\x1f #\x1f \x84\x81\x82qno\xac\xab\xab\xba\xb9\xb9#\x1f #\x1f #\x1f \xc8\xc7\xc7_\]#\x1f #\x1f #\x1f \xac\xab\xab\xa6\xa5\xa5dbb#\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \x84\x81\x82\x8d\x8b\x8c\xf1\xf1\xf1\xe3\xe3\xe3SPP#\x1f #\x1f \xa3\xa1\xa2\xe3\xe3\xe3vst?;<#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f ZWXZWX#\x1f #\x1f ZWXURS\x8c\x8a\x8a\x91\x8f\x8f#\x1f #\x1f ZWXLIJ\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f #\x1f \xac\xab\xab\xa2\xa0\xa0\xc8\xc7\xc7hef1-.#\x1f #\x1f #\x1f #\x1f #\x1f ZWXZWX\x00\x00\x00\xd6\xd5\xd5\x8c\x8a\x8a\x9e\x9d\x9d#\x1f #\x1f #\x1f hef\x8a\x88\x88\xac\xab\xab'#$#\x1f #\x1f #\x1f \x91\x8f\x8f\x8c\x8a\x8a\xc3\xc2\xc2\xc8\xc7\xc7#\x1f #\x1f #\x1f \xac\xab\xabgee#\x1f #\x1f #\x1f \xc8\xc7\xc7\xbe\xbd\xbd#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \x91\x8f\x8f\x9a\x98\x98\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f \xd6\xd5\xd51-.#\x1f #\x1f #\x1f ?;<?;<#\x1f #\x1f #\x1f #\x1f ZWXZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f VST\x9a\x98\x98\xac\xab\xab#\x1f #\x1f #\x1f #\x1f LIJ1-.#\x1f #\x1f ZWXZWX\x00\x00\x00\x91\x8f\x8f\xd6\xd5\xd51-.#\x1f #\x1f 1-.\xf1\xf1\xf1\xac\xab\xab\x00\x00\x00#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f \x91\x8f\x8f^^#\x1f #\x1f #\x1f \xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \xba\xb9\xb9\xb1\xaf\xaf\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f ZWX#\x1f #\x1f 1-.\xc8\xc7\xc7lij\x91\x8f\x8f#\x1f #\x1f #\x1f #\x1f ZWXZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f mjk\xf1\xf1\xf11-.#\x1f #\x1f LIJ\xe3\xe3\xe3^[\\ZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8fussLIJ#\x1f #\x1f #\x1f \xc8\xc7\xc7\xb1\xaf\xaf\xde\xde\xde\xf1\xf1\xf1'#$#\x1f #\x1f #\x1f \x91\x8f\x8f\x88\x85\x86\xc3\xc2\xc2\xc8\xc7\xc7#\x1f #\x1f #\x1f \x9e\x9d\x9debc#\x1f #\x1f #\x1f \xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \xc8\xc7\xc7\xc3\xc2\xc2\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x99\x97\x97\x9e\x9d\x9d\x91\x8f\x8f#\x1f #\x1f #\x1f LIIussZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f wuu\xc8\xc7\xc7#\x1f #\x1f #\x1f \xc8\xc7\xc7\xb4\xb3\xb3\x83\x81\x81ZWX#\x1f #\x1f ZWX\x8e\x8c\x8c\xa5\xa4\xa4\x91\x8f\x8f#\x1f #\x1f #\x1f ?;<\x91\x8f\x8f\xba\xb9\xb9\xf1\xf1\xf1\x83\x81\x81PLM1-.#\x1f #\x1f vst\x8a\x88\x88\xba\xb9\xb9\xba\xb9\xb9#\x1f #\x1f #\x1f \xc8\xc7\xc7\\YZ#\x1f #\x1f #\x1f \xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \xc8\xc7\xc7\xc8\xc7\xc7\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \x84\x81\x82|zz\xf1\xf1\xf1?;<#\x1f #\x1f #\x1f \xc8\xc7\xc7rpqZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f pnn\xac\xab\xab#\x1f #\x1f #\x1f \xba\xb9\xb9\x8a\x88\x88\xd6\xd5\xd5#\x1f #\x1f #\x1f 1-.\xf1\xf1\xf1\xf1\xf1\xf1#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f vstheevst#\x1f #\x1f 1-.\xf1\xf1\xf1\x81~\x7fvst#\x1f #\x1f 1-.khiLII#\x1f #\x1f #\x1f \xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x97\x96\x96\xba\xb9\xb9\xba\xb9\xb9ussZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \xc8\xc7\xc7\xc8\xc7\xc7\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f \x84\x81\x82?;<#\x1f #\x1f #\x1f #\x1f hefussZWX#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f ZWXZWX\x91\x8f\x8f\x91\x8f\x8f#\x1f #\x1f #\x1f _\\]\xc8\xc7\xc7#\x1f #\x1f #\x1f 1-.\x84\x81\x821-.#\x1f #\x1f #\x1f #\x1f \x9e\x9d\x9d\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f #\x1f ebc\xc8\xc7\xc7#\x1f #\x1f #\x1f LIJvst#\x1f #\x1f #\x1f \x91\x8f\x8fa^^#\x1f #\x1f #\x1f #\x1f \xc8\xc7\xc7\xc8\xc7\xc7#\x1f #\x1f #\x1f #\x1f \x91\x8f\x8f\x87\x85\x85\xac\xab\xab\xc8\xc7\xc7ebcZWX#\x1f \xc8\xc7\xc7\x91\x8f\x8fZWX#\x1f \xc8\xc7\xc7\xc8\xc7\xc7\x00\x00\x00\x00\x00\x00#\x1f #\x1f #\x1f \x84\x81\x82#\x1f #\x1f #\x1f #\x1f #\x1f 1-.?;<#\x1f #\x1f \x84\x81\x82pmnZWX#\x1f #\x1f ZWXlij\x9e\x9d\x9d\x91\x8f\x8f#\x1f #\x1f ZWXlij\x9e\x9d\x9d\x91\x8f\x8f#\x1f #\x1f #\x1f ]Z[\x86\x84\x85LIJ#\x1f #\x1f #\x1f #\x1f #\x1f LIJ#\x1f #\x1f #\x1f \xba\xb9\xb9\xc8\xc7\xc7#\x1f #\x1f LIJ\x84\x81\x82\x91\x8f\x8fvstLIJ#\x1f #\x1f geezwx\x84\x81\x82#\x1f #\x1f #\x1f #\x1f #\x1f #\x1f LIJURS\x91\x8f\x8f512#\x1f #\x1f #\x1f \xc8\xc7\xc7\xd1\xd0\xd0:67#\x1f #\x1f #\x1f \x91\x8f\x8f\xac\xab\xab#\x1f #\x1f jghZWX#\x1f \xc8\xc7\xc7\x9c\x9a\x9bZWX#\x1f \xc8\xc7\xc7\xcc\xcb\xcb\x00\x00\x00\x00\x00\x00:67#\x1f #\x1f \xf1\xf1\xf1\x84\x81\x821-.#\x1f 1-.vst\xe3\xe3\xe3\xd6\xd5\xd5ZWX\x9e\x9d\x9dlijzwx\x91\x8f\x8fZWXZWX\x91\x8f\x8fuss\xa5\xa4\xa4\xba\xb9\xb9ZWXZWX\x91\x8f\x8fuss\xa5\xa4\xa4\xba\xb9\xb9ZWXZWXhefEBC\x97\x96\x96\xe3\xe3\xe3hef#\x1f #\x1f ?;<\x91\x8f\x8f\xf1\xf1\xf1\xac\xab\xabZWX\xc8\xc7\xc7\xac\xab\xab\xf1\xf1\xf1\x9e\x9d\x9d\xe3\xe3\xe3\xae\x93s\xb7\x8f]\xbe\x94\xb5\x8bY\xac\x95y\xe3\xe3\xe3\x91\x8f\x8fZWW\x84\x81\x82qno\xac\xab\xab?;<#\x1f #\x1f 1-.\x91\x8f\x8fURSLIJ\x00\x00\x00>;<ZWXZWXZWX\xe3\xe3\xe3\xd5\xd5\xd5EBChefZWXZWX\xba\xb9\xb9\xe3\xe3\xe31-.LIJVST\x91\x8f\x8fZWX\xd6\xd5\xd5\xa2\xa0\xa0\x91\x8f\x8fZWX\xd6\xd5\xd5\xcf\xce\xce\x00\x00\x00\x00\x00\x00EBChefZWX\xba\xb9\xb9\x8c\x8a\x8bHDE,()C?@\x83\x81\x81\xba\xb9\xb9\xb1\xaf\xb0\x9a\x98\x98\xa6\x8es\xdb\xadr\xe0\xb7\x83\xb8\x9f\x80\x90\x88\x81lijuss\x91\x8f\x8f\xba\xb9\xb9\x8a\x88\x88zwxlijuss\x91\x8f\x8f\xba\xb9\xb9\x8a\x88\x88zwx^[\a^hef\xe3\xe3\xe3\xa5\xa4\xa4zwx:67,()QMN\x95\x93\x94\xba\xb9\xb9\xa7\xa6\xa6\x9a\x98\x98\x91\x8f\x8f\xe7\xe3\xde\xe7\xd1\xb5\xff\xf9\xf1\xfc\xd2\x9c\xfa\xb8d\xfa\xb2V\xf8\x98\x1d\xf9\xabH\xfa\xb8d\xfe\xf2\xe3\xdb\xd2\xc6\x91\x8f\x8f\x00\x00\x00\xac\xab\xabussZWW,()'#$LIIa^^\x91\x8f\x8f\x00\x00\x00\x00\x00\x00ZWXZWXZWX\x87\x85\x86\x9e\x9d\x9d\xe3\xe3\xe3hefa^^[\zwx\xa7\xa6\xa6\x9a\x98\x98uss>;<nlluss\x95\x93\x94\x98\x96\x96\xb3\xb2\xb2uss\x95\x93\x94\x98\x96\x96\xd6\xd5\xd5\x00\x00\x00\x00\x00\x00hefa^a^\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xd8\xaa\xfa\xb8d\xfa\xb2V\xfd\xe5\xc6\xfb\xc5\x7f\xfb\xcb\x8e\xfd\xe5\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xf2\xe3\xfe\xf2\xe3\xf8\x9e+\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xfd\xe5\xc6\xfd\xe9\xcf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xd8\xaa\xff\xf9\xf1\xfa\xb2V\xf8\x98\x1d\xfa\xb2V\xfd\xe5\xc6\xfa\xbdn\xfb\xcd\x92\xfd\xe2\xbf\xfe\xf2\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xf2\xe3\xfc\xd8\xaa\xfb\xca\x8b\xfa\xb5\\xf8\xa49\xf8\x9b%\xf8\x9f-\xf9\xabH\xf8\x98\x1d\xfd\xe5\xc6\xfd\xeb\xd4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xf9\xf1\xfc\xd5\xa3\xfb\xc3|\xfb\xcb\x8e\xf8\x98\x1d\xf8\x98\x1d\xf9\xa59\xfc\xd2\x9c\xfe\xf2\xe3\xfa\xc1y\xfb\xcd\x92\xfd\xdf\xb8\xfe\xec\xd4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xec\xd4\xfd\xdf\xb8\xfc\xd2\x9c\xfb\xc6\x83\xff\xf9\xf1\xfc\xd2\x9c\xf9\xa59\xf8\x9e+\xfa\xb9f\xf9\xabH\xf8\x98\x1d\xff\xf9\xf1\xfe\xef\xdb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xcb\x8e\xfa\xc2{\xfd\xe5\xc6\xf9\xa59\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf9\xabH\xfc\xd2\x9c\xfe\xec\xd4\xfa\xb5\\xf9\xb3Z\xfb\xc7\x84\xfc\xd8\xaa\xfd\xe5\xc6\xfd\xeb\xd4\xfe\xf2\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xf9\xf1\xfe\xef\xdb\xfd\xe9\xcf\xfc\xda\xae\xfb\xcb\x8e\xf9\xb5_\xfa\xb6`\xfe\xec\xd4\xfc\xd2\x9c\xfa\xb8d\xf8\x98\x1d\xf8\x98\x1d\xf8\x9e+\xfc\xd8\xaa\xfe\xf2\xe3\xf8\x98\x1d\xfa\xb2V\xfb\xca\x8a\xff\xf9\xf1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\xe5\xc6\xfb\xc5\x7f\xfa\xbbj\xfb\xcb\x8e\xf8\x9e+\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x9e+\xfa\xb2V\xfb\xcb\x8e\xfc\xd8\xaa\xfd\xe5\xc6\xfe\xf2\xe3\xf9\xaeN\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf9\xb0R\xff\xf9\xf1\xfd\xe5\xc6\xfd\xdf\xb8\xfb\xcb\x8e\xfa\xb8d\xf8\x9e+\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xfb\xbfr\xfe\xf2\xe3\xfb\xcd\x92\xfc\xd2\x9c\xf8\x98\x1d\xfd\xe5\xc6\xfb\xcb\x8e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xcb\x8e\xfb\xcb\x8e\xff\xf9\xf1\xfb\xcb\x8e\xf8\x9e+\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xfb\xbfr\xfd\xe5\xc6\xfb\xcb\x8e\xfc\xd8\xaa\xfb\xce\x95\xf9\xa59\xfb\xbfr\xfa\xbeq\xfd\xe5\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xf9\xf1\xfd\xe2\xbf\xfb\xcb\x8e\xfa\xb8c\xfd\xdf\xb8\xfa\xb8d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf9\xabH\xfc\xd2\x9c\xfe\xf2\xe3\xfb\xcb\x8e\xfc\xd2\x9c\xfd\xe5\xc6\x00\x00\x00\xfa\xbbj\xfc\xd2\x9c\xfa\xbcm\xfb\xbfr\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\xdf\xb8\xfb\xcb\x8e\xfa\xbah\xf9\xb3Y\xfd\xe5\xc6\xfb\xcb\x8e\xfa\xb8d\xf9\xabH\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf8\x98\x1d\xf9\xa59\xfa\xb2V\xfb\xcb\x8e\xfd\xdf\xb8\xff\xf9\xf1\xfb\xc3|\xfb\xcf\x97\xfd\xe2\xbf\xfe\xf2\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xd2\x9c\xfc\xd2\x9c\xfc\xd2\x9c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

@averagesecurityguy
Copy link
Author

The script above simply unzips the data stored in the file. What you do with the data after that depends on what type of data it is. I have no idea what that data is so there is no way for me to help you.

@Mortadha92
Copy link

Mortadha92 commented Nov 2, 2020 via email

@Kungergely
Copy link

Kungergely commented Nov 2, 2020

@Mortadha92 Well then you can use your CMAP table to do character substitution I suppose. The values inside beginbfrange denote substitution ranges i.e. all the characters within that range are substituted for another (Unicode) character. E.g. the characters \x000f are substituted for \x002C "," (a comma), \x000c for \x0029 ")" (right parenthesis) and so on. You can read more about the workings of the whole thing e.g. here: https://blog.idrsolutions.com/2012/05/understanding-the-pdf-file-format-embedded-cmap-tables/

@averagesecurityguy
Copy link
Author

Unfortunately no.

@Kungergely
Copy link

@mikodham BTW pasting binary code in here like that is completely useless (the comment interface of GitHub is NOT binary safe!). It's impossible to reconstruct the original data stream that you had in your PDF file from what you've posted. This applies to @vipercommand as well BTW.

@LazyBoy95
Copy link

I tried to use it and print out as UTF-8 to txt.
Turns out couple of streams were empty/missing.

@BYugandhar
Copy link

My pdf has structure having the data as follows

20 0 obj
<</Filter/FlateDecode/Length 299>>stream
H‰\‘ËjÃ0�E÷úŠY&‹ ?ã�Œ!Í�¼èƒ:ý G�§‚Z�²²ðßW�…��àpï�I3üÐ��­�ð�;Š��ôJK‹Óx·�áŠ7¥Yœ€TÂ=ˆN1t†q�nçÉáÐè~dU�üÓ‹“³3¬ör¼âšñw+Ñ}ƒÕס]�oïÆüà€ÚA�u
�{èµ3oÝ€À)¶i¤×•›7>óç¸Ì�!!ŽÃcÄ(q2�@Ûé�²*ò«†êìWÍPË�zœ†Øµ�ß�%{êíQ”DõBqB”¥�Åñ‰h›“–eA;.”æ�Qº'g¾�Î] c ’¨Ø�:�zhg¢Ý�¨HˆÊ(P¸½ 5‹Œè%�”Ó·�ï>èç Ïµ¾q4,êØÒ+¥ñ9O3�ð©e³_�� xÃ�Í
endstream
endobj

i want decode it ,i had tried using above script it didnt worked for me can any suggest me any solution to decode using Python/Java

@Kungergely
Copy link

Kungergely commented May 11, 2023

@BYugandhar My comment above still applies: the binary data you've posted here is completely useless. If the script above doesn't work then the content is most likely encrypted. Look for an /Encrypt XX Y R tag in the PDF. The XX Y part refers to the object that holds the encryption directory (i.e. the encryption metadata). This object (referenced as XX Y obj) will contain lines such as /U and /O, these are the (hashed) user and owner passwords which you need to crack. Good luck with them, just get a program that does the brute-force cracking for you instead.

@BYugandhar
Copy link

BYugandhar commented May 12, 2023

@Kungergely Thanks for the answer. This PDF is not encrypted ,even i have checked for /U ,/O ,/UE and /UE also not found.Could please suggest me Is there way to decode back to original Text.(In the PDF text content is "Hello" that i need to retrieve back from above stream)

@GitHubRulesOK
Copy link

GitHubRulesOK commented Jun 18, 2023

@BYugandhar
You have posted text

20 0 obj
<</Filter/FlateDecode/Length 299>>stream
H‰\‘ËjÃ0�E÷úŠY&‹ ?ã�Œ!Í�¼èƒ:ý G�

HOWEVER in the PDF those are not text (in common with every computer file on this planet that is a BINARY bitSTREAM.
When we open such a file in a TEXT editor we see the Binary BYTES as characters like ABCDEFG or ������� when not A-Z or other normal ASCII text characters.
When you cut and paste such ANSI text say from MS Notepad to MS Notepad in ANSI mode, most of the characters (EXCEPT [None]) will actually be uncorrupted and thus potentially usable. Here is an ANSI view of such text NOTE there are very few ����
image

HOWEVER when paste or save as plain text that one missing [none] is critical and all saves are usually corrupted, such that Fonts and Images that depend on that nul and void character fail back to blank leaving pages bare of data. sadly the Equation for PDF is 255/256 NEQ <00>

What can often happen in such cases, MAY BE the decode fails and I often see returns, Rubbish In, Rubbish Out

20 0 obj
<</Length 0>>
stream

endstream
endobj

image

@nerun
Copy link

nerun commented Mar 24, 2024

Add import sys and replace "some_doc.pdf" by sys.argv[1] for a generic pdf flat decode command line tool.

#!/usr/bin/env python3
# This script is designed to do one thing and one thing only. It will find each
# of the FlateDecode streams in a PDF document using a regular expression,
# unzip them, and print out the unzipped data. You can do the same in any
# programming language you choose.
#
# This is NOT a generic PDF decoder, if you need a generic PDF decoder, please
# take a look at pdf-parser by Didier Stevens, which is included in Kali linux.
# https://tools.kali.org/forensics/pdf-parser.
#
# Any requests to decode a PDF will be ignored.
import re
import zlib
import sys

pdf = open(sys.argv[1], "rb").read()
stream = re.compile(rb'.*?FlateDecode.*?stream(.*?)endstream', re.S)

for s in stream.findall(pdf):
    s = s.strip(b'\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