|
社区嘉宾
- 帖子:15158
- 注册:
2005-08-03
- 来自:
|
发表于:
2009-05-24 16:07
|
只看楼主
短消息
资料
病毒分析学习笔记之二
本次开始就需要大家用一些调试工具积极跟着我一起调试程序了,用邓爷爷的一句名言:实践才是检验真理的唯一标准。希望大家不要因为代码表明看起来很繁琐而畏惧,也不要光看不操作,让我们一起把反汇编这种看起来晦涩难懂的东西学透学精!本次课程用到的工具:OD http://www.pediy.com/tools/Debuggers/ollydbg/OllyICE.rarIDA(可用可不用)http://bbs.pediy.com/showthread.php?t=55801需要用到的程序见附件Push ebpMov ebx,espSub esp,XXX看过一些汇编代码的人一定对这个有些印象,那么这是做了什么操作呢?里面有什么奥秘呢? 本次需要了解的两个指令sub(相当于减)sub eax,xxx 就是将eax减去 xxx与之对应的是add ,相加。首先我们先引入一个非常简单的小程序:#include <stdio.h>#include <string.h>void func1(int input1, int input2){ int j; char c; short k; j = 0; c = 'a'; k = 1; printf("sum=%d\n", input1+input2); return;}int main(){ char output[8] = "abcdef"; int i, j; i=2; j=3; func1(i,j); printf("%s\r\n", output); return 0;}编译好了之后,用IDA打开该程序 定位到main函数.text:00401090 push ebp .text:00401091 mov ebp, esp .text:00401093 sub esp, 50h .text:00401096 push ebx .text:00401097 push esi .text:00401098 push edi .text:00401099 lea edi, [ebp+var_50] .text:0040109C mov ecx, 14h .text:004010A1 mov eax, 0CCCCCCCCh .text:004010A6 rep stosd .text:004010A8 mov eax, ds:dword_420030 .text:004010AD mov [ebp+var_8], eax .text:004010B0 mov cx, ds:word_420034 .text:004010B7 mov [ebp+var_4], cx .text:004010BB mov dl, ds:byte_420036 .text:004010C1 mov [ebp+var_2], dl .text:004010C4 xor eax, eax .text:004010C6 mov [ebp+var_1], al .text:004010C9 mov [ebp+var_C], 2 .text:004010D0 mov [ebp+var_10], 3 .text:004010D7 mov ecx, [ebp+var_10] .text:004010DA push ecx .text:004010DB mov edx, [ebp+var_C] .text:004010DE push edx .text:004010DF call sub_401005 -------- 这里调用了func_1函数 .text:004010E4 add esp, 8 .text:004010E7 lea eax, [ebp+var_8] .text:004010EA push eax .text:004010EB push offset aS ; "%s\r\n" .text:004010F0 call _printf .text:004010F5 add esp, 8 .text:004010F8 xor eax, eax .text:004010FA pop edi .text:004010FB pop esi .text:004010FC pop ebx .text:004010FD add esp, 50h .text:00401100 cmp ebp, esp .text:00401102 call __chkesp .text:00401107 mov esp, ebp .text:00401109 pop ebp .text:0040110A retn .text:0040110A _main_0 endpFunc_1函数 .text:00401020 .text:00401020 push ebp .text:00401021 mov ebp, esp .text:00401023 sub esp, 4Ch .text:00401026 push ebx .text:00401027 push esi .text:00401028 push edi .text:00401029 lea edi, [ebp+var_4C] .text:0040102C mov ecx, 13h .text:00401031 mov eax, 0CCCCCCCCh .text:00401036 rep stosd .text:00401038 mov [ebp+var_4], 0 .text:0040103F mov [ebp+var_8], 61h .text:00401043 mov [ebp+var_C], 1 .text:00401049 mov eax, [ebp+arg_0] .text:0040104C add eax, [ebp+arg_4] .text:0040104F push eax .text:00401050 push offset Format ; "sum=%d\n" .text:00401055 call _printf .text:0040105A add esp, 8 .text:0040105D pop edi .text:0040105E pop esi .text:0040105F pop ebx .text:00401060 add esp, 4Ch .text:00401063 cmp ebp, esp .text:00401065 call __chkesp .text:0040106A mov esp, ebp .text:0040106C pop ebp .text:0040106D retn .text:0040106D sub_401020 endp
本次我们不必关心这些代码的含义,我们目前只关心的是函数对栈是如何操作的。所以不要被这些东西吓到,我们要用的只是很少的一部分用户系统信息:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)
附件:
您所在的用户组无法下载或查看附件
 newcenturymoon 最后编辑于 2009-05-24 19:17:29
|