Gl.ib.ly

(glibly); Just another techie blog.

Auto corrupting your PDF files

Posted by Tariq • Tuesday, June 30. 2009 • Category: Tidbits
A few weeks ago I came across a blog post which showed you how to corrupt your own pdf files. That post was in response to the interweb ate my homework post from Bruce Schneier.

Anyhows, Didier's method is fairly simple -- there are many other ways todo this like truncating the file or inserting some randomness using dd and /dev/urandom. So lets automate it.


He corrupts a reference to the Root object in the pdf file to throw pdf viewers off the scent. You can see this in a file like so:


xxd YOUR.pdf | grep -A2 Root
 


0000350: 666f 2031 3420 3020 5220 0d2f 526f 6f74 fo 14 0 R ./Root
0000360: 2031 3720 3020 5220 0d2f 5072 6576 2036 17 0 R ./Prev 6
0000370: 3634 3531 200d 2f49 445b 3c64 3234 3936 6451 ./ID[

* might not always work.

You can use sed to help you corrupt easily! Here we go:


sed s/\.\\/Root.../\.\\/Rootsie/g YOUR.pdf > YOUR_CORRUPT.PDF
 


Here we tell sed to find ./Root followed by three bytes. We replace this with ./Rootsie. If all goes well you should end up with a corrupt pdf and a file which has the following somewhere:


xxd  YOUR_CORRUPT.PDF | grep -A2 Root
 


0000350: 666f 2031 3420 3020 5220 2e2f 526f 6f74 fo 14 0 R ./Root
0000360: 7369 6520 3020 5220 0d2f 5072 6576 2036 sie 0 R ./Prev 6
0000370: 3634 3531 200d 2f49 445b 3c64 3234 3936 6451 ./ID[
Defined tags for this entry: , , , ,
Vote for articles fresher than 90 days!
Current karma: 5 of 5, 3 vote(s)
Bookmark Auto corrupting your PDF files  at del.icio.us Digg Auto corrupting your PDF files Bloglines Auto corrupting your PDF files Technorati Auto corrupting your PDF files Fark this: Auto corrupting your PDF files Bookmark Auto corrupting your PDF files  at YahooMyWeb Bookmark Auto corrupting your PDF files  at Furl.net Bookmark Auto corrupting your PDF files  at blogmarks Stumble It!

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as (Linear | Threaded)
  1. No comments

Add Comment


Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.