BUUCTF Reverse/[网鼎杯 2020 青龙组]jocker
先看下文件信息,没有加壳,32位程序
运行一下,又是一道字符串比较的题目
用IDA32位打开,分析一下
// positive sp value has been detected, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
char Str[50]; // [esp+12h] [ebp-96h] BYREF
char Destination[80]; // [esp+44h] [ebp-64h] BYREF
DWORD flOldProtect; // [esp+94h] [ebp-14h] BYREF
size_t v7; // [esp+98h] [ebp-10h]
int i; // [esp+9Ch] [ebp-Ch]
__main();
puts("please input you flag:");
if ( !VirtualProtect(encrypt, 200u, 4u, &flOldProtect) )
exit(1);
scanf("%40s", Str);
v7 = strlen(Str);
if ( v7 != 24 ) // flag长度为24
{
puts("Wrong!");
exit(0);
}
strcpy(Destination, Str);
wrong(Str);
omg(Str);
for ( i = 0; i <= 186; ++i )
*((_BYTE *)encrypt + i) ^= 0x41u;
if ( encrypt(Destination) )
((void (__cdecl *)(char *))finally)(Destination);
return 0;
}
这里有个函数,详情可以看这个VirtualProtect函数,大概就是设置这一段内容可以改变
if ( !VirtualProtect(encrypt, 200u, 4u, &flOldProtect) )
下面这里将这段地址都异或了一个0x41
for ( i = 0; i <= 186; ++i )
*((_BYTE *)encrypt + i) ^= 0x41u;
而且无法访问encrypt这段地址,然后看一下汇编代码
这里就是经过异或后的结果
这几个函数对输入的字符串进行变换
scanf("%40s", Str);
v7 = strlen(Str);
if ( v7 != 24 ) // flag长度为24
{
puts("Wrong!");
exit(0);
}
strcpy(Destination, Str);
wrong(Str);
omg(Str);
跟进查看
char *__cdecl wrong(char *a1)
{
char *result; // eax
int i; // [esp+Ch] [ebp-4h]
for ( i = 0; i <= 23; ++i )
{
result = &a1[i];
if