Sunday, June 9, 2013

Breaking Pyramix

This is a recount of the method I used to break Ben0xA's pyramix encoding at BSidesDetroit over the course of about 3 hours. It was challenging, frustrating, and immensely fun. Ben has since released the source of the pyramix cipher.

The challenge:

****INTERCEPTED TRANSMISSION****
Be warned those who read this n0te
This challenge will cause you pain.
As you journey through the pyramix
And your strength begins to wane.
Men have gone crazy,
Women have gone mad.
They ramble about dancing
And monkey's dressed in plaid.
But do not lose hope
With this puzzle of the kings
As you drink all the booze
And hack all the things.

338339866833833938873389679838367336688868876868966686756877866687886587378333338734837333873333337373398

****END TRANSMISSION****

Note the underlined text. 

I figured this would be important but wasn't sure how. The underlined letters spell 'Ben0xAstyl'.

We knew that this was loosely based on trifid. Understanding how trifid works is critical.

Looking at the ciphertext I could see that the letters look like they could fit in groups of three.

We also were given this picture:


I was confused for a long time as it looks like the Y axis says 0 to 6 (7 rows) when there are only 6. But this is the structure you use to decode by hand.

So this is what we have to work with given the trifid cipher component of the challenge:

33833986683383393887338967983836733
66888688768689666867568778666878865
87378333338734837333873333337373398

There are no 7's, 8's, or 9's on that key, so we need to transpose.

subtracting 2 from everything gives:

11611764461161171665116745761614511
44666466546467444645346556444656643
65156111116512615111651111115151176

This was still no good and much time was spent trying to figure out where the 7's would go and how you know what side to use. 

In order to decode we need to transpose the given text -3 to get:

00500653350050060554005634650503400
33555355435356333534235445333545532
54045000005401504000540000004040065

Now we can see where the 0's may come in handy. In the end I found that a zero on the bottom will mean that you use the left side, a zero on the top means you start from the right.

Decoding this gets you:

FEVST7VHITVEVZF7ETRKDEV6IN7RITOFLGB

Not exactly what we're looking for but this is where the underlined letters in the challenge come in. What you need to do is create a new alphabet to decode with.

BEN0XASTYLCDFGHIJKMOPQRUVWZ123456789

Now replace the code in the pyramid with this new alphabet to get this:



Now when you decode the numbers with this alphabet you will get this:

00500653350050060554005634650503400
33555355435356333534235445333545532
54045000005401504000540000004040065

AXQMOSQUITOXQWASXQTHEXQFIRSTXQCURSE

Removing the XQ characters gives you the flag.

Thanks to Ben0xA for a really great crypto challenge.