ida打开
找到sub_401890函数
int __thiscall sub_401890(CWnd *this)
{
CWnd *v1; // eax
int v2; // eax
struct CString *v4; // [esp-4h] [ebp-C4h]
int v5[26]; // [esp+4Ch] [ebp-74h] BYREF
int i; // [esp+B4h] [ebp-Ch]
char *Str; // [esp+B8h] [ebp-8h]
CWnd *v8; // [esp+BCh] [ebp-4h]
v8 = this;
v4 = (CWnd *)((char *)this + 100);
v1 = CWnd::GetDlgItem(this, 1002);
CWnd::GetWindowTextA(v1, v4);
v2 = sub_401A30((char *)v8 + 100);
Str = CString::GetBuffer((CWnd *)((char *)v8 + 100), v2);
if ( !strlen(Str) )
return CWnd::MessageBoxA(v8, &byte_4035DC, 0, 0);
for ( i = 0; Str[i]; ++i )
{
if ( Str[i] > 57 || Str[i] < 48 )
{
if ( Str[i] > 122 || Str[i] < 97 )
{
if ( Str[i] > 90 || Str[i] < 65 )
sub_4017B0();
else
v5[i] = Str[i] - 29;
}
else
{
v5[i] = Str[i] - 87;
}
}
else
{
v5[i] = Str[i] - 48;
}
}
return sub_4017F0(v5);
}
有看到sub_4017F0函数
int __cdecl sub_4017F0(int a1)
{
int result; // eax
char Str1[28]; // [esp+D8h] [ebp-24h] BYREF
int v3; // [esp+F4h] [ebp-8h]
int v4; // [esp+F8h] [ebp-4h]
v4 = 0;
v3 = 0;
while ( *(int *)(a1 + 4 * v4) < 62 && *(int *)(a1 + 4 * v4) >= 0 )
{
Str1[v4] = aAbcdefghiabcde[*(_DWORD *)(a1 + 4 * v4)];
++v4;
}
Str1[v4] = 0;
if ( !strcmp(Str1, "KanXueCTF2019JustForhappy") )
result = sub_401770();
else
result = sub_4017B0();
return result;
}
由此可以看出第二个函数是字典
写个Python脚本
tab='abcdefghiABCDEFGHIJKLMNjklmn0123456789opqrstuvwxyzOPQRSTUVWXYZ'
tg='KanXueCTF2019JustForhappy'
temp=[]
for i in range(len(tg)):
temp.append(tab.index(tg[i]))
flag=''
for c in temp:
if c>=65-29 and c<=90-29:
c+=29
elif c>=97-87 and c<=122-87:
c+=87
elif c>=48-48 and c<=57-48:
c+=48
flag+=chr(c)
print(flag)
得到flag:j0rXI4bTeustBiIGHeCF70DDM