C300_055
C300_소스코드
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 | #include <stdio.h> #include <string.h> #define SKY "sky" void main( void ) { char string[100]; int ret; printf( "영단어를 입력한 후 Enter키를 치세요 !\n" ); printf( "sky로 시작되는 단어를 입력하면 프로그램이 종료됩니다. \n" ); do { gets( string ); ret = strncmp( string, SKY, 3 ); if( ret == 0 ) { printf( "%3.3s == %s, ret = %d \n", string, SKY, ret ); break; } else if( ret < 0 ) printf( "%s < %s, ret = %d \n", string, SKY, ret ); else printf( "%s > %s, ret = %d \n", string, SKY, ret ); } while( 1 ); } | cs |
IDA - Layout Graph
IDA - Text View
strncmp 가 함수로 실행되어 비교적 해석하기 쉽다.
pseudo code - 의사코드
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 | #include <stdio.h> main() { int ret; char string[100]; printf(_Format); printf(aSky_3); eax = string; gets(eax); ecx = string; strncmp(ecx, "sky", 3); do{ if(ret == 0) edx = ret; eax = string; printf(a33sSRetD, eax, aSky, edx); break; else if(ret < 0) ecx = ret edx = string; printf(aSSRetD, edx, aSky_0, ecx); else eax = ret; ecx = string; printf(aSSRetD_0, ecx, aSky_1, eax); while(1); eax = 0' } | cs |
pseudo code - 최종 의사코드
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 | #include <stdio.h> main() { int ret; char string[100]; printf(_Format); printf(aSky_3); gets(string); strncmp(string, "sky", 3); do{ if(ret == 0) printf(a33sSRetD, string, aSky, ret); break; else if(ret < 0) printf(aSSRetD, string, aSky_0, ret); else printf(aSSRetD_0, string, aSky_1, ret); while(1); return 0; } | cs |
'Reversing > ASM to C' 카테고리의 다른 글
ASM to C with IDA - 057 (strlen) (0) | 2018.07.16 |
---|---|
ASM to C with IDA - 056 (strcat) (0) | 2018.07.16 |
ASM to C with IDA - 054 (strcmp) (0) | 2018.07.12 |
ASM to C with IDA - 053 (0) | 2018.07.12 |
ASM to C with IDA - 052 (strcpy) (0) | 2018.07.11 |