ruby challenge 12

dealing evil

Challenge 12 is titled dealing evil and it looks like that is our only hint. Well, that and the picture; a once again fuzzy image of five piles of cards being dealt out. Zooming in on the image will reveal sort of a fish scale pattern, no matter what I tried I could not tease anything other then smaller, tinted, versions of the same image. It turns out that the tint pattern on the image is just a diversion, the next hint is the image name: evil1.jpg. Like the piles of cards there are five files, evil2.jpg says ‘not .jpg — .gfx’, evil3.jpg says ‘no more evil …’, and evil4.jpg is not actually a jpeg open it in a hex editor (or a text editor) and it will tell you ‘Bert is evil! go back!’, and of course the fifth file is evil2.gfx.

Evil2.gfx file is not a gfx file. Open the file up in a hex editor and look at the header, it looks like several image file headers have been shuffled together, as have the rest of the image files. We know that we want five piles, so seperating them should be fairly simple.

here is the code;

evil, eb ='./evil2.gfx', 'r'), []
evil.each_byte{|x| eb.concat([x.chr])}
for e in (0..4):
  es = []
  e.step(eb.length, 5){|x| es.concat([eb[x]])}
  if es[0,3].join == "GIF"     
    post = ".gif"
  elsif es[1,3].join == "PNG" 
    post = ".png"
    post = ".jpg"
  evl ='./evil' + e.to_s + post, 'w')

Half of the code just determines what each file type is by reading the headers. I tried using Rmagick and the img.format method, but it conked out when reading evil3.png which is apparently damaged.

Next: python challenge 13; call him


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s