HACKvent 2020 - Day 2

01-01-2021 - 1 minute, 16 seconds - CTF

Challenge - Chinese Animals

The challenge description of day 2 read:

I've received this note from a friend, who is a Chinese CTF player:


Unfortunately, Google Translate wasn’t of much help. I suspect the data has somehow been messed up while transmitting it. Sadly, I can’t ask my friend about more details. The Great Chinese Firewall is thwarting our attempts to reach each other, and there’s no way I’m going to install WeChat on my phone.

Failed translation

"I suspect the data has somehow been messed up while transmitting it." sounded like an encoding issues to us. So we tried try a bunch, because who knows what encoding was used.

Well, actually we could have guessed the encoding. Obviously the destination encoding was to be something ASCII compatible, typically for the western hemisphere. The source encoding must have been some wide character encoding then, otherwise there wouldn't be many issues.

But we didn't, so we wrote more code than necessary:

static void Main()
    Console.InputEncoding = Encoding.Unicode;
    Console.OutputEncoding = Encoding.Unicode;

    Console.WriteLine("Input string:");
    var origString = Console.ReadLine();

    PrintStringFromEncodingInAllEncodings(origString, Encoding.UTF8);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.ASCII);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.BigEndianUnicode);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.Default);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.Latin1);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.UTF32);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.UTF7);
    PrintStringFromEncodingInAllEncodings(origString, Encoding.Unicode);


static void PrintStringFromEncodingInAllEncodings(string s, Encoding encoding)
    Span<byte> bytes = encoding.GetBytes(s);
    Console.WriteLine($"From {encoding.EncodingName}");

static void PrintBytesInAllEncodings(Span<byte> bytes)
    PrintBytesInGivenEncoding(bytes, Encoding.ASCII);
    PrintBytesInGivenEncoding(bytes, Encoding.UTF8);
    PrintBytesInGivenEncoding(bytes, Encoding.BigEndianUnicode);
    PrintBytesInGivenEncoding(bytes, Encoding.Default);
    PrintBytesInGivenEncoding(bytes, Encoding.Latin1);
    PrintBytesInGivenEncoding(bytes, Encoding.UTF32);
    PrintBytesInGivenEncoding(bytes, Encoding.UTF7);
    PrintBytesInGivenEncoding(bytes, Encoding.Unicode);

static void PrintBytesInGivenEncoding(Span<byte> bytes, Encoding encoding)

In hindsight, no surprise, the source encoding was UTF-16 BE. Converting correctly yielded HV20{small-elegant-butterfly-loves-grass-mud-horse}.

Failed translation

Next Post Previous Post