-
Stack AlignmentHacking/Pwnable 2019. 7. 11. 22:31
스택 정렬(Stack Alignment)은 스택을 16바이트 경계에 정렬하는 것을 의미한다.
32bit binary에서 정렬 코드
gdb-peda$ pd main Dump of assembler code for function main: 0x080485d3 <+0>: lea ecx,[esp+0x4] // Stack Alignment 0x080485d7 <+4>: and esp,0xfffffff0 // 하위 1비트 -> 0 0x080485da <+7>: push DWORD PTR [ecx-0x4] // ret 0x080485dd <+10>: push ebp // sfp 0x080485de <+11>: mov ebp,esp 0x080485e0 <+13>: push ecx 0x080485e1 <+14>: sub esp,0x4 0x080485e4 <+17>: mov eax,ecx 0x080485e6 <+19>: cmp DWORD PTR [eax],0x1 0x080485e9 <+22>: jg 0x8048605 <main+50> 0x080485eb <+24>: sub esp,0xc 0x080485ee <+27>: push 0x80486e4 0x080485f3 <+32>: call 0x8048430 <puts@plt> 0x080485f8 <+37>: add esp,0x10 0x080485fb <+40>: sub esp,0xc 0x080485fe <+43>: push 0x0 0x08048600 <+45>: call 0x8048450 <exit@plt> 0x08048605 <+50>: call 0x804857b <vuln> 0x0804860a <+55>: nop 0x0804860b <+56>: mov ecx,DWORD PTR [ebp-0x4] 0x0804860e <+59>: leave 0x0804860f <+60>: lea esp,[ecx-0x4] 0x08048612 <+63>: ret End of assembler dump. gdb-peda$
참고문헌
https://stackoverflow.com/questions/672461/what-is-stack-alignment
what is "stack alignment"?
What is stack alignment? Why is it used? Can it be controlled by compiler settings? The details of this question are taken from a problem faced when trying to use ffmpeg libraries with msvc, how...
stackoverflow.com
https://www.lazenca.net/display/TEC/01.Frame+Pointer+Overwrite%28One-byte+Overflow%29+-+x86
01.Frame Pointer Overwrite(One-byte Overflow) - x86 - TechNote - Lazenca.0x0
Excuse the ads! We need some help to keep our site up. List Frame Pointer Overwrite(One-byte Overflow) - x86 x86에서도 x64 환경과 같이 Frame Pointer를 1byte 덮어써서 코드의 흐름을 변경 할 수 있습니다.32 bit Binary의 경우 64bit와 달리 스택을 16 바이트 경계에 정렬하는 코드가 추가됩니다.x86-64 ABI는 16 바이트 스택 정렬이
www.lazenca.net
'Hacking > Pwnable' 카테고리의 다른 글
LEAVE & RET instruction (0) 2019.07.11