2 minutes
FDCA Xmas 2024 Day 7 - Sukkerkolde Cyberkrigere
Challenge Description
Danish (original)
Cyber-Operations Command Centeret er efter flere dages hårdt arbejde gået fuldstændig sukkerkold, så kokken Andrimner finder dokumentet med æbleskivernes lokation frem fra skuffen - men hov! Jætterne har tilsyneladende krypteret teksten!? Heldigvis finder Andrimner krypteringsrunerne, som skurkene i deres hast ud af køkkenets server har tabt i filsystemet.
Kan du dekryptere æbleskiver.runes?
English (from chatgpt)
The Cyber-Operations Command Center has gone completely sugar-sweet after several days of hard work, so the chef Andrimner pulls the document with the location of the æbleskivers from the drawer – but wait! It seems the giants have encrypted the text!? Fortunately, Andrimner finds the encryption runes that the villains hastily dropped in the file system as they rushed out of the kitchen’s server.
Can you decrypt æbleskiver.runes?
File
We are also given the following file:
Solution
Unzipping the file we can see that we have a dll file and a file with base64:
$ unzip JettEncrypt.dll_aebleskiver.runes.zip
Archive: JettEncrypt.dll_aebleskiver.runes.zip
inflating: æbleskiver.runes
inflating: JettEncrypt.dll
$ cat æbleskiver.runes
uru8voW7zNK0zpi4zY3SltOSqsqQzLOXzc6yggAAAAA=
Using AvaloniaILSpy on the dll we can see how the flag was encrypted:
// JettEncrypt.Encryptor
using System;
using System.Text;
public static string encrypt(string ymir)
{
byte[] array = new byte[32];
Array.Copy(Encoding.UTF8.GetBytes(ymir), array, ymir.Length);
byte[] array2 = new byte[32];
for (int i = 0; i < 8; i++)
{
byte[] array3 = new byte[4];
Array.Copy(array, i * 4, array3, 0, 4);
Array.Copy(BitConverter.GetBytes(-BitConverter.ToInt32(array3, 0)), 0, array2, i * 4, 4);
}
return Convert.ToBase64String(array2);
}
So I made the following c-code to reverse it:
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
union Section {
int32_t i;
char s[5];
};
int main(int argc, char *argv[]) {
union Section sections[8];
for (size_t k = 0; k < 8; k++) {
strncpy(sections[k].s, argv[1] + k*4, 4);
sections[k].i = -sections[k].i;
printf("%s", sections[k].s);
}
return 0;
}
And ran it as follows:
$ gcc solve.c -o solve
$ ./solve $(base64 -d æbleskiver.runes)
FDCA{D3-L1gG3r-i-mU5p3Lh31M}