以下是代码部分
program a1_1;
{$APPTYPE CONSOLE} //声明本程序是一个控制台程序
//uses sysutils; //注释语句,并不会执行
var s:string; //var属于变量 s:string;属于常量,声明 s 是字符类型的变量字符
begin //开始执行
Writeln('请输入测试文字:'); //屏幕上输出[请输入测试文字:]输出后自动换行
Readln(s); 读入S的变量
Writeln('你所输入的是:',s); //把S的变量写到屏幕上并换行
//下面的代码是为了在按下回车键前始终显示运行界面 //注释语句,并不会执
行
Writeln('按下回车键<Enter>退出。');
Readln; //读入一行文字
end. //结束
-----------------------------------------------------------------------------------------------------
通过跟踪调试可以得到以下结论
00403BBE 55 push ebp ;载入后程序停在这里
00403BBF 68 5B3C4000 push 00403C5B
00403BC4 64:FF30 push dword ptr fs:[eax]
00403BC7 64:8920 mov dword ptr fs:[eax], esp
00403BCA A1 A4404000 mov eax, dword ptr [4040A4]
00403BCF BA 703C4000 mov edx, 00403C70 ; 请输入测试文字:
00403BD4 E8 9BFBFFFF call 00403774
00403BD9 E8 2AF1FFFF call 00402D08
00403BDE E8 89E9FFFF call 0040256C
00403BE3 BA 5C564000 mov edx, 0040565C
00403BE8 A1 A8404000 mov eax, dword ptr [4040A8]
00403BED E8 92EEFFFF call 00402A84 ; 在这程序被完全运行
00403BF2 A1 A8404000 mov eax, dword ptr [4040A8]
00403BF7 E8 F4EEFFFF call 00402AF0
00403BFC E8 6BE9FFFF call 0040256C
00403C01 A1 A4404000 mov eax, dword ptr [4040A4]
00403C06 BA 8C3C4000 mov edx, 00403C8C ; 你所输入的是:
00403C0B E8 64FBFFFF call 00403774
00403C10 8B15 5C564000 mov edx, dword ptr [40565C]
00403C16 E8 59FBFFFF call 00403774 ; 在这显示刚才所输入的字符
00403C1B E8 E8F0FFFF call 00402D08
00403C20 E8 47E9FFFF call 0040256C
00403C25 A1 A4404000 mov eax, dword ptr [4040A4]
00403C2A BA A43C4000 mov edx, 00403CA4 ; 按下回车键<enter>退出。
00403C2F E8 40FBFFFF call 00403774
00403C34 E8 CFF0FFFF call 00402D08
00403C39 E8 2EE9FFFF call 0040256C
00403C3E A1 A8404000 mov eax, dword ptr [4040A8]
00403C43 E8 A8EEFFFF call 00402AF0 ; 屏幕上提示:按下回车,程序将退出
00403C48 E8 1FE9FFFF call 0040256C ; 按下回车后程序继续向下走
00403C4D 33C0 xor eax, eax
00403C4F 5A pop edx
00403C50 59 pop ecx
00403C51 59 pop ecx
00403C52 64:8910 mov dword ptr fs:[eax], edx
00403C55 68 623C4000 push 00403C62
00403C5A C3 retn ; 返回到00403C62
00403C5B ^ E9 20F4FFFF jmp 00403080
00403C60 ^ EB F8 jmp short 00403C5A
00403C62 E8 8DF8FFFF call 004034F4 ; 走到这里程序将退出
------------------------------------------------------------------------------------------------------------------------
我们在来看一下
00403C62 E8 8DF8FFFF call 004034F4 ; 走到这里程序将退出
004034F4这个地址跟进一下看看,里面的代码是这样的,很容易就看出这个CALL是个结束进程
004034F4 53 push ebx
004034F5 56 push esi
004034F6 57 push edi
004034F7 55 push ebp
004034F8 BB 20564000 mov ebx, 00405620
004034FD BE 00404000 mov esi, 00404000
00403502 BF 30504000 mov edi, 00405030
00403507 807B 28 00 cmp byte ptr [ebx+28], 0
0040350B 75 16 jnz short 00403523
0040350D 833F 00 cmp dword ptr [edi], 0
00403510 74 11 je short 00403523
00403512 8B17 mov edx, dword ptr [edi]
00403514 89D0 mov eax, edx
00403516 33D2 xor edx, edx
00403518 8917 mov dword ptr [edi], edx
0040351A 8BE8 mov ebp, eax
0040351C FFD5 call ebp
0040351E 833F 00 cmp dword ptr [edi], 0
00403521 ^ 75 EF jnz short 00403512
00403523 833D 04404000 0>cmp dword ptr [404004], 0
0040352A 74 11 je short 0040353D
0040352C E8 ABFEFFFF call 004033DC
00403531 E8 32FFFFFF call 00403468
00403536 33C0 xor eax, eax
00403538 A3 04404000 mov dword ptr [404004], eax
0040353D 807B 28 02 cmp byte ptr [ebx+28], 2
00403541 75 0A jnz short 0040354D
00403543 833E 00 cmp dword ptr [esi], 0
00403546 75 05 jnz short 0040354D
00403548 33C0 xor eax, eax
0040354A 8943 0C mov dword ptr [ebx+C], eax
0040354D E8 8AFDFFFF call 004032DC
00403552 807B 28 01 cmp byte ptr [ebx+28], 1
00403556 76 05 jbe short 0040355D
00403558 833E 00 cmp dword ptr [esi], 0
0040355B 74 21 je short 0040357E
0040355D 8B43 10 mov eax, dword ptr [ebx+10]
00403560 85C0 test eax, eax
00403562 74 1A je short 0040357E
00403564 E8 A7020000 call 00403810
00403569 8B53 10 mov edx, dword ptr [ebx+10]
0040356C 8B42 10 mov eax, dword ptr [edx+10]
0040356F 3B42 04 cmp eax, dword ptr [edx+4]
00403572 74 0A je short 0040357E
00403574 85C0 test eax, eax
00403576 74 06 je short 0040357E
00403578 50 push eax
00403579 E8 F2DAFFFF call <jmp.&kernel32.FreeLibrary>
0040357E E8 31FDFFFF call 004032B4
00403583 807B 28 01 cmp byte ptr [ebx+28], 1
00403587 75 03 jnz short 0040358C
00403589 FF53 24 call dword ptr [ebx+24]
0040358C 807B 28 00 cmp byte ptr [ebx+28], 0
00403590 74 05 je short 00403597
00403592 E8 A1FEFFFF call 00403438
00403597 833B 00 cmp dword ptr [ebx], 0
0040359A 75 17 jnz short 004035B3 ; 不跳程序将结束
0040359C 833D 18504000 0>cmp dword ptr [405018], 0
004035A3 74 06 je short 004035AB
004035A5 FF15 18504000 call dword ptr [405018]
004035AB 8B06 mov eax, dword ptr [esi]
004035AD 50 push eax
004035AE E8 ADDAFFFF call <jmp.&kernel32.ExitProcess> ; 程序退出函数ExitProcess
004035B3 8B03 mov eax, dword ptr [ebx]
004035B5 56 push esi
004035B6 8BF0 mov esi, eax
004035B8 8BFB mov edi, ebx
004035BA B9 0B000000 mov ecx, 0B
004035BF F3:A5 rep movs dword ptr es:[edi], dword p>
004035C1 5E pop esi
004035C2 ^ E9 76FFFFFF jmp 0040353D
004035C7 5D pop ebp
004035C8 5F pop edi
004035C9 5E pop esi
004035CA 5B pop ebx
004035CB C3 retn
004035AE E8 ADDAFFFF call <jmp.&kernel32.ExitProcess> ; 程序退出函数ExitProcess (这里很明显了)
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)