-
-
[原创]KCTF 2024 第七题 星际移民wp
-
发表于: 2024-8-28 17:17 3152
-
很传统的一道题
输入 username 和 Serial之后,就进入验证模块
这里的a1[1]就是sub_00401120
的地址,读了函数本身的字节,参与后续的校验
后面就更加易懂一点
先是通过username计算一个值2 * (v11 & 0xF)
然后对密文中的“其他”位进行校验
这里校验的含义是,其他位的内容应该等于sub_004010D0
(*a1)的内容
最后是字符串校验
最复杂的左移右移部分,因为使用的key是sub_00401120
本身的字节,最后的校验是固定字符串"KCTF-2024-CRACK-SUCCESS"
所以其实可以逃课,或者提前算好这部分的值,然后插入密文之中
我这里使用的方法是绕过反调试之后,直接用样例的密文中对应部分替换
v2 = a1[1];
for
( i = 0; i < 0x2B9; ++i )
v34[i % 0x43u] ^= v2[i];
v4 = v34[0];
for
( j = 1; j < 66; v4 ^= v34[j - 2] ^ v34[j - 1] ^ v34[j - 3] ^ v6 )
{
v6 = v34[j + 1] ^ v34[j];
j += 5;
}
v7 = v4 ^ v34[66];
v34[66] ^= v4;
v8 = v34;
v9 = 66;
do
{
*v8++ ^= v7;
--v9;
}
while
( v9 );
v2 = a1[1];
for
( i = 0; i < 0x2B9; ++i )
v34[i % 0x43u] ^= v2[i];
v4 = v34[0];
for
( j = 1; j < 66; v4 ^= v34[j - 2] ^ v34[j - 1] ^ v34[j - 3] ^ v6 )
{
v6 = v34[j + 1] ^ v34[j];
j += 5;
}
v7 = v4 ^ v34[66];
v34[66] ^= v4;
v8 = v34;
v9 = 66;
do
{
*v8++ ^= v7;
--v9;
}
while
( v9 );
v10 = u_name[0];
v11 = 0;
for
( k = u_name; *k; v10 = *k )
{
++k;
v11 ^= v10;
}
v13 = *a1;
v14 = v34;
v33 = &v34[2 * (v11 & 0xF)];
v10 = u_name[0];
v11 = 0;
for
( k = u_name; *k; v10 = *k )
{
++k;
v11 ^= v10;
}
v13 = *a1;
v14 = v34;
v33 = &v34[2 * (v11 & 0xF)];
key_func
=
[...]
# sub_00401120
flag_base
=
"KCTF-2024-CRACK-SUCCESS"
good_check_data
=
[
0x69
,
0x34
,
0x45
,
0x23
,
0x2D
,
0x32
,
0x30
,
0x32
,
0x86
,
0xD2
,
0xA1
,
0x25
,
0x14
,
0x43
,
0x69
,
0x69
,
0x4D
,
0xAA
,
0x68
,
0x43
,
0x54
,
0x53
,
0x53
]
good_enc_data
=
[...]
# sub_004010D0
def
get_str(_data):
return
''.join([
hex
(i)[
2
:].zfill(
2
)
for
i
in
_data])
def
decode1(_data):
for
i
in
range
(
len
(key_func)):
_data[i
%
0x43
] ^
=
key_func[i]
return
_data
def
decode2(_data):
key
=
_data[
0x42
]
_data1
=
[_data[i] ^ key
for
i
in
range
(
0x42
)]
key2
=
0
for
i
in
range
(
0x42
):
key2 ^
=
_data[i]
_data1.append(key2^key)
return
_data1
def
decode3(_uname:
str
):
key1
=
0
for
i
in
[
ord
(i)
for
i
in
_uname]:
key1 ^
=
i
key1_addr
=
2
*
(key1 &
0xF
)
ret_list
=
[i
for
i
in
good_enc_data]
for
i
in
range
(
len
(good_check_data)):
ret_list[key1_addr
+
i]
=
good_check_data[i]
return
ret_list
if
__name__
=
=
'__main__'
:
a1
=
decode3(
"KCTF"
)
a2
=
decode2(a1)
a3
=
decode1(a2)
print
(get_str(a3))
key_func
=
[...]
# sub_00401120
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
看原图
赞赏
雪币:
留言: