Diving into the Portable Document Format
Toulouse Hacking Convention 2017 Guillaume Endignoux @gendignoux Friday 3rd March, 2017
1 / 34
Diving into the Portable Document Format Toulouse Hacking Convention - - PowerPoint PPT Presentation
Diving into the Portable Document Format Toulouse Hacking Convention 2017 Guillaume Endignoux @gendignoux Friday 3 rd March, 2017 1 / 34 Portable Document Format ? PDF timeline: 1991-1993: inception and first release by Adobe 1 2008: ISO
1 / 34
1https://acrobat.adobe.com/us/en/why-adobe/about-adobe-pdf.html 2 / 34
1https://acrobat.adobe.com/us/en/why-adobe/about-adobe-pdf.html 2 / 34
2http://www.cvedetails.com 3https://github.com/ANSSI-FR/caradoc 4http://spw16.langsec.org/ 3 / 34
4 / 34
5 / 34
6 / 34
%PDF-1.7 1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj 2 0 obj << /Type /Pages /Count 1 /Kids [3 0 R] >> endobj xref 0 6 0000000000 65536 f 0000000009 00000 n 0000000060 00000 n ... trailer << /Size 6 /Root 1 0 R >> startxref 428 %%EOF
7 / 34
Header Objects ... Table + trailer #1 End-of-file #1 Objects ... Table + trailer #2 End-of-file #2
%PDF-1.7 xref 0 6 0000000000 65536 f 0000000009 00000 n 0000000060 00000 n ... trailer << /Size 6 /Root 1 0 R >> startxref 428 %%EOF xref 0 3 0000000002 65536 f 0000000567 00001 n 0000000000 00001 f 6 1 0000001234 00000 n trailer << /Size 7 /Root 1 1 R /Prev 428 >> startxref 1347 %%EOF
Original file Incremental update
8 / 34
9 / 34
10 / 34
11 / 34
12 / 34
13 / 34
13 / 34
Catalog Root of the page tree Page 3 Node Page 4 Page 1 Page 2
14 / 34
Catalog Outline root Chapter Chapter Chapter Section Section Section
15 / 34
Catalog Outline root Chapter Chapter Chapter Section Section Section
16 / 34
17 / 34
18 / 34
18 / 34
19 / 34
20 / 34
5https://github.com/gendx/pdf-corpus/tree/master/corpus/contentstream/graphic-stack 21 / 34
https://github.com/ANSSI-FR/caradoc/blob/master/test_files/negative/outlines/cycle.pdf
https://github.com/ANSSI-FR/caradoc/blob/master/test_files/negative/polymorph/polymorph.pdf
https://www.alchemistowl.org/pocorgtfo/pocorgtfo13.pdf 22 / 34
23 / 34
24 / 34
24 / 34
24 / 34
Po A Ko B Pu O C P, ID Ku D U E Ka,b a, b A, C, E ≈ MD5 B ≈ RC4 D ≈ MD5+RC4 password checksum (in file) salt (in file)
25 / 34
26 / 34
6https://www.adobe.com/devnet/pdf/pdf_reference.html 27 / 34
PDF strict parser relaxed parser
graph of references extraction of specific objects type checking list of types graph checking graphics instructions future work no error detected normalization
6https://www.adobe.com/devnet/pdf/pdf_reference.html 27 / 34
7https://github.com/ANSSI-FR/caradoc/tree/master/doc/grammar 28 / 34
7https://github.com/ANSSI-FR/caradoc/tree/master/doc/grammar 28 / 34
29 / 34
30 / 34
30 / 34
normalized 9829 files type checking type checked 2105 files type error 1575 files graph checking instructions checking no error found 1891 files
31 / 34
32 / 34
8https://developers.google.com/protocol-buffers/. 33 / 34
34 / 34