BUUCTF在线评测 (buuoj.cn)
先到ida,先看一下字符串
找到主函数
int __cdecl main(int argc, const char **argv, const char **envp)
{
char Str[104]; // [rsp+20h] [rbp-70h] BYREF
int j; // [rsp+88h] [rbp-8h]
int i; // [rsp+8Ch] [rbp-4h]
sub_402230(argc, argv, envp);
sub_40E640("Give me your code:\n");
sub_40E5F0("%s", Str);
if ( strlen(Str) != 33 )
{
sub_40E640("Wrong!\n");
system("pause");
exit(0);
}
for ( i = 0; i <= 32; ++i )
{
byte_414040[i] = Str[dword_40F040[i]]; #把dword_40F040的数据变成字符型形式给byte_414040
byte_414040[i] ^= LOBYTE(dword_40F040[i]); # LOBYTE是取16bit数据的低8bit,这里是一个打乱顺序的操作,这是通过观察dword_40F040的数据发现正好是0~32的乱序猜测的(别的文章说的)
}
for ( j = 0; j <= 32; ++j )
{
if ( byte_40F0E0[j] != byte_414040[j] )#一个对比操作,对byte_40F0E0进行逆向即可
{
sub_40E640("Wrong!\n");
system("pause");
exit(0);
}
}
sub_40E640("Right!Good Job!\n");
sub_40E640("Here is your flag: %s\n", Str);
system("pause");
return 0;
}
对LOWORD, HIWORD, LOBYTE, HIBYTE的理解_mfc中lobyte-CSDN博客
这里8dup(0)是存8个0
汇编: dup伪指令_year db 4 dup('0')-CSDN博客
写个脚本
dword_40F040 = [0x9, 0x0A, 0x0F, 0x17, 0x7, 0x18, 0x0C, 0x6, 0x1, 0x10, 0x3, 0x11, 0x20, 0x1D, 0x0B, 0x1E, 0x1B, 0x16, 0x4, 0x0D, 0x13, 0x14, 0x15, 0x2, 0x19, 0x5, 0x1F, 0x8, 0x12, 0x1A, 0x1C, 0x0E, 0]
byte_40F0E0 = [0x67, 0x79, 0x7B, 0x7F, 0x75, 0x2B, 0x3C, 0x52, 0x53, 0x79, 0x57, 0x5E, 0x5D, 0x42, 0x7B, 0x2D, 0x2A, 0x66, 0x42, 0x7E, 0x4C, 0x57, 0x79, 0x41, 0x6B, 0x7E, 0x65, 0x3C, 0x5C, 0x45, 0x6F, 0x62, 0x4D]
str1 = [0] * 33
flag = ''
for i in range(33):
byte_40F0E0[i] ^= dword_40F040[i]
str1[dword_40F040[i]] = byte_40F0E0[i]
for i in range(33):
flag += chr(str1[i])
print(flag)
#flag{Tr4nsp0sltiON_Clph3r_1s_3z}