Google CTF - Anonymous Exchange Writeup

I've bought some bitcoins with my credit cards, and some of them attracted attention, but I don't know which ones. Could you find out? Challenge running at

Let's take a look:

$ nc 1337
Hey. Could you tell me if my cards ccard0x1 through ccard0x40 have attracted the wrong
type of attention? Flagged cards are displayed in their dumps, and their encryption is
deterministic. I seem to have the wrong encoding on my terminal, so I'll need help
there. I'll patch you into a management interface in a few seconds.

Welcome to our telnet dogecoin exchange!.
We've currently frozen most of the operations pending an investigation into potential
credit card fraud with law enforcement.
 - NEWACC to create an account.
 - NEWCARD to create a test credit card.
 - ASSOC <cardx> <accounty> to associate cardx to accounty.
 - BACKUP to generate a anonymized encrypted jsonified maybe-emojified backup.

The first thing to do is take a look at the BACKUP function. Here's an example account record:

  "account": "d82b2fb9eae6c10b",
  "cards": [
      "card": "b698929890dce9c6"
      "card": "85ff9e8504f55324"

Without using any of the other commands, we can investigate the database. There are about 300 accounts and 500 cards, the exact number changes each time, as does the associations between accounts and cards. We see accounts with 0, 1, 2 or 3 associated cards. And we see cards that have 1, 2, or 3 associated accounts. After playing around further we can verify that associations are indeed restricted to these values. We are allowed to perform associations with the target cards and test accounts. Additionally, we get cut off after 55 seconds, which limits the number of operations we can perform.

Given the category of the challenge is Misc rather than Crypto, it is unlikely we will need to exploit a weakness in the encryption, beyond the fact we are told it is deterministic. The determinism means that if a card appears twice in the database, we know it will be represented by the same string.

The challenge is still running, so I'd encourage you to fire up netcat and have a stab at a solution before reading on!

Writeup and Solution

Favicon Added

A favicon has now been added, remarkably hassle free with the 'Real Favicon Generator'

MathJax Support

MathJax has now been installed which allows standard $\LaTeX$ both inline and as equations:

$$ |\langle \mathbf{u}, \mathbf{v} \rangle|^2 \leq \langle \mathbf{u},\mathbf{u}\rangle \cdot \langle \mathbf{v},\mathbf{v}\rangle $$

(The ever userful Cauchy-Schwarz inequality for inner products)

Calloc and Thread Safety

During my undergrad, I took a module on High Performance Computing which was taught in C and covered the usual suspects: MPI, OpenMP, CUDA etc. For each assignment, students uploaded their source code which was then automatically tested before being inspected by hand. The content was relatively straightforward, however when the 3rd assignment was returned to us, a number of students had been docked 25% of the mark with the comment:

calloc is NOT guaranteed to be thread safe.

Additionally the lecturer provided demonstration code to 'prove' the function wasn't thread safe on university machines. As students from the Mathematics Institute, we unfamiliar with the intricacies of the various standards, but equally malcontent to accept the lecturer at his word.


Syntax Highlighting

highlight.js is now providing syntax highlighting.

Here is some inline code printf("Hello, World!"); inside a line of text. And now for a block of code:

import antigravity
s = "Python syntax highlighting"

HTTPS Enabled

Lets Encrypt certificate installed and HTTPS access enabled!


Website updated and PGP key uploaded. A Let's Encrypt Certificate is in the works in order to enable HTTPS.

Pro Forma

Hello, World!