본문 바로가기
반응형

코스웨어/13년 스마트컨트롤러419

[stack] 코드의 스텍영역 살펴보기 - 0911 정리 함수 호출에 따른 STACK 영역의 변화 살펴보기 ▶ 다음 소스의 어셈블리어 따라가보기 int main (){add2 (3, 4);} void add2 (int A, int B){A + B;} ▶ 전체 과정- ① ~ ⑨ 진행 ▶ 시작 지점- esp- ebp- eip 1. push 4- esp- eip 2. push 3- esp- eip 3. call Add2- esp- eip 4. push ebp- esp- eip 5. mov ebp, esp- ebp- eip 6. mov eax, [ebp+8]- eax- eip 7. add eax, [ebp+12]- eax- eip 8. pop ebp- esp- ebp- eip 9. ret- eip- espadd esp, 8esp = 12ffc4 2013. 9. 16.
20130916 어셈블리 - 이수현 0916a.c 0916b.asm 컴파일cl /c 0916a.c : 0916a.objml /c /coff 0916b.asm : 0916b.objcl 0916a.obj 0916b.obj : 0916a.exe 2013. 9. 16.
20130916 어셈블리 - 전영기 push ebpmovebp, esp pusheaxpushecxpushedxpushfd ;기존 플래그비트를 저장하기 위함이다. 도중에 add 연산자가 있어 플래그비트를 바꿔버린다.pushebx movebx, esp ;esp를 ebx에 저장movesp, [ebp + 8]addesp, 40pusheax ;순차로 넣기pushecxpushedx movesp, ebx ;esp복구 popebx ;ebp복구popedx ;flag bit edx에 저장 moveax, esp ;eax에 esp저장movesp, [ebp + 8]addesp, 28 pushebx ;순차적으로 넣기movecx, ebp ;초기 esp주소addecx, 12pushecxmovecx, [ebp] ; 초기 ebppush ecxpushesipushedimo.. 2013. 9. 16.
ASM 프로시저를 이용한 레지스터값 출력!! ☞ 프로시저를 이용한 context 스위칭 프로그램 만들기 - 현재 레지스터값 출력!! C 소스 #include typedef struct _context { int efl; int eip; int edi; int esi; int ebp; int esp; int ebx; int edx; int ecx; int eax; }context ; void linux(context *); void Printf_REG(context *); int main() { context stReg = { 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678, 0x12345678 }; linu.. 2013. 9. 16.
20130917 이세웅 숙제 2013. 9. 16.
main의 ESP 찾기 어셈블리어 함수(프로시저) C코드에서 호출해 사용하기 - main의 ESP 찾기 ☞ C 소스 #include struct context { int eax; int ebx; int ecx; int edx; int esp; }; void linux(struct context *); int main() { int iNum1 = 100; struct context stReg; int iNum2 = 200; linux(&stReg); printf("%08X\n", stReg.eax); printf("%08X\n", stReg.ebx); printf("%08X\n", stReg.ecx); printf("%08X\n", stReg.edx); printf("%08X\n", stReg.esp); return 0; } ☞.. 2013. 9. 13.
2013_09_09 정리 입니다 -한성원- http://prezi.com/obcx7ngla7w8/?utm_campaign=share&utm_medium=copy 프레지로 만들어봐서 링크 타시구가서 봐야되요.ㅜㅜ 2013. 9. 13.
어셈블리 구조체포인터 함수 - 전영기 구조체 포인터를 인자로 받아 구조체 내부값을 바꾸는 어셈블리 코드esp를 구조체주소에 +16을 하여 구조체 멤버중 edx를 가리키고 있음push를 이용하여 구조체에 값을 넣음마지막으로 esp값을 ebp를 이용해 복구 나름 완성했지만 복구코드가 좋지 않다는 지적을 받게 되었습니다...주기는 30주기엔트리와 push ebx ecx edx pop edx ecx ebx를 제외한다면30주기가 나옵니다. 두번째 미션 여기서 프로그램 시작 시 esp의 위치는ebp + 12한 값그래서 add 12하고 push후 sub를 실행 eax 저장은 직접 주소에 저장 2013. 9. 13.
130913 금 조유진 .386.MODEL FLAT PUBLIC _linux.CODE_linux PROC NEAR32; 총 24 사이클( 엔트리+엑시트 백업 푸시팝 제외) pushebpmovebp, esp pushebx;2pushecx;2pushedx;2 ; 8moveax, 1;2movebx, 2;2movecx, 3;2movedx, 4;2 ; 6pusheax;2moveax, [ebp+8]; 4 ; 2popDWORD PTR[eax];4 ; 2movDWORD PTR[eax+4], ebx;2 ; 2movDWORD PTR[eax+8], ecx;2 ; 2movDWORD PTR[eax+12], edx;2 popedx;2popecx;2popebx;2 movesp, ebppopebpret _linux ENDP END 2013. 9. 13.
728x90
반응형