安恒杯2019年5月月赛

西湖论剑线下赛复现专场

easycrack

简单的替换,也可以在strcmp下断,调试得到flag。

Testre2

得到flag之后才知道是RC5,逆的过程中只觉得中间加密部分的逻辑和骑驴师傅出的考核题差不多2333

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
int main()
{
unsigned int key[26]={0};
key[0]=0xb7e15163;
for(int i=1;i<26;i++)
key[i]=key[i-1]-0x61c88647;
unsigned int a1[4]={0x243F6A88,0x85A308D3,0x452821E6,0x38D01377};
unsigned int v5=0,v6=0,v7=0;
for(int i=0;i<78;i++)
{
key[i%26]=( (key[i%26]+v5+v6)<<(3&0x1f) ) | ( (key[i%26]+v5+v6)>>(32-(3&0x1f)) );
v5=key[i%26];
a1[i&3]=( (a1[i&3]+v5+v6)<<((v5+v6)&0x1f) ) | ( (a1[i&3]+v5+v6)>>(32-((v5+v6)&0x1f)) );
v6=a1[i&3];
}
unsigned int final[4]={0xF4A956BF,0xBA568F3D,0xD73A7F7C,0x817F532B};
//unsigned int final[4]={0X6EA91D54,0X7C5153BA,0X339AABC3,0X6672A3A9};
unsigned int input[4]={0x30303030,0x30303030,0x30303030,0x30303030};

//encrypt
/*for(int j=0;j<=3;j+=2)
{
v6=key[0]+input[j];
v7=key[1]+input[j+1];
for(int k=0;k<=11;++k)
{
v6=(( (v6^v7 )<<(v7&0x1f) ) | ( (v6^v7 )>>(32-(v7&0x1f)) ) )+key[2*j];
v7=(( (v6^v7 )<<(v6&0x1f) ) | ( (v6^v7 )>>(32-(v6&0x1f)) ) )+key[2*j+1];
}
input[j]=v6;
input[j+1]=v7;
}*/

//decrypt
for(int j=0;j<=3;j+=2)
{
v6=final[j];
v7=final[j+1];
for(int k=0;k<=11;++k)
{
v7=( ( ( ((v7-key[2*j+1])>>(v6&0x1f) ) ) |( (v7-key[2*j+1])<< (32-(v6&0x1f) ) ) ) )^v6;
v6=( ( ( ((v6-key[2*j])>>(v7&0x1f) ) ) |( (v6-key[2*j])<< (32-(v7&0x1f) ) ) ) )^v7;
}
input[j]=v6-key[0];
input[j+1]=v7-key[1];
}
unsigned char flag[16]={0};
memcpy(flag,input,16);
for(int i=0;i<16;i++)
printf("%c",flag[i]);
}

需要注意的就是运算符的优先级,我记得不是很清楚,所以只能为了运算顺序正确,使用了大量括号orz

文章目录
  1. 1. easycrack
  2. 2. Testre2
|