Python Challenge – level 12 solution

The picture file name is evil1.jpg.
It led me to try evil2.jpg.
The URL evil2.jpg exists and it says “not jpg but .gfx”
The URL http://www.pythonchallenge.com/pc/return/evil2.gfx exists. And we got the binary evil2.gfx
evil2.gfx is a mixed file from 5 picture files. This is solved by looking at the binary files with a hex editor.
The following code separated the file into their original format:

# file evil2.gfx is a combined file from 5
f = open('evil2.gfx','rb')
g = f.read()
f1 = open('evil2-1.jpg','ab')
f2 = open('evil2-2.jpg','ab')
f3 = open('evil2-3.jpg','ab')
f4 = open('evil2-4.jpg','ab')
f5 = open('evil2-5.jpg','ab')

for x in range(len(g)):
    if x % 5 == 0:
        f1.write(g[x])
    elif x % 5 == 1:
        f2.write(g[x])
    elif x % 5 == 2:
        f3.write(g[x])
    elif x % 5 == 3:
        f4.write(g[x])
    else:
        f5.write(g[x])
f.close()
f1.close()
f2.close()
f3.close()
f4.close()
f5.close()

Each of the created file gives a piece of the answer:
dis – pro – port – ional – ity

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s