prob3.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | Dump of assembler code for function main: 0x8048400 <main>: push %ebp //복귀주소 0x8048401 <main+1>: mov %ebp,%esp 0x8048403 <main+3>: sub %esp,32 //32바이트 공간 할당 0x8048406 <main+6>: push %edi //백업 0x8048407 <main+7>: push %esi //백업 0x8048408 <main+8>: push %ebx //백업 0x8048409 <main+9>: mov DWORD PTR [%ebp-4],0xa // a = 10 0x8048410 <main+16>: lea %edi,[%ebp-28] // edi = ebp-28 0x8048413 <main+19>: mov %esi,0x8048510 //esi = "ABCDEFGHIJKLMNOP" 0x8048418 <main+24>: cld //direction flag = 0 0x8048419 <main+25>: mov %ecx,0x4 //ecx = 0x4 아래 반복을 위함 0x804841e <main+30>: repz movs %es:(%edi),%ds:(%esi)//4바이트씩 처리 //repz(repe) -> cx가 0이 아닌동안, 비교가 같지 않은 동안 반복 //movs Source에서 Destination으로 데이터복사 //ecx가 4이므로 총 4바이트씩 4번 16바이트를 처리 0x8048420 <main+32>: movs %es:(%edi),%ds:(%esi) //?? 왜 한번에 안했지?? //ds(esi)에서 es(edi)로 데이터 복사 0x8048421 <main+33>: lea %eax,[%ebp-11] 0x8048424 <main+36>: push 3 0x8048426 <main+38>: push 0 0x8048428 <main+40>: push %eax 0x8048429 <main+41>: call 0x8048340 <memset> //memset([17],0,3) 0x804842e <main+46>: add %esp,12 ////////초기식/////////// 0x8048431 <main+49>: mov DWORD PTR [%ebp-8],0x0 //ebp-8 = 0 /////////조건식//////////// 0x8048438 <main+56>: cmp DWORD PTR [%ebp-8],15 //i와 15비교 0x804843c <main+60>: jle 0x8048440 <main+64> //왼쪽(0)이 작으면 아래 건너뜀 0x804843e <main+62>: jmp 0x80484a0 <main+160> //출력으로 점프 ///////////////반복문 시작 ///////////////////// 0x8048440 <main+64>: mov %eax,DWORD PTR [%ebp-8] //eax = i 0x8048443 <main+67>: mov %edx,%eax //edx = eax = i 0x8048445 <main+69>: and %edx,1 //edx = 홀수이면 1 짝수면 0 0x8048448 <main+72>: test %edx,%edx //edx가 0인지 확인 0x804844a <main+74>: jne 0x8048471 <main+113> //0이 아니면 점프 //짝수 0x804844c <main+76>: lea %eax,[%ebp-28] //eax = 문자열 주소 0x804844f <main+79>: mov %edx,DWORD PTR [%ebp-8] //edx = i의 값 0x8048452 <main+82>: lea %ecx,[%ebp-28] //ecx = 문자열 주소 0x8048455 <main+85>: mov DWORD PTR [%ebp-32],%ecx //int tmp = 문자열주소 0x8048458 <main+88>: mov %ebx,DWORD PTR [%ebp-8] //ebx = i값 0x804845b <main+91>: mov %ecx,DWORD PTR [%ebp-32] //ecx = tmp의 값 0x804845e <main+94>: mov %cl,BYTE PTR [%ebx+%ecx] //cl = [문자열주소+i]의 문자 0x8048461 <main+97>: mov BYTE PTR [%ebp-32],%cl //tmp = cl 0x8048464 <main+100>: mov %bl,BYTE PTR [%ebp-8] //bl = i의 값 0x8048467 <main+103>: mov %cl,BYTE PTR [%ebp-32] //cl = tmp의 값 0x804846a <main+106>: add %cl,%bl //cl = cl+bl (tmp + i) 0x804846c <main+108>: mov BYTE PTR [%edx+%eax],%cl //[edx+eax] = cl 0x804846f <main+111>: jmp 0x8048494 <main+148> //홀수 0x8048471 <main+113>: lea %eax,[%ebp-28] //eax = ebp-28 0x8048474 <main+116>: mov %edx,DWORD PTR [%ebp-8] //edx = [ebp-8]의 값 0x8048477 <main+119>: lea %ecx,[%ebp-28] //ecx = ebp-28 0x804847a <main+122>: mov DWORD PTR [%ebp-32],%ecx //[ebp-32] = ebp-28 0x804847d <main+125>: mov %ebx,DWORD PTR [%ebp-8] //ebx = [ebp-8]의 값 0x8048480 <main+128>: mov %ecx,DWORD PTR [%ebp-32] //ecx = [ebp-32]의 값 0x8048483 <main+131>: mov %cl,BYTE PTR [%ebx+%ecx] //cl = [ebx+ecx]의 값 0x8048486 <main+134>: mov BYTE PTR [%ebp-32],%cl //[ebp-32] = cl 0x8048489 <main+137>: mov %bl,BYTE PTR [%ebp-8] //bl = [ebp-8]의 값 0x804848c <main+140>: mov %cl,BYTE PTR [%ebp-32] //cl = [ebp-32]의 값 0x804848f <main+143>: sub %cl,%bl //cl = cl+bl 0x8048491 <main+145>: mov BYTE PTR [%edx+%eax],%cl //[edx+eax] = cl 0x8048494 <main+148>: inc DWORD PTR [%ebp-8] //[ebp-8]++ -> 아마 for문 증가문 0x8048497 <main+151>: jmp 0x8048438 <main+56> //아마 반복문? //////////////반복문 끝//////// // 명령어파이프라인 -> 효율적 처리를 위함 0x8048499 <main+153>: lea %esi,[%esi*1] 0x80484a0 <main+160>: lea %eax,[%ebp-28] //eax = ebp-28 0x80484a3 <main+163>: push %eax 0x80484a4 <main+164>: push 0x8048521 //"%s\n" 0x80484a9 <main+169>: call 0x8048330 <printf> // 0x80484ae <main+174>: add %esp,8 0x80484b1 <main+177>: lea %esp,[%ebp-44] 0x80484b4 <main+180>: pop %ebx 0x80484b5 <main+181>: pop %esi 0x80484b6 <main+182>: pop %edi 0x80484b7 <main+183>: leave 0x80484b8 <main+184>: ret (gdb) x/s 0x8048510 0x8048510 <_IO_stdin_used+4>: "ABCDEFGHIJKLMNOP" (gdb) x/s 0x8048521 0x8048521 <_IO_stdin_used+21>: "%s\n" | cs |
핸드레이
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<stdio.h> #include<string.h> int main(){ int i; int a=10; char arr[20]="ABCDEFGHIJKLMNOP"; memset(&arr[17],0,3); for(i=0;i<=15;i++){ if(i%2==0){ arr[i]+=i; }else{ arr[i]-=i; } } printf("%s",arr); return 0; } | cs |
'Study > reversing' 카테고리의 다른 글
PE 헤더 구조체 (0) | 2017.10.12 |
---|---|
PE란? (0) | 2017.10.11 |
prob2.c 핸드레이 (0) | 2017.09.20 |
prob1.c 핸드레이 (0) | 2017.09.19 |
abex Crackme 1번 Line By Line (0) | 2017.09.19 |