Reversing/ASM to C

ASM to C with IDA - 008

MarcoKhan 2018. 5. 26. 10:56

C300_008


C300_소스코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h> 
 
main()
{
    int i;
    unsigned int j;
    int k;
 
    i = 2000000000;
    j = 4000000000;
    k = 'b';
 
    printf("정수형 변수 i의 값은 %d \n", i);        
    printf("정수형 변수 j의 값은 %u \n", j);
    printf("정수형 변수 k의 값은 %d \n", k);
}
cs



IDA - Layout Graph




IDA - Text View




move  [ebp+j], 0EE6B2800h 를 주목해서 보자.


0EE6B2800h이 뭔가 어색해 보이지 않는가???

원래 4byte가 와야하는데 앞에 추가로 0이 붙어있다.

unsigned int type에서 unsinged type임을 알려주는 참고자 같은 역할은 하는것 같다.


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
#include <stdio.h> 
 
main()
{
    int i;
    int j;
    int k;
 
    i = 2000000000;
    j = 4000000000;
    k = 98;
 
    eax = i;
    printf(_Format, eax);
 
    ecx = j;
    printf(byte_40303C, ecx);
 
    edx = k;
    printf(byte_403058, edx);                
 
    eax = 0;    
}
cs



pseudo code - 최종 의사 코드



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h> 
 
main()
{
    int i;
    unsigned int j;
    int k;
 
    i = 2000000000;
    j = 4000000000;
    k = 98;
 
    printf(_Format, i);
 
    printf(byte_40303C, j);
 
    printf(byte_403058, k);                
}
cs