December 4
2011

Can you crack it? stage 2 solution in Haskell

Hacks Haskell

GCHQ recently opened a puzzle called ‘Can you crack it’, over at canyoucrackit.co.uk. The challenge is split into three stages, and here is my solution to Stage 2. The original task suggested the solution should be done with Javascript, however I decided to tackle this challenge with Haskell.

The challenge is to write a Virtual Machine to interpret a block of code given in the instructions – once the program is interpreted, the solution appears in the memory of the virtual computer. The code itself firstly decrypts a section of the memory; this decrypted block is itself a program which is then run by the Virtual Machine.

Solution: Download [tar.gz] [source code repo]

The program can be built using Haskell’s cabal command.

 

For those who are interested or want to have a go with hexdumps, here is the output of this program:

310433aa40028003520072017301b250
3014c001800010100000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
3200750c310833324002800352007201
7303b200c3b000301bc001ff00000000
00000000000000000000000000000000
00007510010000000000000000000000
cc000000000000000000000000000000
7d1f15604d4d527d0e276d106d5a0656
4714420eb6b2b2e6ebb4838ed7e5d4d9
c3f08095f182829abd95a48d9a2b3069
4a6965551c7b691c6e04743521262f60
034e371e335439e6bab4a2ada4c595c8
c1e48aece7928be881f0ad98a4d0c08d
ac2252657e272b5a12610a017a6b1d67
474554202f6461373533373066653135
63343134386264346365656338363166
62646161352e65786520485454502f31
2e300000000000000000000000000000
377a07111f1d682532771e62235b4755
53301142f6f1b1e6c3ccf8c5e4ccc0d3
85fd9ae3e681b5bbd7cd87a3d36b366f
6f66553016455e09745c3f292b663d0d
02302835150915ddecb8e2fbd8cbd8d1
8bd582d99af192abe8a6d6d08caad294
cf454667207d44146b456d5403176062
555a4a6661115768750562367d02104b
08224232bae2b9e2d6b9ffc3e98a8fc1
8fe1b8a496f18f81b18d89ccd4787661
723e372356737179637c081120697a14
6805211e322759b7cfabddd5cc9793f2
e7c0ebffe9a3bfa1ab8bbb9e9e8ca0c1
9b5a2f2f4e4e00000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000

The result (and the next stage) are hidden within this data.

Enjoy!

Leave a Reply