Pinguw
Articles10
Tags3
Categories2

Categories

Archive

RCTF2024部分题解

RCTF2024部分题解

四道re(那个misc就是纯逆向)

rctf

Reverse

2048

审计源码,看出每轮将获得分数为输入的sorce,上限为当前得分,初次上限为1w,那么每次成功分数翻倍的情况下用不了几次即可到达100w分:

2048

RCTF{you_are_2048_master}

bloker_vm

在每种case中下断点,可得到加密逻辑,

但是没看出反调试的影响在哪里。

vm

解密代码:

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
53
54
55
56
57
58
59
60
61
62
#include <cstdio>

int rc4(unsigned char* input, int input_len, char* key, int key_len)
{
int result; // eax
char v5; // [esp+D3h] [ebp-155h]
char v6; // [esp+D3h] [ebp-155h]
int v7; // [esp+F4h] [ebp-134h]
int i; // [esp+100h] [ebp-128h]
int j; // [esp+100h] [ebp-128h]
int k; // [esp+100h] [ebp-128h]
unsigned __int8 v11; // [esp+10Fh] [ebp-119h]
unsigned __int8 v12; // [esp+11Bh] [ebp-10Dh]
char v13[260]; // [esp+124h] [ebp-104h]
for(i = 0; i < 256; ++i)
v13[i] = i;
v7 = 0;
for(j = 0; j < 256; ++j)
{
v7 = ((unsigned __int8)key[j % key_len] + v7 + (unsigned __int8)v13[j]) % 256;
v5 = v13[j];
v13[j] = v13[v7];
v13[v7] = v5;
}
v12 = 0;
v11 = 0;
for(k = 0; ; ++k)
{
result = k;
if(k >= input_len)
break;
v11 += v13[++v12];
v6 = v13[v12];
v13[v12] = v13[v11];
v13[v11] = v6;
input[k] ^= v13[((unsigned __int8)v13[v11] + (unsigned __int8)v13[v12]) % 256];
}
return result;
}

int main()
{
unsigned char enc_flag[] =
{
0x80, 0x05, 0xE3, 0x2F, 0x18, 0x2F, 0xC5, 0x8C, 0x25, 0x70,
0xBC, 0x05, 0x1C, 0x4F, 0xF2, 0x02, 0xE5, 0x3E, 0x02, 0x2F,
0xE5, 0x11, 0xA3, 0xC0
};
char key[] = "thisisyoursecretkey";


rc4(enc_flag, 24, key, 18);

for(int i = 0; i < 24; i++)
{
enc_flag[i] = (enc_flag[i] << 2) & 63 | (enc_flag[i] >> 6);
enc_flag[i] ^= 0x7D;
printf("%c", enc_flag[i]);
}

return 0;
}

RCTF{a_baby_debug_bloker}

PPTT

看到mian函数中先将输入写成二叉树层序存储,然后先序和中序遍历,并对中序的结果进行交换混淆,

tree mix

v23,v24,v25存储的即为中序遍历的结果,z3解方程可得

z3

z3解方程+还原:

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
from Crypto.Util.number import *
from z3 import *

v17 = BitVec('v17', 64)
v18 = BitVec('v18', 64)
v19 = BitVec('v19', 64)
v20 = BitVec('v20', 64)
v23 = BitVec('v23', 64)
v24 = BitVec('v24', 64)
v25 = BitVec('v25', 64)

s = Solver()

s.add(v20 == v24 & v23)
s.add(v19 == (v24 & v23 | v25 & v23) + 65670)
s.add(v18 == (v25 & v23 ^ v25 & v24) - 1131796)
s.add(v17 == v24 & v23 ^ v25 & v23)
# s.add((v24 & v23 & (~(v24 | v23) | v25 & v23 | v25 & v24 & ~v18) | v25 & v24 & v18) != 0x67437616)
s.add((v23 ^ (v20 & ~v18 | v20 & ~v19 | v17 & v19 | v25 & v23 & ~v18)) == 0x400010000622000)
s.add((v18 ^ (v19 - v20)) == 0x2100A0203EFBB8B)
s.add((v17 ^ v19 ^ v20) == 0x4083102108E)
s.add((v19 ^ v17) - v18 == 0x1551566F3C6485ED)
s.add((v18 ^ v19 ^ v25 & v24) == 0x40836ECAB9A)
s.add((v17 ^ v20) - v18 == 0x3E51566F3C718563)
s.add(v23 - v24 == 0x1AEFF6FDFC121BF1)
s.add((v25 + v24 + v23) % 10 == 8)

while s.check() == sat:
model = s.model()
tmp = long_to_bytes(model[v25].as_long())
s.add(v25 != model[v25])

if len(str(tmp)) != 11 or tmp.find(b'C') == -1 or tmp.find(b'F') == -1 or tmp.find(b'}') == -1:
continue

mid1 = long_to_bytes(model[v23].as_long())
mid2 = long_to_bytes(model[v24].as_long())
mid3 = long_to_bytes(model[v25].as_long())
# print(mid1[::-1])
# print(mid2[::-1])
# print(mid3[::-1])

str1 = '0123456789abcdefghijklmn'
str2 = 'gefckamb52hl48i0n1j396d7'

mid = mid1[::-1]+mid2[::-1]+mid3[::-1]
flag = ''
for i in range(24):
flag += chr(mid[str2.find(str1[i])])

print(flag)

一个一个验证所有解

trytry flag

RCTF{sjknwemqspsdaqtyua}

Misc

s1ayth3sp1re

这应该是个re题。

把文件拖进jadx查找判断胜利的条件:

3000

直接看加密逻辑,简单异或:

enc

写解密代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
arr1 = [164, 158, 95, 107, 4, 215, 108, 115, 5, 8, 25, 57, 41, 236, 231, 17, 85]
arr2 = [246, 221, 11, 45, 127, 148, 45, 36, 70, 73, 78, 8, 98, 141, 140, 112, 40]

enc1 = [0] * len(arr1)
for i in range(len(arr1)):
enc1[i] = arr1[i] ^ arr2[i]
print(chr(enc1[i]), end = '')

print()

arr3 = [100, 174, 197, 56]
arr4 = [2, 0xC2, 164, 95]

enc2 = [0] * len(arr3)
for i in range(len(arr3)):
enc2[i] = arr3[i] ^ arr4[i]
print(chr(enc2[i]), end = '')
cawcaw1kaka

RCTF{CAWCAW1Kaka}

Author:Pinguw
Link:https://pinguw.github.io/2024/05/29/%E6%AF%94%E8%B5%9BWP/RCTF2024/
看完了吗,再去看看博主的其他文章叭:)