We are given the hint “Solveable in <5m. Much attack very wamerican-small.” The file begins with “VimCrypt~01!” and research on vim’s encryption method reveals that this means the file has been encrypted with the Unix crypt function. We apt-get install wamerican-small
, strip the vimcrypt header, convert it to a C array, and write a quick solver by using vim’s source code:
#include <stdio.h>
#include <string.h>
unsigned char decrypted[402] = {0};
unsigned char encrypted[402] = {
0x09, 0x06, 0x7E, 0x78, 0x8B, 0x07, 0xE5, 0x5E, 0x75, 0x3D, 0x5A, 0x66,
0x49, 0x2B, 0x7D, 0x17, 0x5E, 0x96, 0xF0, 0xC0, 0x07, 0x30, 0x24, 0xC3,
0xDF, 0x06, 0xA9, 0xEF, 0xDC, 0x27, 0x9E, 0x60, 0x88, 0xF9, 0x89, 0x10,
0x6C, 0x9D, 0x68, 0xBE, 0x36, 0xB3, 0x7E, 0x1B, 0xEA, 0xED, 0xA7, 0x90,
0x2B, 0x92, 0xE5, 0xED, 0xE3, 0xC9, 0x05, 0xC1, 0x16, 0xC9, 0xFE, 0x71,
0x4C, 0x6A, 0x16, 0x61, 0x72, 0xFB, 0x1E, 0x97, 0xC1, 0x79, 0x32, 0xC5,
0x96, 0x23, 0x3B, 0x94, 0x39, 0x27, 0x58, 0x70, 0x0E, 0x4D, 0x76, 0xC9,
0x38, 0xE0, 0x64, 0x43, 0xB7, 0xC4, 0x2B, 0xAA, 0xA9, 0x89, 0xAA, 0xE6,
0x68, 0x80, 0xCF, 0xF8, 0xB0, 0xEE, 0x08, 0xBD, 0x5B, 0x7A, 0xE1, 0x7D,
0x22, 0x6D, 0x44, 0x34, 0xC7, 0x80, 0x28, 0x03, 0x12, 0x8B, 0x3A, 0x28,
0xCC, 0x21, 0xEF, 0x04, 0x9C, 0xF2, 0xAF, 0xF0, 0x71, 0x86, 0x5E, 0xAF,
0x4E, 0x3B, 0xB9, 0x75, 0x90, 0x86, 0xEF, 0x10, 0x42, 0xC7, 0xD9, 0x51,
0x82, 0xE8, 0xFC, 0x36, 0x07, 0xE3, 0x5F, 0xDE, 0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35, 0xEB,
0x5A, 0xD0, 0xDE, 0x32, 0x46, 0x44, 0x93, 0x85, 0x1E, 0x4C, 0xA3, 0x2C,
0xD2, 0xF2, 0xC4, 0x31, 0x69, 0x71, 0x4D, 0x7C, 0xA5, 0x0F, 0xB3, 0xCB,
0xDF, 0xE7, 0xB1, 0xBF, 0xCD, 0x70, 0xCE, 0xB6, 0x8A, 0x76, 0x78, 0x1A,
0xEE, 0x64, 0x6E, 0x06, 0x2C, 0xE6, 0x84, 0x5B, 0x84, 0x7E, 0x19, 0xA9,
0xD5, 0x0A, 0x80, 0x57, 0x8D, 0x32, 0xF6, 0x29, 0xC0, 0x77, 0x4B, 0x22,
0xAA, 0x70, 0xE6, 0x22, 0x89, 0x39
};
int main(int argc, char *argv[])
{
char input[64] = {0};
/* in vim74/src/misc2.c */
make_crc_tab();
/* read input lines until EOF */
while(fgets(input, 64, stdin))
{
int b = 0;
input[63] = ' ';
/* remove n */
input[strlen(input) - 1] = ' ';
/* decrypt using functions from vim74/src/misc2.c */
crypt_init_keys(input);
memcpy(decrypted, encrypted, 402);
crypt_decode(decrypted, 402);
/* print out the decryption */
for(b = 0; b < 402; b++)
{
printf("%c", decrypted[b]);
}
printf("n");
/* clear input buffer */
memset(input, 0, 64);
}
return 0;
}
doge-solve.c
Now, a simple compile and run!
$ gcc -o doge-solve doge-solve.c $ ./doge-solve < /usr/share/dict/american-english-small | strings -n 30 The key is: ShibeSuchDictionaryAttacksWow wow very much ctf most key such flag so much shellcode wow
Flag: ShibeSuchDictionaryAttacksWow