Author: Omar Ganiev (beched)
Decrypt this text
Flag is the key used to encrypt it.
Using xortool i have tried to analyse the file:
xortool decrypt.bin
We see that xortool is telling us that key length is 8, but also suggests that it can be 4*n. Let's try to decrypt:
xortool -l 32 -c ' ' decrypt.bin
Checking results:
cat xortool_out/*
Inside that pile of under-deciphered text we can see something familiar:
xortool --help
And now we have plaintext. Since the cipher is XOR, we can restore the key by XORing plaintext with ciphertext. So i wrote this tiny programm in C:
#include <stdio.h>
#include <stdlib.h>
void main(void){
//hex bytes of decode.bin
char encrypted[623]={0x40,0x56,0x45,0x46,0x5c,0x09,0x55,0x1f,0x16,0x4a,0x6f,0x45,0x19,0x72,0x17,0x42,0x09,0x5f,0x09,0x11,0x40,0x59,0x43,0x02,0x0b,0x11,0x16,0x5e,0x59,0x03,0x17,0x4e,0x57,0x4b,0x17,0x53,0x5d,0x07,0x55,0x48,0x15,0x5a,0x16,0x5f,0x33,0x13,0x17,0x1b,0x46,0x57,0x10,0x54,0x47,0x45,0x43,0x12,0x0c,0x54,0x45,0x5a,0x51,0x1f,0x17,0x5a,0x5d,0x57,0x50,0x46,0x5b,0x46,0x11,0x53,0x07,0x40,0x00,0x01,0x19,0x5c,0x59,0x16,0x05,0x5f,0x10,0x5f,0x40,0x16,0x0c,0x00,0x44,0x54,0x14,0x44,0x55,0x0a,0x17,0x55,0x50,0x58,0x45,0x41,0x1a,0x6c,0x19,0x11,0x4b,0x13,0x02,0x10,0x5c,0x40,0x44,0x16,0x12,0x58,0x00,0x11,0x5f,0x53,0x1a,0x46,0x4c,0x53,0x04,0x42,0x51,0x46,0x58,0x58,0x18,0x52,0x59,0x5d,0x44,0x0a,0x5c,0x55,0x01,0x56,0x45,0x0a,0x5f,0x13,0x5a,0x59,0x15,0x44,0x45,0x41,0x46,0x59,0x01,0x07,0x06,0x5d,0x00,0x11,0x57,0x0e,0x56,0x44,0x11,0x33,0x62,0x41,0x52,0x01,0x5c,0x0b,0x6c,0x13,0x45,0x1d,0x56,0x41,0x43,0x59,0x09,0x5c,0x4b,0x41,0x4d,0x16,0x38,0x4b,0x0c,0x4d,0x48,0x1c,0x5c,0x03,0x5b,0x46,0x65,0x19,0x6c,0x7d,0x63,0x32,0x70,0x7e,0x28,0x60,0x38,0x45,0x62,0x0f,0x51,0x5f,0x0a,0x55,0x0b,0x50,0x59,0x53,0x5d,0x3b,0x6e,0x7e,0x15,0x45,0x5d,0x09,0x59,0x45,0x02,0x33,0x17,0x12,0x1e,0x0a,0x15,0x1c,0x4b,0x58,0x00,0x1c,0x14,0x5f,0x52,0x58,0x01,0x44,0x0d,0x11,0x14,0x16,0x43,0x46,0x44,0x11,0x09,0x54,0x5a,0x01,0x43,0x5e,0x18,0x56,0x51,0x12,0x47,0x0e,0x5c,0x11,0x0d,0x56,0x1c,0x45,0x11,0x5a,0x59,0x42,0x03,0x57,0x00,0x43,0x1d,0x3c,0x43,0x46,0x49,0x52,0x49,0x1c,0x19,0x05,0x5f,0x57,0x4a,0x19,0x17,0x12,0x13,0x46,0x19,0x11,0x46,0x13,0x45,0x45,0x19,0x13,0x5a,0x59,0x15,0x44,0x45,0x41,0x5b,0x45,0x10,0x0f,0x06,0x5d,0x00,0x11,0x57,0x0e,0x56,0x44,0x18,0x11,0x58,0x5c,0x56,0x46,0x5a,0x59,0x07,0x41,0x45,0x0a,0x4b,0x13,0x5f,0x53,0x1e,0x10,0x06,0x5e,0x50,0x53,0x4a,0x6c,0x44,0x11,0x48,0x5c,0x18,0x4b,0x1a,0x5b,0x59,0x41,0x1a,0x59,0x56,0x1f,0x55,0x54,0x08,0x0e,0x56,0x57,0x19,0x13,0x17,0x16,0x0b,0x51,0x1d,0x58,0x59,0x43,0x0e,0x46,0x0f,0x54,0x1c,0x11,0x58,0x03,0x59,0x51,0x4c,0x51,0x17,0x46,0x5c,0x46,0x49,0x43,0x09,0x51,0x00,0x45,0x11,0x5a,0x59,0x42,0x03,0x57,0x00,0x43,0x1d,0x3c,0x43,0x46,0x49,0x49,0x49,0x1c,0x19,0x0e,0x52,0x4e,0x18,0x19,0x17,0x12,0x13,0x46,0x19,0x11,0x46,0x13,0x45,0x45,0x19,0x13,0x5e,0x58,0x16,0x45,0x11,0x11,0x5d,0x45,0x43,0x0e,0x01,0x49,0x48,0x54,0x5a,0x05,0x58,0x52,0x5d,0x5d,0x17,0x41,0x47,0x14,0x33,0x11,0x46,0x1e,0x07,0x49,0x14,0x1e,0x55,0x44,0x13,0x44,0x00,0x1c,0x57,0x5e,0x02,0x14,0x17,0x11,0x45,0x11,0x14,0x46,0x17,0x54,0x4a,0x4c,0x43,0x57,0x13,0x00,0x56,0x43,0x05,0x56,0x45,0x04,0x55,0x5f,0x17,0x46,0x09,0x43,0x16,0x58,0x56,0x5a,0x06,0x46,0x07,0x59,0x04,0x43,0x55,0x05,0x43,0x53,0x4a,0x4a,0x3d,0x12,0x13,0x4b,0x56,0x1d,0x4b,0x1e,0x07,0x17,0x4c,0x47,0x52,0x1b,0x16,0x42,0x0c,0x5f,0x40,0x57,0x01,0x0a,0x01,0x11,0x45,0x42,0x55,0x0b,0x52,0x16,0x59,0x4a,0x17,0x1f,0x51,0x46,0x5b,0x44,0x12,0x13,0x12,0x0c,0x55,0x5f,0x17,0x59,0x08,0x5c,0x1c,0x11,0x41,0x45,0x06,0x46,0x14,0x43,0x0c,0x5f,0x40,0x07,0x55,0x5a,0x5d,0x33,0x17,0x12,0x13,0x46,0x19,0x11,0x46,0x13,0x45,0x45,0x19,0x13,0x17,0x16,0x46,0x10,0x45,0x11,0x14,0x16,0x43,0x46,0x44,0x11,0x06,0x59,0x55,0x14,0x56,0x55,0x4c,0x5c,0x45,0x41,0x13,0x00,0x56,0x43,0x46,0x58,0x00,0x1c,0x4a,0x39,0x0a};
//var where key will be stored
char key[32];
//some text taken from "xortool --help" outpyt
char test[]="xortool.py\n\
A tool to do some xor analysis:\n\
- guess the key length (based on count of equal chars)\
- guess the key (base on knowledge of most frequent char)\
\
";
//xor encrypted and plain to get key and print it
for (int i = 0; i < 32; ++i)
{
key[i]=test[i]^encrypted[i];
printf("%c", key[i]);
}
//decrypt ciphertext and print it
printf("\n");
for (int i = 0; i < 623; ++i)
{
printf("%c", encrypted[i]^key[i%32]);
}
}
When we run it, we see deciphered text:
89723f91f3ee9376f0e146cfd1e14f76
We needed to find key, so let's submit it and get our 200 points :)