逆向工程函数分析:
- 分析函数参数:将传入的参数分别用符号进行表示;
- 分析局部变量:[ebp-4]
- 分析全局变量:[0x12345678]
- 功能分析
//if语句汇编分析
int a = 0;
int b = 2;
if (b > a)
{
cout << a;
}
汇编逆向分析:
//提升堆栈
00911E80 push ebp
00911E81 mov ebp,esp
00911E83 sub esp,0D8h
//保护现场
00911E89 push ebx
00911E8A push esi
00911E8B push edi
//缓冲区填充
00911E8C lea edi,[ebp-0D8h]
00911E92 mov ecx,36h
00911E97 mov eax,0CCCCCCCCh
00911E9C rep stos dword ptr es:[edi]
00911E9E mov ecx,offset _5A91085F_practice@cpp (091C027h)
00911EA3 call @__CheckForDebuggerJustMyCode@4 (0911212h)
//执行操作
int a = 0;
00911EA8 mov dword ptr [a],0
int b = 2;
00911EAF mov dword ptr [b],2
if (b > a)
00911EB6 mov eax,dword ptr [b]
00911EB9 cmp eax,dword ptr [a]
00911EBC jle main+57h (0911ED7h)
{
cout << a;
00911EBE mov esi,esp
00911EC0 mov eax,dword ptr [a]
00911EC3 push eax
00911EC4 mov ecx,dword ptr [_imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A (091B098h)]
00911ECA call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (091B09Ch)]
00911ED0 cmp esi,esp
{
cout << a;
00911ED2 call __RTC_CheckEsp (091121Ch)
}
return 0;
00911ED7 xor eax,eax
}
//恢复现场
00911ED9 pop edi
00911EDA pop esi
00911EDB pop ebx
//还原堆栈
00911EDC add esp,0D8h
00911EE2 cmp ebp,esp
00911EE4 call __RTC_CheckEsp (091121Ch)
00911EE9 mov esp,ebp
00911EEB pop ebp
00911EEC ret
语句分析:
00911EB6 mov eax,dword ptr [b]
00911EB9 cmp eax,dword ptr [a] //进行条件运算
00911EBC jle main+57h (0911ED7h)//进行结果比较,判定是否跳转
00911ED7 xor eax,eax
//if-else语句分析
int a = 0;
int b = 2;
if (b > a)
{
cout << a;
}
else
{
cout << b;
}
汇编逆向分析:
//堆栈提升
000F1880 push ebp
000F1881 mov ebp,esp
000F1883 sub esp,0D8h
//保护现场
000F1889 push ebx
000F188A push esi
000F188B push edi
//填充缓冲区
000F188C lea edi,[ebp-0D8h]
000F1892 mov ecx,36h
000F1897 mov eax,0CCCCCCCCh
000F189C rep stos dword ptr es:[edi]
000F189E mov ecx,offset _5A91085F_practice@cpp (0FF027h)
000F18A3 call @__CheckForDebuggerJustMyCode@4 (0F1280h)
//执行语句
int a = 0;
000F18A8 mov dword ptr [a],0
int b = 2;
000F18AF mov dword ptr [b],2
if (b > a)
000F18B6 mov eax,dword ptr [b]
000F18B9 cmp eax,dword ptr [a]
000F18BC jle main+59h (0F18D9h)
{
cout << a;
000F18BE mov esi,esp
000F18C0 mov eax,dword ptr [a]
000F18C3 push eax
000F18C4 mov ecx,dword ptr [_imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A (0FD0DCh)]
{
cout << a;
000F18CA call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0FD0A4h)]
000F18D0 cmp esi,esp
000F18D2 call __RTC_CheckEsp (0F128Ah)
}
else
000F18D7 jmp main+72h (0F18F2h)
cout << b;
000F18D9 mov esi,esp
000F18DB mov eax,dword ptr [b]
000F18DE push eax
000F18DF mov ecx,dword ptr [_imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A (0FD0DCh)]
000F18E5 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0FD0A4h)]
000F18EB cmp esi,esp
000F18ED call __RTC_CheckEsp (0F128Ah)
//int d[12];
//cout << d &