DEF CON 22 CTF Quals: 3dttt

Unlike most of the challenges in DC22 quals, this one required no binary exploitation, no reversing, just writing a little code. You needed to play 3-D Tic Tac Toe, and you needed to play fast. Unfortunately, I didn’t record the sessions, so I don’t have the example output.

Basically, you just received an ASCII representation of each of the 3 boards making up the 3d-tic-tac-toe environment, and were prompted to provide x,y,z coordinates for your next move. However, you had only a very short period of time (fractions of a second) to send your move, so playing by hand was impossible. The winner of each board was the player with the most rows won, and it did go to the full 27 moves each time. Also, it’s important to note that the player always goes first, and that you have to win 50 rounds in order to receive the flag.

I chose this basic algorithm:

On the first move, play in the very center of the boards (1,1,1)

For each subsequent move, consider each available position.

Consider each row that the position sits on.

If the row has both X and O on it, award 0 – the row is a lost cause.

If playing would win that row for us, or block a win for our opponent (they have 2/3), award 3 points.

If we already have something on that row, or they already have something on that row, award 1 point. We’re either making progress or blocking.

Otherwise, no points.

Sum the row points for each position, and play in the highest scoring position.

I had no idea if this algorithm would work, but it was actually successful resulting in the flag on the first try.