WriteUp

下载题目附件,得到压缩包flag都是爱你的形状.zip,打开发现部分加密,无密码的密码.txt内容如下:

TZ1rbrkf3TUknVMjfmqNe0HgLEgq6LzkvTeDdb8j/928JL31YsPYKI9EvSTzmEWdjI4b2yPrc3RA8rYICWU8r1oc0cbfTsOX3a18XOJ3iAUAam15lUOZmqP6r7FRRGEMF9nnxVNU9pISsbkHCwxXLhAoiO8MORNSLLfYT6yKGFc=

MIICXQIBAAKBgQCqfQxeO7YCFgjIWTlaZlxRoDxb0Fw4GQLSadOpnkRNfstIJqz/
HFmKjqPkCLEH11Yt5SoTTVAR9v3jQUc8v0JF67mq169DAGx9JZwzvvsD9/n4RIOE
yKXaD7+5yfm2u4a/p7y7UJRZugVutgF/iElaiGxao9FDz+OIal4MCIHFywIDAQAB
AoGBAIjq1Dv5iDo0p+j+fujyu8FyBgdWVjlXHMUO6EWYLRJveaIALX7TrbVwyH4h
3MqHTVaebCQEOwGyckNH8YX/s6BT+jm8p8nA2v9cPpm/zlImgHnxhTIZ/DYkmC86
I1aDyLIA1/EZgNIBfzl0NVGrypaZsBOQX6uXZooVhLEYUOLBAkEA1ojOuAu9IX6y
2FzlOb2muUxwSoP0aBxaQSSEgy2STJ6v/nWJeUYjCWovLLLmkkNaJEFzrMkkIG+0
pp65s7i67QJBAMtw13+gYPq6RSZOffYpPMTfGjxixWrvSqZXP+1TtRx02rveUXge
QeKaGvtJCx9dqG4YtHSVgnKfhI9C7XyVFJcCQE0rTOCbKF8iCgcV80Z/17cTrdi/
+mxwtm50Sk49WEDDXB81/EtpVTUPwwRbHeFC5Ovht1BR0fLw+5Rrx/TD4EkCQH34
2Kfhokt+7fSjY+H6dPOfBnrf2ki19a58lkwZqir9vLfaGO5dJgTv0cdJ2oZIk1Ph
HlSWg5kAZ6/iDHY5Re8CQQCD4kAbV5N18L1pzYCJ2ep+dX7HtBFf7ubP0UqSHvA3
hYqUxkYgLLzGblVazjWr0b3EfHLZfJGxq8EU47utZdYt

MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqfQxeO7YCFgjIWTlaZlxRoDxb
0Fw4GQLSadOpnkRNfstIJqz/HFmKjqPkCLEH11Yt5SoTTVAR9v3jQUc8v0JF67mq
169DAGx9JZwzvvsD9/n4RIOEyKXaD7+5yfm2u4a/p7y7UJRZugVutgF/iElaiGxa
o9FDz+OIal4MCIHFywIDAQAB

emmm什么加密需要两种密钥呢

看到这么工整的Base64文本,那肯定是RSA的公私钥没跑了,题目提示其实不太对,因为RSA的加密和解密都只需要公私钥的其中一个就行,而解密则需要另一个,并不是两个都要。

那么直接打开国内权威的一个RSA加解密站点:在线RSA私钥加密解密、RSA private key encryption and decryption--查错网,用私钥解密试试,发现失败了,那再用公钥解密试试,还是失败了。。。可能是RSA版本或者某个内部数值不对的缘故...

试试看CaptfEncoder里的RSA工具,选择私钥解密,输入私钥和密文,发现解密成功,得到明文nynuctf

解压得到简单re.rar,再解压得到reverse.exe,试着打开看一下,发现打不开,可能是VC支持库的锅。

那只能静态分析了(懒得装支持库,因为理论上Win10上的支持库还是很全的),打开IDA,发现没啥弯弯绕绕的,就是调个函数然后按位置加上i值就得到加密后的文本,然后比对就完事,那么就看函数里是个啥算法了。

void *__cdecl sub_411AB0(char *a1, unsigned int a2, int *a3)
{
  int v4; // STE0_4
  int v5; // STE0_4
  int v6; // STE0_4
  int v7; // [esp+D4h] [ebp-38h]
  signed int i; // [esp+E0h] [ebp-2Ch]
  unsigned int v9; // [esp+ECh] [ebp-20h]
  int v10; // [esp+ECh] [ebp-20h]
  signed int v11; // [esp+ECh] [ebp-20h]
  void *Dst; // [esp+F8h] [ebp-14h]
  char *v13; // [esp+104h] [ebp-8h]

  if ( !a1 || !a2 )
    return 0;
  v9 = a2 / 3;
  if ( (signed int)(a2 / 3) % 3 )
    ++v9;
  v10 = 4 * v9;
  *a3 = v10;
  Dst = malloc(v10 + 1);
  if ( !Dst )
    return 0;
  j_memset(Dst, 0, v10 + 1);
  v13 = a1;
  v11 = a2;
  v7 = 0;
  while ( v11 > 0 )
  {
    byte_41A144[2] = 0;
    byte_41A144[1] = 0;
    byte_41A144[0] = 0;
    for ( i = 0; i < 3 && v11 >= 1; ++i )
    {
      byte_41A144[i] = *v13;
      --v11;
      ++v13;
    }
    if ( !i )
      break;
    switch ( i )
    {
      case 1:
        *((_BYTE *)Dst + v7) = aAbcdefghijklmn[(signed int)(unsigned __int8)byte_41A144[0] >> 2];
        v4 = v7 + 1;
        *((_BYTE *)Dst + v4++) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | 16 * (byte_41A144[0] & 3)];
        *((_BYTE *)Dst + v4++) = aAbcdefghijklmn[64];
        *((_BYTE *)Dst + v4) = aAbcdefghijklmn[64];
        v7 = v4 + 1;
        break;
      case 2:
        *((_BYTE *)Dst + v7) = aAbcdefghijklmn[(signed int)(unsigned __int8)byte_41A144[0] >> 2];
        v5 = v7 + 1;
        *((_BYTE *)Dst + v5++) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | 16 * (byte_41A144[0] & 3)];
        *((_BYTE *)Dst + v5++) = aAbcdefghijklmn[((byte_41A144[2] & 0xC0) >> 6) | 4 * (byte_41A144[1] & 0xF)];
        *((_BYTE *)Dst + v5) = aAbcdefghijklmn[64];
        v7 = v5 + 1;
        break;
      case 3:
        *((_BYTE *)Dst + v7) = aAbcdefghijklmn[(signed int)(unsigned __int8)byte_41A144[0] >> 2];
        v6 = v7 + 1;
        *((_BYTE *)Dst + v6++) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | 16 * (byte_41A144[0] & 3)];
        *((_BYTE *)Dst + v6++) = aAbcdefghijklmn[((byte_41A144[2] & 0xC0) >> 6) | 4 * (byte_41A144[1] & 0xF)];
        *((_BYTE *)Dst + v6) = aAbcdefghijklmn[byte_41A144[2] & 0x3F];
        v7 = v6 + 1;
        break;
    }
  }
  *((_BYTE *)Dst + v7) = 0;
  return Dst;
}

函数内容如上,一看有个基文本abcdefgh...,以及经典的三段式位移拼接,那不就是Base64嘛...

直接按位减i得到e2lfbDB2ZV95b3V9Base64一下得到flag。

flag

{i_l0ve_you}