In this article, we will look into the following assembly code, analyze it and try to construct the corresponding C code.
0000000000400546 <main>: 400546: push rbp 400547: mov rbp,rsp 40054a: sub rsp,0x30 40054e: mov rax,QWORD PTR fs:0x28 400555: 00 00 400557: mov QWORD PTR [rbp-0x8],rax 40055b: xor eax,eax 40055d: mov DWORD PTR [rbp-0x20],0x6c707041 400564: mov WORD PTR [rbp-0x1c],0x65 40056a: mov DWORD PTR [rbp-0x24],0x0 400571: jmp 40058a <main+0x44> 400573: mov eax,DWORD PTR [rbp-0x24] 400576: cdqe 400578: movzx edx,BYTE PTR [rbp+rax*1-0x20] 40057d: mov eax,DWORD PTR [rbp-0x24] 400580: cdqe 400582: mov BYTE PTR [rbp+rax*1-0x10],dl 400586: add DWORD PTR [rbp-0x24],0x1 40058a: mov eax,DWORD PTR [rbp-0x24] 40058d: cdqe 40058f: movzx eax,BYTE PTR [rbp+rax*1-0x20] 400594: test al,al 400596: jne 400573 <main+0x2d> 400598: mov eax,DWORD PTR [rbp-0x24] 40059b: cdqe 40059d: mov BYTE PTR [rbp+rax*1-0x10],0x0 4005a2: mov eax,0x0 4005a7: mov rcx,QWORD PTR [rbp-0x8] 4005ab: xor rcx,QWORD PTR fs:0x28 4005b2: 00 00 4005b4: je 4005bb <main+0x75> 4005b6: call 400420 <__stack_chk_fail@plt> 4005bb: leave 4005bc: ret 4005bd: nop DWORD PTR [rax]
0 Comments