Categories
Challenge

DEF CON 32 – Cloud Village CTF – Azure’s Goblins 0 – 3

Based off the descriptions, these four challenges looked like fun little incrementally more difficult crypto challenges.

Since this was a cloud CTF and I was doing my utmost to avoid any cloud content, I thought that was an excellent option and downloaded the first (or 0th, I suppose) one to take a peek.

Azure’s Goblins 0 Intro Card

The intro card for this (and subsequent) Azure’s Goblins challenges seems to contain hints about the type of keys and encryption you’re supposed to crack, which would have come in handy had I any intention whatsoever of actually doing that.

The downloaded zip file contains the dockerfile and dependencies for each of the Azure’s Goblins challenges, and so I opened up the first one and took a look.

Screenshot of Directory

Note: try.py is my script, not a part of the challenge.

Clearly, you’re meant to build and run each dockerfile and then interact with the service to crack something and do something to get the flag (or something).

However, I didn’t have docker installed and didn’t particularly want to go through the process of doing so, so I went to look at __init__.py

Screenshot of __init__.py

Normally I’d include the text rather than a screenshot, but there’s always a chance the CTF folks don’t want that posted, so a screenshot of my terminal you get.

You’ll notice that, while ugly, this looks very familiar to anyone with any incident response or SOC experience. That’s because it’s obfuscated in the same way a lot of malicious payload is: By base64-encoding, reversing, and compressing about a jillion times, with an added eval() and uncompress/unreverse/unbase64 at each level.

I’m well-familiar with that special brand of annoyance, so I wrote an ugly script that took that base64 string, decoded it, and then pulled the base64 string out of that decoded string (using hard-coded boundaries, of course), and repeated that until it failed gracefully detected there was no longer any base64 to decode, at which point you can reasonably assume you’ve reached the code, or some fresh hell of obfuscation.

try.py

import zlib
import base64

def do_thing(one):
	print("ONE\n", one)
	print("ONE STRIPPED\n", one[11:-3][::-1])
	two = zlib.decompress(base64.b64decode(one[11:-3][::-1]));
	print("TWO\n", two)
	do_thing(two)
print()
thing= b'==AM2UuWf4///+M/16G/3EOv/PLuqnrfGkDGjNodaPYJ87MQ+/GQE0PZJ1an3vmJC+5wT2IIBW3VaBA4C6rxhsP6/Jz24CDWl5lTC3q/7Rh/ZurEPGoo2TkRvNJ7PamO8kJXxcEZ9f932Dd8o0sJZwxuq2VjPnB7eU3SW1CvN2GlDLrQY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+0lW2XbJQLVVMxd//ZmZlJzYxMPMmogZHsi3n9TRSoTxyW7lNwJe'
one =zlib.decompress(base64.b64decode(thing[::-1]));
do_thing(one)

You’ll notice that I am consistent between filenames, variable names, and function names, in that I use only the least-descriptive possible names. In my defence, the name of the game in a CTF is speed, and I promise I document better professionally or when I’m not racing.

Anyways, you pop the initial base64 in that one variable and run the script, and Bob’s your uncle. Here’s (some of) the output from that script:

Screenshot of Output

If you squint, you’ll see that the command finishes after gracefully detecting that it has reached non-base64 content, and in the second-last printed variable (not including the mess of errors), you’ll see the source code, and the flag stored in a variable as

FLAGGob1insAndKMSIsn0tRe4l21e68b

Wrap that up into the flag format and there you have it.

Note: I think this is actually the flag for the 4th (or 3rd, depending on where you start counting) challenge in this set, because I didn’t bother re-entering the base64 from the 0th (1st) – You’ll see why in a sec

Now I moved on to the next three goblin challenges. Lo and behold, they all wanted me to do something silly like run a docker container. Thankfully, the exact same script worked for each (after replacing the base64), and I was spared from having to install docker for another day. This also got us a ton of points for very little effort, though one of the organizers assured me the next day that this was a foreseen and legitimate way of solving the challenge. Pah!

Here’s a quick capture of the intro cards for each, and the output of my script:

Leave a Reply