GCHQ Challenge Solution Explained 107
First time accepted submitter DrDevil writes "The British spy agency GCHQ recently published a puzzle at canyoucrackit.co.uk (as featured on Slashdot), now just a few days later an academic at the University of Greenwich in England has posted a full video explanation of the puzzle. The puzzle has three stages and is not at all simple — likely to challenge even the best computer science graduates."
Opaque (Score:4, Interesting)
I didn't give the challenge a serious go, but stage 1 just seems convoluted - why is it the mark of a good code cracker to recognise x86 bytecode?
Re:Opaque (Score:5, Funny)
Because terrorists are yet to discover x64
Re: (Score:2)
Google? (Score:2)
Re:Opaque (Score:5, Insightful)
The ability to recognise codes is precisely what they were testing.
If they had used a week cryptography code everyone would have cracked it, if they had used a strong code no one could (at least no one who didn't already work for their competition).
Utilizing an unexpected but extremely common code seems to be a nice solution.
Re:Opaque (Score:4, Interesting)
Not really.
You can make a simple cipher that is obfuscated in such a way that many people will not get it.
Heck a simply letter substitution ciper used on a dead language will pretty much cull the number of people trying to crack it by a significant amount. I completely fooled my CS instructor by doing just that. Aramaic phrase that had a simple letter substitution applied and a xor of a passphrase that was 1/10th the length of the cipher.
Mine was un-cracked for a full semester with him, his undergrads and all the CS students crakcing at it. Nowhere in the challenge did he say we HAD to use english as the content of the message.
Re: (Score:3, Interesting)
Let's assume for the sake of this discussion that you are a USian.
As a result of political infighting you have heads of state that are reviled in a vitriolic manner by about half the population.
Lets take a list of your heads of state:
Nixon (out due to Watergate)
Ford (ok, but reviled for Nixon pardon)
Carter (amiable bloke, but seemed to let America go to sleep on his watch)
Reagan (surprisingly effective, considering he was slowly losing his marbles)
H.W.Bush (had the bad luck to say "No new taxes" when ambush
Re: (Score:2)
In the UK, Queen Lizzie enjoys the support of a large majority of the population
She is kind of easy to support, she does sweet FA and she costs us less than we give to most foreign countries in aid.
Obama (has the bad luck to be black, leading to morons disputing his legitimacy to be President)
Nice.
Re: (Score:2)
There is a group, Republic [republic.org.uk], trying to make the UK a republic. I considered joining around the time of Prince Whatsit's wedding.
Economically, it would be nice if we didn't have to pay for the royal family. Politically, it would be nice if we could elect a head of state. Culturally, it would be nice to look round our castles and palaces, and have the art and so on in a national museum.
But, there are much, much bigger economic, political and cultural problems. I gave some extra money to Liberty [liberty-hu...hts.org.uk] instead.
Re: (Score:2)
I share your allergy, but I also have a more serious allergy. I am no person's "subject". I am a free man. No matter how the Brits argue the matter, no matter all the amendments etc to UK constitution, Brits remain subjects of some old woman in a castle. The only way that I would ever bow to the old girl, is if she first bowed to me. Figurehead or not, that "subject" thing would rub me raw, really, really fast.
I'm anti-monarchist, but I still prefer the Queen as head of state over dangerous war-mongering retards like Ronald Reagan or George W Bush
Re:Opaque (Score:5, Interesting)
It looked interesting, but I lost interest when I saw the salary -- slightly less than what I have already, working for a different bit of government. And GCHQ is in Cheltenham.
But have you visited the UK? I live here, so it's what I'm used to, but when visiting a couple of cities in the US recently I felt more "watched" and regulated. There were many signs with lists of local laws, with violations incurring big fines. There were *more* public (government/city/whatever) CCTV cameras. (I don't know about private ones, in shops and so on -- they didn't catch my eye.) The government buildings were built like fortresses, and I had my ID scanned and bag x-rayed when visiting museums. When I tried to leave, a government employee handled my genitals.
I don't want an argument about which country is better -- they both need improvements in this respect. But I'd like to know how you felt watched (or similar) when you visited the UK.
Re: (Score:2)
It looked interesting, but I lost interest when I saw the salary
No offence, but why not just piss off and work in the City inventing ever more esoteric and unauditable financial instruments, if you're so fucking clever and money-oriented?
Re: (Score:2)
It looked interesting, but I lost interest when I saw the salary
No offence, but why not just piss off and work in the City inventing ever more esoteric and unauditable financial instruments, if you're so fucking clever and money-oriented?
With an attitude like that, we'd probably get along pretty well :).
My comment is too brief. I live (and want to continue to live) in inner London. That's more important than the salary. But GCHQ's £24k is still low, especially as the changes to pensions are going to affect net pay (~£500 less, I think) and pay increases are currently on hold in the public sector.
I already work for the government, earning £27k (I think), only in science rather than spying/hacking/security. Comparable jo
Re: (Score:2)
I finished stage 1 and 2, and decided it wasn't worth the time finishing it, since they wouldn't hire me anyways. :) That, and I think I'm allergic to the UK. Having cameras all over the place, watching my every move, gives me the creeps. I'm ok with the occasional stalker, but these aren't even people that decided they were madly in love with me, and want to kill me. I'd always feel like I'd be hearing a voice over a hidden speaker saying "Citizen, you have violated citizens code XYZ. Please remain where you are. You will be transported for re-education."
Unless you're living somewhere carefree and beautiful like Somalia, you really are blind to your surroundings. if you think the UK is egregiously bad in terms of privacy.
Oh, and go fuck yourself.
Re:Opaque (Score:5, Informative)
Well, "DEADBEEF" is a bit of a giveaway [wikipedia.org].
Re: (Score:2)
Re: (Score:2)
I would have expected deadbeef to indicate another platform.
Re:Opaque (Score:5, Informative)
Recognizing unknown architecture binaries is an important skill to have when reverse engineering, especially for embedded systems. Very often you'll get a firmware file and you have to figure out what it is. Each architecture has its peculiarities, so it doesn't take long to get a feeling for what their opcodes look like. For example, 32-bit ARM code sticks out like a sore thumb (no pun intended :) due to the condition code field, which means that every 32-bit word almost always starts with 0xEx (and whether that's the first or last byte in the word tells you the endianness). Variable length architectures like x86 look very different from RISC ISAs with a fixed instruction length like PowerPC.
Re: (Score:2)
Well... I do know someone who is capable of staring at an unknown, undocumented binary blob for a new/proprietary architecture and working out enough of the ISA to write a fairly comprehensive disassembler and then an emulator. Just by staring at the hex and making educated guesses as to what each opcode means, which he later refines as he makes sense of the program. How he can do that boggles the mind, but he can (I've seen him do it at least three times already).
I don't know if the intelligence agencies h
Re: (Score:2)
Re: (Score:2)
The mark of a good code cracker is to be able to look at a bunch of numbers and/or letters and recognize patterns. This one was x86 byte code, which is, IMHO, a nice break from english language letter frequencies.
Re: (Score:2)
Re: (Score:1)
I wondered that, myself. I doubt I would have recognized it.
But just on a lark, I put the bytes into a file, and hadded it to the Unix "file" command.
It reports that it is a "DOS executable (COM)".
Not a great challenge (Score:5, Interesting)
My opinion, as someone who has both solved and organized several challenges of this sort, is that the challenge is neither hard (at least by the standards of the ones I've dealt with) nor well designed. In fact, it kind of degenerates: it starts out OK but the ending is terrible.
Stage 1 is interesting: it combines recognizing executable code (the first thing I thought when I stared at that hex dump is "this looks like x86 code", but being able to recognize binary architectures is a valuable skill) combined with some steganography (fishing out the rest of the required data from the PNG. Fair enough, and OK for a first round.
Stage 2 starts out well: virtual machines are used for obfuscation and make fun challenges. However, the execution is backwards. Being given VM bytecode and a specificiation to implement a VM isn't a hacking or reverse engineering challenge; it's just work ("go implement this for me"). A much better challenge would be to be given either the spec or (preferably) code that implements it, and then have to reverse engineer the bytecode itself to solve the puzzle. That involves writing a custom disassembler, which is a much more interesting task.
Stage 3 is a clusterfuck. It's just an executable that checks for a few constants in a file and then builds a URL out of the rest of it. There's a hash (old-school DES crypt() salted password) that the input has to match, but even though it's crackable using a dictionary, you don't even have to do that because the URL includes the hash (which is in the executable), not the plaintext! The rest of the URL isn't checked, and it's basically a guessing game where you have to fish out constants from previous levels. It's just a glorified way of saying "okay, now take a wild guess as to what numbers to stick in the URL". It's not realistic in the slightest.
Anyone interested in a "better stage 2" might want to check out a level [marcansoft.com] that I put together for the Hack-It competition at the 18th Euskal Encounter (2010). Your goal is to figure out the 64-bit input key that works (if you don't know what "works" means, compile and run the code and it should be obvious). The full set of challenges can be found here: 2010 [marcansoft.com] 2011 [marcansoft.com] (unfortunately, the website / problem statements are in Spanish, but I'm sure you can work it out with a bit of copy/pasting into Google Translate - if there's enough interest I'll translate them to English).
Re: (Score:1)
"combined with some steganography"
Calling data contained in the comment field of a png steganography seems rather overly generous.
Re: (Score:2)
"combined with some steganography"
Calling data contained in the comment field of a png steganography seems rather overly generous.
He didn't say that it was GOOD stenography...
Re: (Score:2)
If you want a steganography challenge (with a twist), try this [marcansoft.com], from this year's Hack-It ;)
Stage 2 not trivial (Score:2)
Re: (Score:2)
It took me about 30 minutes using Python (why would you use JavaScript? The mind boggles.), but yes, I agree, the specification wasn't terribly clear especially if you've never worked with segmented memory. The jump instructions also are confusingly described as jumping to r2:r1 in the mod=1 version (it should be imm:r1). Personally, I quite dislike this memory model (and x86 in general), but I've had the "pleasure" of working with an embedded system integrating a 80186 core so I had a fairly good idea of w
Re: (Score:2)
Well, if JavaScript is the language that you're most familiar and comfortable with, and you're happy using a browser or you have a commandline JS interpreter handy, then by all means. I personally prefer Python of course, but everyone has a different taste in programming languages. However, what makes no sense is writing it in JS just because the original file ends in .js. That little fact should have exactly zero influence on the choice of language that you do pick to implement this in.
Considering the pare
Re: (Score:2)
I used JavaScript as I assumed that that was the expected target language. Most of the time went into understanding the semantics of the jmp(e) instruction and for that I needed some tracing. Then I went to C++ (my prefered language for the matter) when I hit an infinite loop and did not see any output, because I ran the script inside Firefox.
It was also not my objection to write the shortest possible code. The more I write programs (including dirty and quick), I come to the conviction that my code should l
Re: (Score:2)
You're right. The problem isn't the lack of "self.ip += 1" inside the condition (that would do nothing, as the branch target specifies the new value for self.ip anyway); the problem is that when a conditional branch with mod == 1 isn't taken, the second byte is executed as a new instruction instead of skipped. I guess this variant isn't used in the provided bytecode so it didn't break things
Re: segmented memory (Score:3)
The Z80 is not a segmented memory model either; you might be thinking of some of the embedded versions such as the HD64180. It was the x86 architecture that was really afflicted with these segment registers.
Re:Not a great challenge (Score:4, Interesting)
Your experience has you quite biased towards these sorts of things. You only watched this video, I can tell, and didn't pay attention.
In the disassembly for stage 3, the messages "loading stage x license key", when they clearly said you were on "stage 2 of 3", were good hints. The unused firmware bits were fairly obvious because they had the right size and served no other purpose, and the unused bytes from stage 1 were obvious after you get your mind on the "unused bits from each stage" track.
And the VM part wasn't trivial. This guy did it in python, but it was intended to be done in javascript. The implementation doesn't really matter, but understanding the bit fiddling needed to implement it is a valuable skill. If you have the skills to disassemble, but not write anything more complicated than hello world, you're probably not useful to them. Not a difficult challenge, but one where you can easily make a mistake and grind your gears for hours. Remember the intent, to find viable candidates for cybersecurity who are interested in doing this sort of thing. Sometimes cyber security is boring but you do what's necessary to solve the problem.
And they never advertised it as a hack-it contest or programming challenge, just a puzzle. So it didn't have to even be fun or entertaining to do - just something to solve. Note as well, they didn't ask for contact information or offer a resume upload - just "Please consider applying with us". So it doesn't even get you an interview.
If you spent the time and are curious enough, you're probably someone they want. If not, you're probably not.
Re: (Score:2, Interesting)
I solved stage 2 entirely on my own and reverse engineered enough of stage 3 to realize exactly what it was doing. I had glossed over stage 1 (after I realized it was x86 I just googled it and saw that others had solved it already) so I didn't immediately know about the unused instructions, but I did correctly guess that the "firmware" stuff from stage 2 was used for the seco
Re: (Score:3, Insightful)
Why crack it when you can bypass it? (Score:4, Funny)
http://www.canyoucrackit.co.uk/soyoudidit.asp [canyoucrackit.co.uk]
Re: (Score:2)
If by win, you mean stand a fair chance of getting to the interview stage, probably. I suspect lacking a good answer to "How did you solve the problem?" would be a bit of an issue, until the whole thing was blown wide open anyway...
Re: (Score:2)
If by win, you mean stand a fair chance of getting to the interview stage, probably. I suspect lacking a good answer to "How did you solve the problem?" would be a bit of an issue, until the whole thing was blown wide open anyway...
"Cheating is often more efficient." 7 of 9
I'm no expert, but isn't showing initiative a desirable quality in candidates?
Re: (Score:1)
Re: (Score:2)
Debatable; keep in mind they're recruiting for cryptanalysts and information/network security people, not spies in the traditional sense. They want strong problem solving abilities; so short-cutting to the solution I would imagine won't discount someone, but they would also need to show the core skills expected of the job...
Re: (Score:1)
"I crowdsourced it."
Re: (Score:1)
No, because your IP address wasn't registered jumping through all the hoops.
I've been having a go... (Score:4, Interesting)
I'm aware that the solution has been leaking out onto the net...
Starting later than most, in spare time, I've trudged through stages One and Two... I've been playing with the stage-3 executable and have disassembled it... though there remains further tedious trudging for me to demonstrate by sensible sequential steps how to go about solving stage-3.
I'm finding it difficult to convince myself that it's worth the effort... I'm sure I can fathom any remaining steps - based upon the fact that there has been little about stages one and two that was actually 'challenging'. It seems silly to plod onwards without 'cheating'.
I was interested principally to try and find out what sort of skills GCHQ actually want... I never assumed I'd be (one of the) first to solve it. The experience has left me wondering what sort of job this sort of tom-foolery would suit one for. Sure debugging and OS-level skills can be valuable - but the challenge is most time consuming as one is required to guess the objective - identifying the intentions of the challenge setter rather than to address real-world issues.
Re: (Score:3)
Stage 3 isn't worth the effort. It's very little hacking/reverse engineering and mostly silly guesswork with no sensible sequence of steps to get there. Spoiler ahead:
The primary challenge is to guess what bits of stage 1 and stage 2 to stick into a URL (or a file which the exe then formats into a URL). You have to go back to stages 1 and 2 and fish out the most likely candidates for "3 32-bit numbers that do nothing and stick out like a sore thumb".
Re: (Score:1)
It's absolutely not worth it to get through to the end.
Salary [gchq-careers.co.uk] from their job posting:
£25,446 (GC10) £31,152 (GC9)
Why on earth would a top notch graduate apply for this position when s/he could make 4x that in the private sector? As the professor in the third video said: that's rather a disappointing end.
Re: (Score:2)
I'd like to know where I could earn £120,000 as a starting salary when I graduate.
Re: (Score:2)
Top grade banks. Look to get hired as a quant, not a techie. Starting salary in the US was $160K flat, plus bonus when my college friends were doing it a few years back. Things have cooled off a bit since then, but it's still possible -- especially with a finished masters or half-finished doctorate.
Re: (Score:2)
What are the hours and stress like in that job though?
Re: (Score:1)
Re: (Score:2)
In at 6:30, out by 7, with monitoring of risk jobs overnight if need be.
Re: (Score:2)
So pretty horrible then, just about enough time to work, eat and sleep.
There's always a catch isn't there?
Re: (Score:2)
I didn't mind it too much...I managed to find a wife, start a family, have a hobby shop and write a book while I was in the system.
The key is to not become addicted to the fat paycheck. It's hard for some people to do, which is why they stay in and subject themselves to the stress for years on end. I saw far too many people with empty million dollar Manhattan apartments to fall into that trap, so when the wife got a teaching job in another part of the country in my sixth year, I packed up and left. We bough
Re: (Score:3)
What are the hours and stress like in that job though?
Rhetorical, or not?
A couple of my friends (well, more friends-of-friends) from my year went on to do that. That was when I stopped seeing them. "Let's meet for drinks after work in central London!" They rarely turned up before 10pm, and even then sometimes went back to work after an hour or two. Got to get their bonus, you see.
One of my closer friends -- I lived with this guy for two years! -- is working for a hedge fund. £200k, I think, probably with a bonus. He was never particularly social, bu
Re: (Score:3, Informative)
Err ... no. There simply aren't quant jobs with grad starting salaries of that level, certainly not in London, and I would highly doubt you'd find that level in NY either. Salaries actually went up (and bonuses down in relative terms) after '08-09, but there's still no way you'll get a six-figure (GBP) base for a grad starting position.
Also, timing is pretty bad if you want to land a quant role right now. Front-office hiring patterns tend to be very cyclical and right now they're in a downswing with most ba
Re: (Score:3)
You might get £35k (basic) in IT in a bank in London, with anything up to 100% bonus. You get to help screw up the economy, too. Don't worry -- after 2-3 years you'll have lost your morals.
Or similar money (and bonus) working in IT for a software company writing code for banks.
I know someone who's making nearer (over?) £120k as a contractor for banks writing Android apps, but he spent a couple of years writing apps himself (earning a decent amount selling them) before he had the reputation to
I thought this was a crypto/cypher challange (Score:1)
I didn't realize that reversing IA-32 excutables was the modern meaning of cracking a code. I figured it would be difficult and possibly even rely on dictonary attack of a cryptographic hash, but IA-32 machine code? This sounds like they are more interested in recruiting people to analyze stuff like Stuxnet than to attract people with cryptography, information theory, and signals backgrounds. I don't claim to be crypto expert (I've took an abstract algebra class that is a requirement for all cryptography cl
Re: (Score:2)
I haven't looked at the video yet, because I still want to see how far I can get with just the spoilers in the comments.
Grr...now I'm mad I didn't recognize the byte swapped DEADBEEF.
Re: (Score:2)
Re:I thought this was a crypto/cypher challange (Score:5, Insightful)
For better or for worse, modern intelligence agencies are much more dependent on people who can RE software and develop exploits, than they are on pure cryptographers.
This is a consequence of the rolling disaster that is software security, combined with the fact that crypto folks have (mostly) gotten their act together.
Re:I thought this was a crypto/cypher challange (Score:4, Interesting)
Re: (Score:3)
This sounds like they are more interested in recruiting people to analyze stuff like Stuxnet
Yes, that's probably exactly what they're after.
Re: (Score:3)
If they're really looking for people who can do that, they should be looking at people who crack DRM. Oh, are most of the people like that keeping their heads down and unlikely to be considering government jobs? Gee golly, I can't imagine why...
perhaps they want to examine packet logs? (Score:5, Insightful)
This is an intelligence agency, and network intrusion programs pumping executable code in the attempt at smashing a stack and jumping execution are pretty common.
Perhaps they want people who can quickly spot x86 assembly payloads from raw packet traces as part of a counter aggression op?
If we assume that their network stack isn't riddled with exploitable stack variables or pointers, and that they successfully prevent the code from running, but log the unrequested network access and dump the binary packets to file for analysis, then having people that can "at a glance" determine what kind of data is in those dumps would be valuable.
Being able to determine what it actually is supposed to do even more so.
With the recent hysteria over scada system cyber attacks (I hate that phrase btw..),setting up a fake scada system as a honeypot and seeing what the cat drags in could also make use of this skillset.
So, the obvious questions:
Does the UK fear it has poorly secured scada systems, or does it fear network worm intrusion on some network segement, and if so, what segments or systems are those?
Re: (Score:1)
The details of the challenge are almost certainly irrelevant - anyone can apply for GCHQ jobs directly with them, without having to complete a challenge.
The more their name is banded around forums and sites like slashdot the better, as they'll get more people applying for their jobs, which can only be good for them.
Stopped at stage 3 (Score:2)
Stage 1 and 2 were really easy frankly. Especially stage 2 since aside from the small error (intentional or not) in the implementation document it was just some simple coding.
Stage 3 was where I stopped, not because I was daunted or otherwise unable but because I didn't have the tools available to screw around with the exe. It was also at that point that I learned they were too stupid to even put up a robots.txt file and thus were not an organization I had any interest in working for.
My solution with full writeup (Score:5, Informative)
I was going to hold this back until the competition was finished, but it seems the cat is out of the bag!
Here is my solution and a writeup of exactly how I got there.
http://www.craig-wood.com/nick/articles/how-i-solved-the-gchq-challenge/ [craig-wood.com]
Stage 2 VM in JavaScript (Score:2)
I spend about three hours writing (mostly debugging) a JavaScript implementation of the VM. (I did make a side step to C++ because at one point the JavaScript implementation seemed to run in an infinite loop.) I also discovered that the specification was not very clear and required some interpretation. So stating that stage 2 was the simplest step, and using some code that someone else developed, is not really honest. The biggest problem was with figuring out how the jmp instruction worked and the use of th
Thank you, participants... (Score:1)
...for helping GCHQ crack the "Modern Warfare 3" video game copy protection! Well done, everyone!
If you are interested in helping us get free premium television channels, cellular phone minutes, tickets to concerts, and more money from taxpayers, then join our team!
There was a really easy way to solve this. (Score:1)
Screen recorder (Score:1)
So what screen recorder software did the author use? It plays back nicely.
Re: (Score:1)
Fraps doesn't do Linux. Whatever was used here was on Linux. That's what I want it for as well.
Re: (Score:2)
If you look at the final video, you'll see that it's Linux running inside a VM, on Windows.
Re: (Score:2)
If you look at the final video, you'll see that it's Linux running inside a VM, on Windows.
Was it on the boss's machine?
Re:Screen recorder - here (Score:2, Interesting)
http://recordmydesktop.sourceforge.net/about.php
Re: (Score:1)
This is probably it. Thanks.
For something ontopic. What's all that stuff about morse code in the source then? Are they providing several challenges so they can recruit people of different skill levels and I indeed different areas of expertise? It would seem the logical thing to do. Maybe there is even another even harder challenge in there to get the really really clued up people? Maybe there's a code hidden In the white space of the source code? (Just throwing down the gauntlet and teasing people).
Re: (Score:1)
The screen recorder is Camtasia - Linux is running in a VM under Windows.
Re: (Score:1)
Thanks for that! It made for a very nice presentation.