ida作为市面是最强大的反汇编利器和强大的hex-ray插件,但是难免有一些小的瑕疵,本次利用一个ida反汇编的一个小特性欺骗它的hex-ray插件,灵感来源于SunshineCtf的一道题和对PE结构的理解。
我们布置一个只读的全局变量赋值为0,然后在程序里判断该只读变量是否为0,而ida对于不可能的分支就会舍弃掉,就会导致只会反汇编其中的一部分。
给出代码
#include <stdio.h>
//flag{12345}
const int wrong = 0;}
char *_wrong = "you missed the flag!";
char *right = "yes you found it the flag is flag{%d}!";
void MySecret()
{
_asm {
push eax
mov eax, wrong
cmp eax, 0
je label_1
mov eax, 8587
add eax, 99
xor eax, 4567
push eax
push right
call printf
add esp, 8 //平衡两个参数
jmp label_2
label_1 : //must in
push _wrong
call printf
add esp, 4
label_2 :
pop eax
}
}
int main()
{
MySecret();
return 0;
}