AndroGenshin:
rc4加密表,base64换表:
脚本梭就行
python
username = b"genshinimpact" base64_table = [125, 239, 101, 151, 77, 163, 163, 110, 58, 230, 186, 206, 84, 84, 189, 193, 30, 63, 104, 178, 130, 211, 164, 94, 75, 16, 32, 33, 193, 160, 120, 47, 30, 127, 157, 66, 163, 181, 177, 47, 0, 236, 106, 107, 144, 231, 250, 16, 36, 34, 91, 9, 188, 81, 5, 241, 235, 3, 54, 150, 40, 119, 202, 150] def rc4(key, data): S = list(range(256)) j = 0 out = [] for i in range(256): j = (j + S[i] + key[i % len(key)]) % 256 S[i], S[j] = S[j], S[i] i = j = 0 for t in data: i = (i + 1) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] out.append(t^ S[(S[i] + S[j]) % 256]) return out import base64 def base64_custom_decode(data, custom_table): original_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" decode_table = str.maketrans(custom_table, original_table) decoded_data = base64.b64decode(data.translate(decode_table)) return decoded_data retval = rc4(username, base64_table) new_table = "".join([chr(t) for t in retval]) enc_data = "YnwgY2txbE8TRyQecyE1bE8DZWMkMiRgJW1=" print(base64_custom_decode(enc_data, new_table))
SMC:
先来看主函数部分:
c
int __cdecl main(int argc, const char **argv, const char **envp)
{
DWORD *v3; // eax
v3 = (DWORD *)malloc(0x26u);
VirtualProtect(&sub_403040, 0x26u, 0x40u, v3);
puts("Please enter your flag:");
sub_401025("%s", data);
if ( NtCurrentPeb()->BeingDebugged )
{
MessageBoxA(0, "Debug Detected!", "Warning!", 0);
Sleep(0x1388u);
exit(0);
}
sub_401042();
if ( ((int (__cdecl *)(char *, void *))sub_403040)(data, &byte_403020) )
puts("Win!");
else
puts("Lose!");
return system("pause");
}
主函数比较简洁明了,就是sub_403040这个函数不知道,是由sub_401042这个函数解密而成的,看一下加密函数
c
char sub_401042()
{
int i; // ecx
char result; // al
for ( i = 0; i < 38; ++i )
{
result = byte_403068[i & 3];
sub_403040[i] ^= result;
}
return result;
}
接着动调把解密后的函数搞出来就行
可以直接set ip直接跳到目标函数处,patch掉反调试代码
解密函数如下:
就是异或再加5,直接梭脚本就行
python
data=[0x7C, 0x82, 0x75, 0x7B, 0x6F, 0x47, 0x61, 0x57, 0x53, 0x25,
0x47, 0x53, 0x25, 0x84, 0x6A, 0x27, 0x68, 0x27, 0x67, 0x6A,
0x7D, 0x84, 0x7B, 0x35, 0x35, 0x48, 0x25, 0x7B, 0x7E, 0x6A,
0x33, 0x71]
for i in data:
char=(i-5)^0x11
print(chr(char),end="")

博客围绕CTF逆向题目展开,涉及AndroGenshin、SMC、Petals等多个题目。解题过程中,运用了rc4加密表、base64换表等方法,使用C和Python语言编写脚本。对于加密函数,通过动调、去花指令等手段解密,部分题目还需爆破求值。



最低0.47元/天 解锁文章
714

被折叠的 条评论
为什么被折叠?



