首页
社区
课程
招聘
1
[原创]看雪CTF2018 第四题 流程 by 青蛙mage
发表于: 2018-6-24 02:52 3788

[原创]看雪CTF2018 第四题 流程 by 青蛙mage

2018-6-24 02:52
3788

第一步,信息收集

主流程:

sharp1:

没什么异常

可能使用了MIRACL大数库,以及很多字符串都描述了相近的信息可能性很大
本题带有混淆,IDA有点不灵光了

主流程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<br>
  unsigned int flag = 0;
  int main()
{   
    //不影响解题的解密() -> serial
    //不影响解题的解密() -> 看雪-京东 CTF 2018
    printf("*****看雪-京东 CTF 2018*****");
    printf("serial:");
    //堆检查()
    //不影响解题的解密() -> success
    //不影响解题的解密() -> error
    char ch[0x18]=0;
    char head[3]=0;
    scanf("%s",&ch);
    if(strlen(ch)>23) {       //最大23位
        printf("error");
        return 0;
    }
    cinstr(a,&ch[3]);
    sharp1(); //flag+1  关键点
    memcpy(head,ch,3);
    for(int i=0;i<3;i++)
    {
        if(!isdigit(head[i]))
        {   printf("error");
            return 0;
        }
    }
    sharp2(); //flag +1  关键点
    if(flag==2)
    {
      printf("success");
    }
    else{
        printf("error");
    }
    system("pause");
}

sharp1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
     void sharp1()
  {
      mirsys *mip(500, 16);   //初始化
      big a, b, c, d;
      //a=d**c mod b
      temp1 = 0x208CBB7CD6ECC64516D07D978F5F0681F534EAD235D5C49ADD72D2DB840D5304; //不要吐槽,省力
      temp2 = 0x7da39de66016477b1afc3dc8e309dc429b5de855f0d616d225b570b68b88a585;
      temp3 = 0x3e9;
      temp4;
      cinstr(a, ch[3]);
      cinstr(b, temp2);
      cinstr(c, temp3);
      if (mr_compare(a , b))
      {   
          return 0;
      }
      powmod(d, b, c, a);     //幂模
      ctostr(temp4, d);
      zero(a);                //释放
      zero(b);
      zero(c);
      zero(d);
      mirexit();             //结束
      if (strcmp(temp4, temp1))
      {
          flag += 1;
      }
}<br>

sharp2:小插曲:其实我这里没逆已经猜对答案了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<br>
  unsigned int flag = 0;
  int main()
{   
    //不影响解题的解密() -> serial
    //不影响解题的解密() -> 看雪-京东 CTF 2018
    printf("*****看雪-京东 CTF 2018*****");
    printf("serial:");
    //堆检查()
    //不影响解题的解密() -> success
    //不影响解题的解密() -> error
    char ch[0x18]=0;
    char head[3]=0;
    scanf("%s",&ch);
    if(strlen(ch)>23) {       //最大23位
        printf("error");
        return 0;
    }
    cinstr(a,&ch[3]);
    sharp1(); //flag+1  关键点
    memcpy(head,ch,3);
    for(int i=0;i<3;i++)
    {
        if(!isdigit(head[i]))
        {   printf("error");
            return 0;
        }
    }
    sharp2(); //flag +1  关键点
    if(flag==2)
    {
      printf("success");
    }
    else{
        printf("error");
    }
    system("pause");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
     void sharp1()
  {
      mirsys *mip(500, 16);   //初始化
      big a, b, c, d;
      //a=d**c mod b
      temp1 = 0x208CBB7CD6ECC64516D07D978F5F0681F534EAD235D5C49ADD72D2DB840D5304; //不要吐槽,省力
      temp2 = 0x7da39de66016477b1afc3dc8e309dc429b5de855f0d616d225b570b68b88a585;
      temp3 = 0x3e9;
      temp4;
      cinstr(a, ch[3]);
      cinstr(b, temp2);
      cinstr(c, temp3);
      if (mr_compare(a , b))
      {   
          return 0;
      }
      powmod(d, b, c, a);     //幂模
      ctostr(temp4, d);
      zero(a);                //释放
      zero(b);
      zero(c);
      zero(d);
      mirexit();             //结束
      if (strcmp(temp4, temp1))
      {
          flag += 1;
      }
}<br>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 void sharp2()
  {
      temp1 = 0x912CA2036A9A0656D17B6B552F157F8E;
      temp2 = "0001314000000000";      //噫,这个1314仿佛是在.....
      //影响解题的解密() -> pediy  //一个提示
      temp2[0] = head[0];
      temp2[1] = head[1];
      temp2[2] = head[2]+1;            //这也是一个提示
      aesroundkey(temp2)               //这里流程和置换表同AES加密中的roundkey环节  10轮 并输出最终密钥 此时有种不详的预感
      temp3 = "7065646979000000";
      temp4 = temp3 ^ temp2;
      aesroundkey(魔改)(temp4);    
      if (strcmp(temp4, temp2))
      {
          flag += 1;
      }
  }

第三部,解密

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 void sharp2()
  {
      temp1 = 0x912CA2036A9A0656D17B6B552F157F8E;
      temp2 = "0001314000000000";      //噫,这个1314仿佛是在.....
      //影响解题的解密() -> pediy  //一个提示
      temp2[0] = head[0];
      temp2[1] = head[1];
      temp2[2] = head[2]+1;            //这也是一个提示
      aesroundkey(temp2)               //这里流程和置换表同AES加密中的roundkey环节  10轮 并输出最终密钥 此时有种不详的预感
      temp3 = "7065646979000000";
      temp4 = temp3 ^ temp2;
      aesroundkey(魔改)(temp4);    
      if (strcmp(temp4, temp2))
      {
          flag += 1;
      }
  }
很明显密码,分为前三位和后X为  3+X  !> 23
X部分powmod:
        Y=0x208CBB7CD6ECC64516D07D978F5F0681F534EAD235D5C49ADD72D2DB840D5304

        P=0x7DA39DE66016477B1AFC3DC8E309DC429B5DE855F0D616D225B570B68B88A585
        G=输入
        X=3e9

先去复习数学..... 

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
免费 1
支持
分享
赞赏记录
参与人
雪币
留言
时间
PLEBFE
为你点赞~
2023-2-4 03:41
最新回复 (0)
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册