CTF Extract encrypted jpeg from pdf using script peepdf (CTF)?

Good day,
There is a pdf file which contains the flag in the picture, there is even a write-up

As example the sounds of peepdf(tried binwalk but nothing came of it)
after performing the 5 steps:
/Type /Embeddedfile
/Filter /FlateDecode
/Params << /Size 108542
/Checksum VY���)$�]���t� >>
/Subtype /text/plain >>
stream


then I as soon as did not try to decode(all my attempts I see no reason to describe) this string but to no avail. Found using 'search txt' hidden text files in the objects 1 and 78 but to extract(tried online resources and peepdf) and did not work. If there are people who understand better than me I'd be happy to hear what I'm doing wrong :)

PS: I'm not good at the structure of pdf files.
April 7th 20 at 11:00
1 answer
April 7th 20 at 11:02
Solution
For 77 obj.
Code
import re
import zlib
import base64

with open('epreuve_BAC_2004.pdf', 'rb') as input_file, open('picture.jpg', 'wb') as output_file:
 encoded_text = input_file.read()
 match = re.search(b'77 0 obj.*?stream(.*?)endstream', encoded_text, re.S)
 stream = match.group(1).strip(b'\n')
 decompressed = zlib.decompress(stream)
 output_file.write(base64.b64decode(decompressed))

The result
5e41791a55597031859073.jpeg
Thank you very much! Killed a few hours but the emphasis is not understand how to get it from there, I realized built-in methods have peepdf not to extract? So how to write a script for me was not the obvious solution) - Rasheed.Pollich commented on April 7th 20 at 11:05
@Rasheed.Pollich, I don't know what peepdf, but if the article is written you will most likely something was done wrong.
In the instructions it's pretty clearly written and can handle even built-in modules. - adrien.Dicki commented on April 7th 20 at 11:08

Find more questions by tags Python