32位
这里后面运行这个程序居然要 Visual Studio,不然运行不了
IDA打开,直接锁定main函数
看见v9,四个32位,就想到了tea加密
、
标准tea
from ctypes import *
#tea
def decrypt(v, k):
v0 = c_uint32(v[0])
v1 = c_uint32(v[1])
delta = 0x9e3779b9
sum1 = c_uint32(delta * 32)
for i in range(32):
v1.value -= ((v0.value << 4) + k[2]) ^ (v0.value + sum1.value) ^ ((v0.value >> 5) + k[3])
v0.value -= ((v1.value << 4) + k[0]) ^ (v1.value + sum1.value) ^ ((v1.value >> 5) + k[1])
sum1.value -= delta
return v0.value, v1.value
if __name__ == '__main__':
a = [1627184887, 37149676]
k = [18, 52, 86, 120]
print("解密后数据:", decrypt(a,k))
4是直接赋值的,3就是我们输入的
但是这只是第一关,下面还有一个函数
我们进sub411302发现是这个,两种可能
smc和花指令
我们看汇编,这是正常的
那么就是smc自加密了
动调
再次编译下这个函数就ok了
int __cdecl sub_41D000(char *Str)
{
char v2; // [esp+0h] [ebp-558h]
size_t m; // [esp+190h] [ebp-3C8h]
BOOL v4; // [esp+19Ch] [ebp-3BCh]
int k; // [esp+1A8h] [ebp-3B0h]
int v6; // [esp+1B4h] [ebp-3A4h]
int v7; // [esp+1C0h] [ebp-398h]
int i; // [esp+1CCh] [ebp-38Ch]
int j; // [esp+1CCh] [ebp-38Ch]
int v10; // [esp+1CCh] [ebp-38Ch]
char v11; // [esp+1DBh] [ebp-37Dh]
char v12; // [esp+1DBh] [ebp-37Dh]
char v13[540]; // [esp+1E4h] [ebp-374h]
char v14[24]; // [esp+400h] [ebp-158h] BYREF
int v15; // [esp+418h] [ebp-140h]
char v16[264]; // [esp+424h] [ebp-134h] BYREF
char v17[40]; // [esp+52Ch] [ebp-2Ch] BYREF
__CheckForDebuggerJustMyCode(&unk_425036);
v17[0] = 15;
v17[1] = -108;
v17[2] = -82;
v17[3] = -14;
v17[4] = -64;
v17[5] = 87;
v17[6] = -62;
v17[7] = -32;
v17[8] = -102;
v17[9] = 69;
v17[10] = 55;
v17[11] = 80;
v17[12] = -11;
v17[13] = -96;
v17[14] = 94;
v17[15] = -53;
v17[16] = 44;
v17[17] = 22;
v17[18] = 40;
v17[19] = 41;
v17[20] = -2;
v17[21] = -1;
v17[22] = 51;
v17[23] = 70;
v17[24] = 14;
v17[25] = 87;
v17[26] = -126;
v17[27] = 34;
v17[28] = 82;
v17[29] = 38;
v17[30] = 43;
v17[31] = 110;
v17[32] = -28;
v17[33] = -126;
v17[34] = 36;
j_memset(v16, 0, 0x100u);
v15 = j_strlen(Str);
strcpy(v14, "you_are_master");
v13[531] = 0;
v6 = 0;
for ( i = 0; i < 256; ++i )
{
v13[i + 264] = i;
v13[i] = v14[i % j_strlen(v14)];
}
for ( j = 0; j < 256; ++j )
{
v6 = (v13[j] + v6 + v13[j + 264]) % 256;
v11 = v13[j + 264];
v13[j + 264] = v13[v6 + 264];
v13[v6 + 264] = v11;
}
v7 = 0;
v10 = 0;
for ( k = 0; k < v15; ++k )
{
v10 = (v10 + 1) % 256;
v7 = (v7 + v13[v10 + 264]) % 256;
v12 = v13[v10 + 264];
v13[v10 + 264] = v13[v7 + 264];
v13[v7 + 264] = v12;
v16[k] = v13[(v13[v7 + 264] + v13[v10 + 264]) % 256 + 264] ^ Str[k];
}
v4 = j_strlen(Str) == 35;
for ( m = 0; m < j_strlen(v17); ++m )
{
if ( v17[m] != v16[m] )
{
v4 = 0;
break;
}
}
if ( v4 )
return sub_41114F("right!!!!", v2);
else
return sub_41114F("please try agin~", v2);
}
进入是一个RC4加密算法
from Crypto.Cipher import ARC4
# 假设这是经过RC4加密的数据
encrypt_data = [15, 148, 174, 242, 192, 87, 194, 224, 154, 69,
55, 80, 245, 160, 94, 203, 44, 22, 40, 41,
254, 255, 51, 70, 14, 87, 130, 34, 82, 38,
43, 110, 228, 130, 36]
key = 'you_are_master'
encrypt_data_bytes = bytes("HDCTF{y0u_ar3_rc4_t3a_smc_m4ster!!}")
key_bytes = bytes(key, 'utf-8')
cipher = ARC4.new(key_bytes)
decrypted_data = cipher.encrypt(encrypt_data_bytes)
# 输出解密后的数据
try:
print(decrypted_data.decode('utf-8')) # 尝试以UTF-8格式解码
except UnicodeDecodeError:
print("无法以UTF-8解码,原始数据可能不是以UTF-8编码。请检查原始数据的编码方式。")
# 如果你知道原始数据的具体编码方式,替换上面的 'utf-8' 为你知道的编码方式